diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-18 00:39:11 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-18 00:39:11 +0200 |
commit | c931eaa22c0890539867399f161c64abdb85a4b8 (patch) | |
tree | 1c5edf3aa8042b12ee810e6d4e63414eeb4d2854 /LibGUI | |
parent | c4c7f224d55f3c97b7385f2ce505c9a3d1d02183 (diff) | |
download | serenity-c931eaa22c0890539867399f161c64abdb85a4b8.zip |
WindowServer: Generate a separate WM event for window icon changes.
Diffstat (limited to 'LibGUI')
-rw-r--r-- | LibGUI/GEvent.h | 20 | ||||
-rw-r--r-- | LibGUI/GEventLoop.cpp | 5 | ||||
-rw-r--r-- | LibGUI/GWindow.cpp | 2 |
3 files changed, 21 insertions, 6 deletions
diff --git a/LibGUI/GEvent.h b/LibGUI/GEvent.h index 1a95331aab..cc0cd8aee2 100644 --- a/LibGUI/GEvent.h +++ b/LibGUI/GEvent.h @@ -31,6 +31,7 @@ public: WindowCloseRequest, WM_WindowRemoved, WM_WindowStateChanged, + WM_WindowIconChanged, }; GEvent() { } @@ -69,10 +70,9 @@ public: class GWMWindowStateChangedEvent : public GWMEvent { public: - GWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, GWindowType window_type, bool is_minimized, const String& icon_path) + GWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, GWindowType window_type, bool is_minimized) : GWMEvent(GEvent::Type::WM_WindowStateChanged, client_id, window_id) , m_title(title) - , m_icon_path(icon_path) , m_rect(rect) , m_window_type(window_type) , m_active(is_active) @@ -85,17 +85,29 @@ public: bool is_active() const { return m_active; } GWindowType window_type() const { return m_window_type; } bool is_minimized() const { return m_minimized; } - String icon_path() const { return m_icon_path; } private: String m_title; - String m_icon_path; Rect m_rect; GWindowType m_window_type; bool m_active; bool m_minimized; }; +class GWMWindowIconChangedEvent : public GWMEvent { +public: + GWMWindowIconChangedEvent(int client_id, int window_id, const String& icon_path) + : GWMEvent(GEvent::Type::WM_WindowIconChanged, client_id, window_id) + , m_icon_path(icon_path) + { + } + + String icon_path() const { return m_icon_path; } + +private: + String m_icon_path; +}; + class GPaintEvent final : public GEvent { public: explicit GPaintEvent(const Rect& rect, const Size& window_size = Size()) diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp index 895bf0a77c..b14c621e91 100644 --- a/LibGUI/GEventLoop.cpp +++ b/LibGUI/GEventLoop.cpp @@ -174,7 +174,9 @@ void GEventLoop::handle_wm_event(const WSAPI_ServerMessage& event, GWindow& wind dbgprintf("GEventLoop: handle_wm_event: %d\n", (int)event.type); #endif if (event.type == WSAPI_ServerMessage::WM_WindowStateChanged) - return post_event(window, make<GWMWindowStateChangedEvent>(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, event.wm.is_minimized, String(event.wm.icon_path, event.wm.icon_path_length))); + return post_event(window, make<GWMWindowStateChangedEvent>(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, event.wm.is_minimized)); + if (event.type == WSAPI_ServerMessage::WM_WindowIconChanged) + return post_event(window, make<GWMWindowIconChangedEvent>(event.wm.client_id, event.wm.window_id, String(event.text, event.text_length))); if (event.type == WSAPI_ServerMessage::WM_WindowRemoved) return post_event(window, make<GWMWindowRemovedEvent>(event.wm.client_id, event.wm.window_id)); ASSERT_NOT_REACHED(); @@ -277,6 +279,7 @@ void GEventLoop::process_unprocessed_messages() break; case WSAPI_ServerMessage::Type::WM_WindowRemoved: case WSAPI_ServerMessage::Type::WM_WindowStateChanged: + case WSAPI_ServerMessage::Type::WM_WindowIconChanged: handle_wm_event(event, *window); break; default: diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index 5e294ffc25..31f9c33e8f 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -277,7 +277,7 @@ void GWindow::event(CEvent& event) return; } - if (event.type() == GEvent::WM_WindowRemoved || event.type() == GEvent::WM_WindowStateChanged) + if (event.type() == GEvent::WM_WindowRemoved || event.type() == GEvent::WM_WindowStateChanged || event.type() == GEvent::WM_WindowIconChanged) return wm_event(static_cast<GWMEvent&>(event)); CObject::event(event); |