diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-30 22:41:14 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-30 23:43:24 +0200 |
commit | 9bbc1c9c930157ba89eb0c3554a67bf4bd6fe7cb (patch) | |
tree | aa489410241d0cc35f653e28bbc2250d6b6a871d /Userland/Services/Taskbar | |
parent | 44602ae1413dc374e7590dab738944e4e07a653d (diff) | |
download | serenity-9bbc1c9c930157ba89eb0c3554a67bf4bd6fe7cb.zip |
WindowServer+Taskbar: Show applets in taskbar :^)
WindowServer now collects applet windows into an "applet area" which is
really just a window that a WM (window management) client can position
via IPC.
This is rather hackish, and I think we should come up with a better
architecture eventually, but this brings back the missing applets since
the global menu where they used to live is gone.
Diffstat (limited to 'Userland/Services/Taskbar')
-rw-r--r-- | Userland/Services/Taskbar/TaskbarWindow.cpp | 22 | ||||
-rw-r--r-- | Userland/Services/Taskbar/TaskbarWindow.h | 1 |
2 files changed, 20 insertions, 3 deletions
diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index be2aa50093..9d7af74e4f 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -88,7 +88,7 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu) auto& start_button = main_widget.add<GUI::Button>("Serenity"); start_button.set_font(Gfx::FontDatabase::default_bold_font()); start_button.set_icon_spacing(0); - start_button.set_fixed_width(80); + start_button.set_fixed_size(80, 22); auto app_icon = GUI::Icon::default_icon("ladybug"); start_button.set_icon(app_icon.bitmap_for_size(16)); @@ -104,6 +104,11 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu) m_default_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window.png"); + m_applet_area_container = main_widget.add<GUI::Frame>(); + m_applet_area_container->set_frame_thickness(1); + m_applet_area_container->set_frame_shape(Gfx::FrameShape::Box); + m_applet_area_container->set_frame_shadow(Gfx::FrameShadow::Sunken); + main_widget.add<Taskbar::ClockWidget>(); } @@ -175,8 +180,8 @@ void TaskbarWindow::on_screen_rect_change(const Gfx::IntRect& rect) NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& identifier) { auto& button = m_task_button_container->add<TaskbarButton>(identifier); - button.set_min_size(20, 23); - button.set_max_size(140, 23); + button.set_min_size(20, 22); + button.set_max_size(140, 22); button.set_text_alignment(Gfx::TextAlignment::CenterLeft); button.set_icon(*m_default_icon); return button; @@ -317,6 +322,17 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event) } break; } + case GUI::Event::WM_AppletAreaSizeChanged: { + auto& changed_event = static_cast<GUI::WMAppletAreaSizeChangedEvent&>(event); + m_applet_area_container->set_fixed_size(changed_event.size().width() + 8, 22); + // NOTE: Widget layout is normally lazy, but here we have to force it right away so we can tell + // WindowServer where to place the applet area window. + main_widget()->do_layout(); + Gfx::IntRect new_rect { {}, changed_event.size() }; + new_rect.center_within(m_applet_area_container->screen_relative_rect()); + GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::WM_SetAppletAreaPosition>(new_rect.location()); + break; + } default: break; } diff --git a/Userland/Services/Taskbar/TaskbarWindow.h b/Userland/Services/Taskbar/TaskbarWindow.h index e88309c55c..3f12d8430e 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.h +++ b/Userland/Services/Taskbar/TaskbarWindow.h @@ -53,4 +53,5 @@ private: NonnullRefPtr<GUI::Menu> m_start_menu; RefPtr<GUI::Widget> m_task_button_container; RefPtr<Gfx::Bitmap> m_default_icon; + RefPtr<GUI::Frame> m_applet_area_container; }; |