diff --git a/Applications/Taskbar/TaskbarWindow.cpp b/Applications/Taskbar/TaskbarWindow.cpp index 28b54fa804..1f1a8b1d4b 100644 --- a/Applications/Taskbar/TaskbarWindow.cpp +++ b/Applications/Taskbar/TaskbarWindow.cpp @@ -66,12 +66,13 @@ void TaskbarWindow::wm_event(GWMEvent& event) } case GEvent::WM_WindowStateChanged: { auto& changed_event = static_cast(event); - printf("WM_WindowStateChanged: client_id=%d, window_id=%d, title=%s, rect=%s, is_active=%u\n", + printf("WM_WindowStateChanged: client_id=%d, window_id=%d, title=%s, rect=%s, is_active=%u, is_minimized=%u\n", changed_event.client_id(), changed_event.window_id(), changed_event.title().characters(), changed_event.rect().to_string().characters(), - changed_event.is_active() + changed_event.is_active(), + changed_event.is_minimized() ); if (!should_include_window(changed_event.window_type())) break; @@ -79,8 +80,16 @@ void TaskbarWindow::wm_event(GWMEvent& event) window.set_title(changed_event.title()); window.set_rect(changed_event.rect()); window.set_active(changed_event.is_active()); - window.button()->set_caption(changed_event.title()); + window.set_minimized(changed_event.is_minimized()); + if (window.is_minimized()) { + window.button()->set_foreground_color(Color::DarkGray); + window.button()->set_caption(String::format("[%s]", changed_event.title().characters())); + } else { + window.button()->set_foreground_color(Color::Black); + window.button()->set_caption(changed_event.title()); + } window.button()->set_checked(changed_event.is_active()); + window.button()->update(); break; } default: diff --git a/Applications/Taskbar/WindowList.h b/Applications/Taskbar/WindowList.h index c48b287087..ff6ca9d103 100644 --- a/Applications/Taskbar/WindowList.h +++ b/Applications/Taskbar/WindowList.h @@ -60,12 +60,16 @@ public: void set_active(bool active) { m_active = active; } bool is_active() const { return m_active; } + void set_minimized(bool minimized) { m_minimized = minimized; } + bool is_minimized() const { return m_minimized; } + private: WindowIdentifier m_identifier; String m_title; Rect m_rect; GButton* m_button { nullptr }; bool m_active { false }; + bool m_minimized { false }; }; class WindowList { diff --git a/LibGUI/GEvent.h b/LibGUI/GEvent.h index 9d35dac93c..8d5530d994 100644 --- a/LibGUI/GEvent.h +++ b/LibGUI/GEvent.h @@ -82,12 +82,13 @@ 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) + 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_rect(rect) , m_active(is_active) , m_window_type(window_type) + , m_minimized(is_minimized) { } @@ -95,12 +96,14 @@ public: Rect rect() const { return m_rect; } bool is_active() const { return m_active; } GWindowType window_type() const { return m_window_type; } + bool is_minimized() const { return m_minimized; } private: String m_title; Rect m_rect; bool m_active; GWindowType m_window_type; + bool m_minimized; }; class QuitEvent final : public GEvent { diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp index fea0d7a334..356ea23e62 100644 --- a/LibGUI/GEventLoop.cpp +++ b/LibGUI/GEventLoop.cpp @@ -274,7 +274,7 @@ 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(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)); + 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, event.wm.is_minimized)); 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/Servers/WindowServer/WSAPITypes.h b/Servers/WindowServer/WSAPITypes.h index 7726198af7..bcd836f8c7 100644 --- a/Servers/WindowServer/WSAPITypes.h +++ b/Servers/WindowServer/WSAPITypes.h @@ -112,6 +112,7 @@ struct WSAPI_ServerMessage { int window_id; WSAPI_Rect rect; bool is_active; + bool is_minimized; WSAPI_WindowType window_type; } wm; struct { diff --git a/Servers/WindowServer/WSMessage.h b/Servers/WindowServer/WSMessage.h index d67bc1c8c8..051e86bffa 100644 --- a/Servers/WindowServer/WSMessage.h +++ b/Servers/WindowServer/WSMessage.h @@ -632,12 +632,13 @@ public: class WSWMWindowStateChangedEvent : public WSWMEvent { public: - WSWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, WSWindowType window_type) + WSWMWindowStateChangedEvent(int client_id, int window_id, const String& title, const Rect& rect, bool is_active, WSWindowType window_type, bool is_minimized) : WSWMEvent(WSMessage::WM_WindowStateChanged, client_id, window_id) , m_title(title) , m_rect(rect) , m_active(is_active) , m_window_type(window_type) + , m_minimized(is_minimized) { } @@ -645,10 +646,12 @@ public: Rect rect() const { return m_rect; } bool is_active() const { return m_active; } WSWindowType window_type() const { return m_window_type; } + bool is_minimized() const { return m_minimized; } private: String m_title; Rect m_rect; bool m_active; WSWindowType m_window_type; + bool m_minimized; }; diff --git a/Servers/WindowServer/WSWindow.cpp b/Servers/WindowServer/WSWindow.cpp index 397ac952ab..10d800ced5 100644 --- a/Servers/WindowServer/WSWindow.cpp +++ b/Servers/WindowServer/WSWindow.cpp @@ -118,6 +118,7 @@ void WSWindow::set_minimized(bool minimized) return; m_minimized = minimized; invalidate(); + WSWindowManager::the().notify_minimization_state_changed(*this); } void WSWindow::on_message(const WSMessage& message) @@ -180,6 +181,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.is_minimized = changed_event.is_minimized(); 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()); diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index 6df3fb053d..8e7b9c096e 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -362,7 +362,7 @@ 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())); + WSMessageLoop::the().post_message(listener, make(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type(), window.is_minimized())); } void WSWindowManager::tell_wm_listeners_window_state_changed(WSWindow& window) @@ -395,6 +395,11 @@ void WSWindowManager::notify_rect_changed(WSWindow& window, const Rect& old_rect tell_wm_listeners_window_state_changed(window); } +void WSWindowManager::notify_minimization_state_changed(WSWindow& window) +{ + tell_wm_listeners_window_state_changed(window); +} + void WSWindowManager::handle_menu_mouse_event(WSMenu& menu, const WSMouseEvent& event) { bool is_hover_with_any_menu_open = event.type() == WSMouseEvent::MouseMove && m_current_menu; diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h index e6f89648d8..185a04af9b 100644 --- a/Servers/WindowServer/WSWindowManager.h +++ b/Servers/WindowServer/WSWindowManager.h @@ -43,6 +43,7 @@ public: void notify_title_changed(WSWindow&); void notify_rect_changed(WSWindow&, const Rect& oldRect, const Rect& newRect); + void notify_minimization_state_changed(WSWindow&); void notify_client_changed_app_menubar(WSClientConnection&); WSWindow* active_window() { return m_active_window.ptr(); }