mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
Taskbar: Reposition the applet area when the desktop rect changes
This commit is contained in:
parent
0cd60a28ba
commit
2231205863
2 changed files with 19 additions and 6 deletions
|
@ -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<Messages::WindowServer::WM_SetAppletAreaPosition>(new_rect.location());
|
||||
}
|
||||
|
||||
NonnullRefPtr<GUI::Button> 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<GUI::WMAppletAreaSizeChangedEvent&>(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<Messages::WindowServer::WM_SetAppletAreaPosition>(new_rect.location());
|
||||
update_applet_area();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -50,8 +50,12 @@ private:
|
|||
|
||||
virtual void wm_event(GUI::WMEvent&) override;
|
||||
|
||||
void update_applet_area();
|
||||
|
||||
NonnullRefPtr<GUI::Menu> m_start_menu;
|
||||
RefPtr<GUI::Widget> m_task_button_container;
|
||||
RefPtr<Gfx::Bitmap> m_default_icon;
|
||||
|
||||
Gfx::IntSize m_applet_area_size;
|
||||
RefPtr<GUI::Frame> m_applet_area_container;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue