diff --git a/Applications/Taskbar/TaskbarWindow.cpp b/Applications/Taskbar/TaskbarWindow.cpp index af7d80faf5..28b54fa804 100644 --- a/Applications/Taskbar/TaskbarWindow.cpp +++ b/Applications/Taskbar/TaskbarWindow.cpp @@ -54,26 +54,6 @@ void TaskbarWindow::wm_event(GWMEvent& event) { WindowIdentifier identifier { event.client_id(), event.window_id() }; switch (event.type()) { - case GEvent::WM_WindowAdded: { - auto& added_event = static_cast(event); - printf("WM_WindowAdded: client_id=%d, window_id=%d, title=%s, rect=%s, is_active=%u\n", - added_event.client_id(), - added_event.window_id(), - added_event.title().characters(), - added_event.rect().to_string().characters(), - added_event.is_active() - ); - if (!should_include_window(added_event.window_type())) - break; - auto& window = m_window_list.ensure_window(identifier); - window.set_title(added_event.title()); - window.set_rect(added_event.rect()); - window.set_active(added_event.is_active()); - window.button()->set_caption(window.title()); - window.button()->set_checked(window.is_active()); - update(); - break; - } case GEvent::WM_WindowRemoved: { auto& removed_event = static_cast(event); printf("WM_WindowRemoved: client_id=%d, window_id=%d\n", diff --git a/LibGUI/GEvent.h b/LibGUI/GEvent.h index 5e572916a3..9d35dac93c 100644 --- a/LibGUI/GEvent.h +++ b/LibGUI/GEvent.h @@ -37,7 +37,6 @@ public: WindowCloseRequest, ChildAdded, ChildRemoved, - WM_WindowAdded, WM_WindowRemoved, WM_WindowStateChanged, }; @@ -73,29 +72,6 @@ private: int m_window_id { -1 }; }; -class GWMWindowAddedEvent : public GWMEvent { -public: - GWMWindowAddedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, GWindowType window_type) - : GWMEvent(GEvent::Type::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; } - GWindowType window_type() const { return m_window_type; } - -private: - String m_title; - Rect m_rect; - bool m_active; - GWindowType m_window_type; -}; - class GWMWindowRemovedEvent : public GWMEvent { public: GWMWindowRemovedEvent(int client_id, int window_id) diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp index 39dccb0187..fea0d7a334 100644 --- a/LibGUI/GEventLoop.cpp +++ b/LibGUI/GEventLoop.cpp @@ -273,8 +273,6 @@ void GEventLoop::handle_wm_event(const WSAPI_ServerMessage& event, GWindow& wind #ifdef GEVENTLOOP_DEBUG dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type); #endif - if (event.type == WSAPI_ServerMessage::WM_WindowAdded) - return post_event(window, make(event.wm.client_id, event.wm.window_id, String(event.text, event.text_length), event.wm.rect, event.wm.is_active, (GWindowType)event.wm.window_type)); if (event.type == WSAPI_ServerMessage::WM_WindowStateChanged) return post_event(window, make(event.wm.client_id, event.wm.window_id, String(event.text, event.text_length), event.wm.rect, event.wm.is_active, (GWindowType)event.wm.window_type)); if (event.type == WSAPI_ServerMessage::WM_WindowRemoved) @@ -411,7 +409,6 @@ void GEventLoop::process_unprocessed_messages() case WSAPI_ServerMessage::Type::WindowResized: handle_resize_event(event, *window); break; - case WSAPI_ServerMessage::Type::WM_WindowAdded: case WSAPI_ServerMessage::Type::WM_WindowRemoved: case WSAPI_ServerMessage::Type::WM_WindowStateChanged: handle_wm_event(event, *window); diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index 59d0280139..973737ccbe 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -258,7 +258,7 @@ void GWindow::event(GEvent& event) return; } - if (event.type() == GEvent::WM_WindowAdded || event.type() == GEvent::WM_WindowRemoved || event.type() == GEvent::WM_WindowStateChanged) + if (event.type() == GEvent::WM_WindowRemoved || event.type() == GEvent::WM_WindowStateChanged) return wm_event(static_cast(event)); GObject::event(event); 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(message).old_rect(); server_message.window.rect = static_cast(message).rect(); break; - case WSMessage::WM_WindowAdded: { - auto& added_event = static_cast(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(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(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(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(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(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;