mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:07:35 +00:00
WindowServer: Merge WM_WindowAdded and WM_WindowStateChanged.
These events are identical, so it's silly to send both. Just broadcast window state changes everywhere instead, it doesn't matter when it was added as clients are learning about this asynchronously anyway.
This commit is contained in:
parent
329cc60a92
commit
99b98dc653
9 changed files with 14 additions and 97 deletions
|
@ -93,7 +93,6 @@ struct WSAPI_ServerMessage {
|
|||
DidSetWallpaper,
|
||||
DidGetWallpaper,
|
||||
ScreenRectChanged,
|
||||
WM_WindowAdded,
|
||||
WM_WindowRemoved,
|
||||
WM_WindowStateChanged,
|
||||
};
|
||||
|
|
|
@ -26,7 +26,6 @@ public:
|
|||
WindowCloseRequest,
|
||||
WindowResized,
|
||||
|
||||
WM_WindowAdded,
|
||||
WM_WindowRemoved,
|
||||
WM_WindowStateChanged,
|
||||
|
||||
|
@ -621,29 +620,6 @@ private:
|
|||
int m_window_id;
|
||||
};
|
||||
|
||||
class WSWMWindowAddedEvent : public WSWMEvent {
|
||||
public:
|
||||
WSWMWindowAddedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, WSWindowType window_type)
|
||||
: WSWMEvent(WSMessage::WM_WindowAdded, client_id, window_id)
|
||||
, m_title(title)
|
||||
, m_rect(rect)
|
||||
, m_active(is_active)
|
||||
, m_window_type(window_type)
|
||||
{
|
||||
}
|
||||
|
||||
String title() const { return m_title; }
|
||||
Rect rect() const { return m_rect; }
|
||||
bool is_active() const { return m_active; }
|
||||
WSWindowType window_type() const { return m_window_type; }
|
||||
|
||||
private:
|
||||
String m_title;
|
||||
Rect m_rect;
|
||||
bool m_active;
|
||||
WSWindowType m_window_type;
|
||||
};
|
||||
|
||||
class WSWMWindowRemovedEvent : public WSWMEvent {
|
||||
public:
|
||||
WSWMWindowRemovedEvent(int client_id, int window_id)
|
||||
|
|
|
@ -157,19 +157,6 @@ void WSWindow::on_message(const WSMessage& message)
|
|||
server_message.window.old_rect = static_cast<const WSResizeEvent&>(message).old_rect();
|
||||
server_message.window.rect = static_cast<const WSResizeEvent&>(message).rect();
|
||||
break;
|
||||
case WSMessage::WM_WindowAdded: {
|
||||
auto& added_event = static_cast<const WSWMWindowAddedEvent&>(message);
|
||||
server_message.type = WSAPI_ServerMessage::Type::WM_WindowAdded;
|
||||
server_message.wm.client_id = added_event.client_id();
|
||||
server_message.wm.window_id = added_event.window_id();
|
||||
server_message.wm.is_active = added_event.is_active();
|
||||
server_message.wm.window_type = to_api(added_event.window_type());
|
||||
ASSERT(added_event.title().length() < sizeof(server_message.text));
|
||||
memcpy(server_message.text, added_event.title().characters(), added_event.title().length());
|
||||
server_message.text_length = added_event.title().length();
|
||||
server_message.wm.rect = added_event.rect();
|
||||
break;
|
||||
}
|
||||
case WSMessage::WM_WindowRemoved: {
|
||||
auto& removed_event = static_cast<const WSWMWindowRemovedEvent&>(message);
|
||||
server_message.type = WSAPI_ServerMessage::Type::WM_WindowRemoved;
|
||||
|
|
|
@ -494,18 +494,14 @@ void WSWindowManager::add_window(WSWindow& window)
|
|||
m_switcher.refresh();
|
||||
|
||||
if (window.listens_to_wm_events()) {
|
||||
for_each_window([&window] (WSWindow& other_window) {
|
||||
if (&window != &other_window && other_window.client())
|
||||
WSMessageLoop::the().post_message(window, make<WSWMWindowAddedEvent>(other_window.client()->client_id(), other_window.window_id(), other_window.title(), other_window.rect(), other_window.is_active(), other_window.type()));
|
||||
for_each_window([&] (WSWindow& other_window) {
|
||||
if (&window != &other_window)
|
||||
tell_wm_listener_about_window(window, other_window);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
for_each_window_listening_to_wm_events([&window] (WSWindow& listener) {
|
||||
if (window.client())
|
||||
WSMessageLoop::the().post_message(listener, make<WSWMWindowAddedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type()));
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
tell_wm_listeners_window_state_changed(window);
|
||||
}
|
||||
|
||||
void WSWindowManager::move_to_front_and_make_active(WSWindow& window)
|
||||
|
@ -541,11 +537,16 @@ void WSWindowManager::remove_window(WSWindow& window)
|
|||
});
|
||||
}
|
||||
|
||||
void WSWindowManager::tell_wm_listener_about_window(WSWindow& listener, WSWindow& window)
|
||||
{
|
||||
if (window.client())
|
||||
WSMessageLoop::the().post_message(listener, make<WSWMWindowStateChangedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type()));
|
||||
}
|
||||
|
||||
void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window)
|
||||
{
|
||||
for_each_window_listening_to_wm_events([&window] (WSWindow& listener) {
|
||||
if (window.client())
|
||||
WSMessageLoop::the().post_message(listener, make<WSWMWindowStateChangedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type()));
|
||||
for_each_window_listening_to_wm_events([&] (WSWindow& listener) {
|
||||
tell_wm_listener_about_window(listener, window);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ private:
|
|||
void flip_buffers();
|
||||
void tick_clock();
|
||||
void tell_wm_listeners_window_state_changed(WSWindow&);
|
||||
void tell_wm_listener_about_window(WSWindow& listener, WSWindow&);
|
||||
|
||||
WSScreen& m_screen;
|
||||
Rect m_screen_rect;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue