summaryrefslogtreecommitdiff
path: root/Applications/Taskbar/TaskbarWindow.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-04 13:19:26 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-04 13:19:26 +0200
commit7b1384c4ef3041df1b44351fb4907d6f40d95b24 (patch)
treeb7fac5c11370abbcdf60aeeb29c8d70d44bbc46b /Applications/Taskbar/TaskbarWindow.cpp
parent19eb81485097138139f9058267494d90e32af58a (diff)
downloadserenity-7b1384c4ef3041df1b44351fb4907d6f40d95b24.zip
Taskbar: Plumb window active state from the WindowServer to the taskbar.
Diffstat (limited to 'Applications/Taskbar/TaskbarWindow.cpp')
-rw-r--r--Applications/Taskbar/TaskbarWindow.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/Applications/Taskbar/TaskbarWindow.cpp b/Applications/Taskbar/TaskbarWindow.cpp
index b139c1fed3..b93e329831 100644
--- a/Applications/Taskbar/TaskbarWindow.cpp
+++ b/Applications/Taskbar/TaskbarWindow.cpp
@@ -19,6 +19,10 @@ TaskbarWindow::TaskbarWindow()
auto* widget = new TaskbarWidget(m_window_list);
set_main_widget(widget);
+
+ m_window_list.aid_create_button = [this] {
+ return create_button();
+ };
}
TaskbarWindow::~TaskbarWindow()
@@ -31,25 +35,34 @@ void TaskbarWindow::on_screen_rect_change(const Rect& rect)
set_rect(new_rect);
}
+GButton* TaskbarWindow::create_button()
+{
+ auto* button = new GButton(main_widget());
+ button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
+ button->set_preferred_size({ 100, 22 });
+ button->set_checkable(true);
+ return button;
+}
+
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<GWMWindowAddedEvent&>(event);
- printf("WM_WindowAdded: client_id=%d, window_id=%d, title=%s, rect=%s\n",
+ 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.rect().to_string().characters(),
+ added_event.is_active()
);
auto& window = m_window_list.ensure_window(identifier);
window.set_title(added_event.title());
window.set_rect(added_event.rect());
- window.set_button(new GButton(main_widget()));
- window.button()->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
- window.button()->set_preferred_size({ 100, 22 });
+ window.set_active(added_event.is_active());
window.button()->set_caption(window.title());
+ window.button()->set_checked(window.is_active());
update();
break;
}
@@ -65,16 +78,19 @@ 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\n",
+ printf("WM_WindowStateChanged: client_id=%d, window_id=%d, title=%s, rect=%s, is_active=%u\n",
changed_event.client_id(),
changed_event.window_id(),
changed_event.title().characters(),
- changed_event.rect().to_string().characters()
+ changed_event.rect().to_string().characters(),
+ changed_event.is_active()
);
auto& window = m_window_list.ensure_window(identifier);
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.button()->set_checked(changed_event.is_active());
break;
}
default: