diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index 9d7af74e4f..99f3101e3a 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -175,6 +175,19 @@ void TaskbarWindow::on_screen_rect_change(const Gfx::IntRect& rect) { Gfx::IntRect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() }; set_rect(new_rect); + update_applet_area(); +} + +void TaskbarWindow::update_applet_area() +{ + // 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. + if (!main_widget()) + return; + main_widget()->do_layout(); + Gfx::IntRect new_rect { {}, m_applet_area_size }; + new_rect.center_within(m_applet_area_container->screen_relative_rect()); + GUI::WindowServerConnection::the().send_sync(new_rect.location()); } NonnullRefPtr TaskbarWindow::create_button(const WindowIdentifier& identifier) @@ -324,13 +337,9 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event) } case GUI::Event::WM_AppletAreaSizeChanged: { auto& changed_event = static_cast(event); + m_applet_area_size = changed_event.size(); 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(new_rect.location()); + update_applet_area(); break; } default: diff --git a/Userland/Services/Taskbar/TaskbarWindow.h b/Userland/Services/Taskbar/TaskbarWindow.h index 3f12d8430e..2c0f9941ea 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.h +++ b/Userland/Services/Taskbar/TaskbarWindow.h @@ -50,8 +50,12 @@ private: virtual void wm_event(GUI::WMEvent&) override; + void update_applet_area(); + NonnullRefPtr m_start_menu; RefPtr m_task_button_container; RefPtr m_default_icon; + + Gfx::IntSize m_applet_area_size; RefPtr m_applet_area_container; };