ladybird/Servers/WindowServer/WSMenuBar.h
Andreas Kling e1940f365b WindowServer+MenuApplets: Move the "Audio" applet to its own program
This patch introduces the second MenuApplet: Audio. To make this work,
menu applet windows now also receive mouse events.

There's still some problem with mute/unmute via clicking not actually
working, but the call goes from the applet program over IPC to the
AudioServer, where something goes wrong with the state change message.
Need to look at that separately.

Anyways, it's pretty cool to have more applets running in their own
separate processes. :^)
2019-12-16 15:33:42 +01:00

35 lines
842 B
C++

#pragma once
#include "WSMenu.h"
#include <AK/Vector.h>
#include <AK/WeakPtr.h>
#include <AK/Weakable.h>
class WSMenuBar : public Weakable<WSMenuBar> {
public:
WSMenuBar(WSClientConnection& client, int menubar_id);
~WSMenuBar();
WSClientConnection& client() { return m_client; }
const WSClientConnection& client() const { return m_client; }
int menubar_id() const { return m_menubar_id; }
void add_menu(WSMenu& menu)
{
menu.set_menubar(this);
m_menus.append(&menu);
}
template<typename Callback>
void for_each_menu(Callback callback)
{
for (auto& menu : m_menus) {
if (callback(*menu) == IterationDecision::Break)
return;
}
}
private:
WSClientConnection& m_client;
int m_menubar_id { 0 };
Vector<WSMenu*> m_menus;
};