diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-05 15:01:28 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-05 15:01:28 +0200 |
commit | 99b98dc65359bc02d28e8d5d51a55c7a69fe6fff (patch) | |
tree | 2388dd4a8f75f7ebfa4f82df065ae042244e0c94 /Servers | |
parent | 329cc60a92188fcfd2a5cffa1792d04385b848c9 (diff) | |
download | serenity-99b98dc65359bc02d28e8d5d51a55c7a69fe6fff.zip |
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.
Diffstat (limited to 'Servers')
-rw-r--r-- | Servers/WindowServer/WSAPITypes.h | 1 | ||||
-rw-r--r-- | Servers/WindowServer/WSMessage.h | 24 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindow.cpp | 13 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowManager.cpp | 23 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowManager.h | 1 |
5 files changed, 13 insertions, 49 deletions
diff --git a/Servers/WindowServer/WSAPITypes.h b/Servers/WindowServer/WSAPITypes.h index 8a80f8c2ed..7726198af7 100644 --- a/Servers/WindowServer/WSAPITypes.h +++ b/Servers/WindowServer/WSAPITypes.h @@ -93,7 +93,6 @@ struct WSAPI_ServerMessage { DidSetWallpaper, DidGetWallpaper, ScreenRectChanged, - WM_WindowAdded, WM_WindowRemoved, WM_WindowStateChanged, }; diff --git a/Servers/WindowServer/WSMessage.h b/Servers/WindowServer/WSMessage.h index 3e676f8926..7290072085 100644 --- a/Servers/WindowServer/WSMessage.h +++ b/Servers/WindowServer/WSMessage.h @@ -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) diff --git a/Servers/WindowServer/WSWindow.cpp b/Servers/WindowServer/WSWindow.cpp index 61b43bea5e..b14f1b66ef 100644 --- a/Servers/WindowServer/WSWindow.cpp +++ b/Servers/WindowServer/WSWindow.cpp @@ -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; diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index 3f7fd48df7..d48482dfd1 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -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; }); } diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h index 8436d9a657..5c487f2256 100644 --- a/Servers/WindowServer/WSWindowManager.h +++ b/Servers/WindowServer/WSWindowManager.h @@ -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; |