diff --git a/Applications/Taskbar/TaskbarWindow.cpp b/Applications/Taskbar/TaskbarWindow.cpp index 69e5261da2..eb332efdf9 100644 --- a/Applications/Taskbar/TaskbarWindow.cpp +++ b/Applications/Taskbar/TaskbarWindow.cpp @@ -45,6 +45,11 @@ GButton* TaskbarWindow::create_button() return button; } +static bool should_include_window(GWindowType window_type) +{ + return window_type == GWindowType::Normal; +} + void TaskbarWindow::wm_event(GWMEvent& event) { WindowIdentifier identifier { event.client_id(), event.window_id() }; @@ -58,6 +63,8 @@ void TaskbarWindow::wm_event(GWMEvent& event) 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()); @@ -86,6 +93,8 @@ void TaskbarWindow::wm_event(GWMEvent& event) changed_event.rect().to_string().characters(), changed_event.is_active() ); + if (!should_include_window(changed_event.window_type())) + break; auto& window = m_window_list.ensure_window(identifier); window.set_title(changed_event.title()); window.set_rect(changed_event.rect()); diff --git a/LibGUI/GEvent.h b/LibGUI/GEvent.h index 1d1d02bd81..5e572916a3 100644 --- a/LibGUI/GEvent.h +++ b/LibGUI/GEvent.h @@ -6,6 +6,7 @@ #include #include #include +#include class GObject; @@ -74,22 +75,25 @@ private: class GWMWindowAddedEvent : public GWMEvent { public: - GWMWindowAddedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active) + 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 { @@ -102,22 +106,25 @@ public: class GWMWindowStateChangedEvent : public GWMEvent { public: - GWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active) + GWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, GWindowType window_type) : GWMEvent(GEvent::Type::WM_WindowStateChanged, 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 QuitEvent final : public GEvent { diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp index 406bf7e80c..39dccb0187 100644 --- a/LibGUI/GEventLoop.cpp +++ b/LibGUI/GEventLoop.cpp @@ -270,10 +270,13 @@ void GEventLoop::handle_menu_event(const WSAPI_ServerMessage& event) void GEventLoop::handle_wm_event(const WSAPI_ServerMessage& event, GWindow& window) { +#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)); + 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)); + 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) return post_event(window, make(event.wm.client_id, event.wm.window_id)); ASSERT_NOT_REACHED(); diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h index 845b4b7c3d..9504c32dc9 100644 --- a/LibGUI/GWindow.h +++ b/LibGUI/GWindow.h @@ -1,6 +1,7 @@ #pragma once -#include "GObject.h" +#include +#include #include #include #include @@ -17,12 +18,6 @@ enum class GStandardCursor { ResizeVertical, }; -enum class GWindowType { - Invalid = 0, - Normal, - Taskbar, -}; - class GWindow : public GObject { public: GWindow(GObject* parent = nullptr); diff --git a/LibGUI/GWindowType.h b/LibGUI/GWindowType.h new file mode 100644 index 0000000000..18ae16fdec --- /dev/null +++ b/LibGUI/GWindowType.h @@ -0,0 +1,9 @@ +#pragma once + +enum class GWindowType { + Invalid = 0, + Normal, + Menu, + WindowSwitcher, + Taskbar, +}; diff --git a/Servers/WindowServer/WSAPITypes.h b/Servers/WindowServer/WSAPITypes.h index ee271f8961..8a80f8c2ed 100644 --- a/Servers/WindowServer/WSAPITypes.h +++ b/Servers/WindowServer/WSAPITypes.h @@ -23,6 +23,8 @@ struct WSAPI_Rect { enum WSAPI_WindowType { Invalid = 0, Normal, + Menu, + WindowSwitcher, Taskbar, }; @@ -111,6 +113,7 @@ struct WSAPI_ServerMessage { int window_id; WSAPI_Rect rect; bool is_active; + WSAPI_WindowType window_type; } wm; struct { WSAPI_Rect rect; diff --git a/Servers/WindowServer/WSMessage.h b/Servers/WindowServer/WSMessage.h index 32bf2135ec..3e676f8926 100644 --- a/Servers/WindowServer/WSMessage.h +++ b/Servers/WindowServer/WSMessage.h @@ -623,22 +623,25 @@ private: class WSWMWindowAddedEvent : public WSWMEvent { public: - WSWMWindowAddedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active) + 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 { @@ -651,20 +654,23 @@ public: class WSWMWindowStateChangedEvent : public WSWMEvent { public: - WSWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active) + WSWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, WSWindowType window_type) : WSWMEvent(WSMessage::WM_WindowStateChanged, 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; }; diff --git a/Servers/WindowServer/WSMessageLoop.cpp b/Servers/WindowServer/WSMessageLoop.cpp index 8709f50c1f..2f8aecf8c8 100644 --- a/Servers/WindowServer/WSMessageLoop.cpp +++ b/Servers/WindowServer/WSMessageLoop.cpp @@ -254,6 +254,10 @@ static WSWindowType from_api(WSAPI_WindowType api_type) switch (api_type) { case WSAPI_WindowType::Normal: return WSWindowType::Normal; + case WSAPI_WindowType::Menu: + return WSWindowType::Menu; + case WSAPI_WindowType::WindowSwitcher: + return WSWindowType::WindowSwitcher; case WSAPI_WindowType::Taskbar: return WSWindowType::Taskbar; default: diff --git a/Servers/WindowServer/WSWindow.cpp b/Servers/WindowServer/WSWindow.cpp index 1b80fc0ae6..61b43bea5e 100644 --- a/Servers/WindowServer/WSWindow.cpp +++ b/Servers/WindowServer/WSWindow.cpp @@ -94,6 +94,22 @@ void WSWindow::handle_mouse_event(const WSMouseEvent& event) m_client->post_message(server_message); } +static WSAPI_WindowType to_api(WSWindowType ws_type) +{ + switch (ws_type) { + case WSWindowType::Normal: + return WSAPI_WindowType::Normal; + case WSWindowType::Menu: + return WSAPI_WindowType::Menu; + case WSWindowType::WindowSwitcher: + return WSAPI_WindowType::WindowSwitcher; + case WSWindowType::Taskbar: + return WSAPI_WindowType::Taskbar; + default: + ASSERT_NOT_REACHED(); + } +} + void WSWindow::on_message(const WSMessage& message) { if (m_internal_owner) @@ -147,6 +163,7 @@ void WSWindow::on_message(const WSMessage& message) 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(); @@ -166,6 +183,7 @@ void WSWindow::on_message(const WSMessage& message) server_message.wm.client_id = changed_event.client_id(); server_message.wm.window_id = changed_event.window_id(); server_message.wm.is_active = changed_event.is_active(); + server_message.wm.window_type = to_api(changed_event.window_type()); ASSERT(changed_event.title().length() < sizeof(server_message.text)); memcpy(server_message.text, changed_event.title().characters(), changed_event.title().length()); server_message.text_length = changed_event.title().length(); diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index c88c1bcab2..d9eb2f7285 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -496,14 +496,14 @@ void WSWindowManager::add_window(WSWindow& window) 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())); + 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())); 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())); + 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; }); } @@ -545,7 +545,7 @@ 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())); + 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; }); }