1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-06 04:37:35 +00:00

WindowServer+CPUGraph: Make menu applets be "regular" windows

Instead of implementing menu applets as their own thing, they are now
WSWindows of WSWindowType::MenuApplet.

This makes it much easier to work with them on the client side, since
you can just create a GWindow with the right type and you're in the
menubar doing applet stuff :^)
This commit is contained in:
Andreas Kling 2019-12-16 15:05:45 +01:00
parent 648ed76085
commit df129bbe0e
13 changed files with 97 additions and 202 deletions

View file

@ -298,7 +298,7 @@ void WSMenuManager::close_bar()
m_bar_open = false;
}
void WSMenuManager::add_applet(WSMenuApplet& applet)
void WSMenuManager::add_applet(WSWindow& applet)
{
int right_edge_x = m_audio_rect.x() - 4;
for (auto& existing_applet : m_applets) {
@ -314,22 +314,22 @@ void WSMenuManager::add_applet(WSMenuApplet& applet)
m_applets.append(applet.make_weak_ptr());
}
void WSMenuManager::remove_applet(WSMenuApplet& applet)
void WSMenuManager::remove_applet(WSWindow& applet)
{
m_applets.remove_first_matching([&](auto& entry) {
return &applet == entry.ptr();
});
}
void WSMenuManager::draw_applet(const WSMenuApplet& applet)
void WSMenuManager::draw_applet(const WSWindow& applet)
{
if (!applet.bitmap())
if (!applet.backing_store())
return;
Painter painter(*window().backing_store());
painter.blit(applet.rect_in_menubar().location(), *applet.bitmap(), applet.bitmap()->rect());
painter.blit(applet.rect_in_menubar().location(), *applet.backing_store(), applet.backing_store()->rect());
}
void WSMenuManager::invalidate_applet(WSMenuApplet& applet, const Rect& rect)
void WSMenuManager::invalidate_applet(const WSWindow& applet, const Rect& rect)
{
// FIXME: This should only invalidate the applet's own rect, not the whole menubar.
(void)rect;