mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47:35 +00:00
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.
This commit is contained in:
parent
44602ae141
commit
9bbc1c9c93
18 changed files with 145 additions and 40 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue