mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:07:35 +00:00
Taskbar: Show minimized window titles in [brackets].
Had to plumb the minimization state from WindowServer to Toolbar in order to implement this.
This commit is contained in:
parent
74142d78c1
commit
ef9fbef4c6
9 changed files with 35 additions and 7 deletions
|
@ -66,12 +66,13 @@ void TaskbarWindow::wm_event(GWMEvent& event)
|
|||
}
|
||||
case GEvent::WM_WindowStateChanged: {
|
||||
auto& changed_event = static_cast<GWMWindowStateChangedEvent&>(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.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:
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<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));
|
||||
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_WindowRemoved)
|
||||
return post_event(window, make<GWMWindowRemovedEvent>(event.wm.client_id, event.wm.window_id));
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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<WSWMWindowStateChangedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active(), window.type()));
|
||||
WSMessageLoop::the().post_message(listener, make<WSWMWindowStateChangedEvent>(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;
|
||||
|
|
|
@ -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(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue