mirror of
https://github.com/RGBCube/serenity
synced 2025-07-17 13:47:38 +00:00

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. :^)
68 lines
1.6 KiB
C++
68 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "WSMenu.h"
|
|
#include <LibCore/CObject.h>
|
|
#include <LibCore/CTimer.h>
|
|
#include <WindowServer/WSWindow.h>
|
|
|
|
class AClientConnection;
|
|
|
|
class WSMenuManager final : public CObject {
|
|
C_OBJECT(WSMenuManager)
|
|
public:
|
|
WSMenuManager();
|
|
virtual ~WSMenuManager() override;
|
|
|
|
void setup();
|
|
void refresh();
|
|
|
|
virtual void event(CEvent&) override;
|
|
|
|
bool is_open(const WSMenu&) const;
|
|
|
|
Vector<WeakPtr<WSMenu>>& open_menu_stack() { return m_open_menu_stack; }
|
|
|
|
Rect menubar_rect() const;
|
|
static int menubar_menu_margin() { return 16; }
|
|
|
|
void set_needs_window_resize();
|
|
|
|
WSMenu* current_menu() { return m_current_menu.ptr(); }
|
|
void set_current_menu(WSMenu*, bool is_submenu = false);
|
|
|
|
void close_bar();
|
|
void close_everyone();
|
|
void close_everyone_not_in_lineage(WSMenu&);
|
|
void close_menu_and_descendants(WSMenu&);
|
|
|
|
void add_applet(WSWindow&);
|
|
void remove_applet(WSWindow&);
|
|
void invalidate_applet(const WSWindow&, const Rect&);
|
|
|
|
private:
|
|
void close_menus(const Vector<WSMenu*>&);
|
|
|
|
WSWindow& window() { return *m_window; }
|
|
const WSWindow& window() const { return *m_window; }
|
|
|
|
void handle_menu_mouse_event(WSMenu&, const WSMouseEvent&);
|
|
|
|
void draw();
|
|
void draw_applet(const WSWindow&);
|
|
void tick_clock();
|
|
|
|
RefPtr<WSWindow> m_window;
|
|
String m_username;
|
|
RefPtr<CTimer> m_timer;
|
|
|
|
WeakPtr<WSMenu> m_current_menu;
|
|
Vector<WeakPtr<WSMenu>> m_open_menu_stack;
|
|
|
|
Vector<WeakPtr<WSWindow>> m_applets;
|
|
|
|
Rect m_username_rect;
|
|
Rect m_time_rect;
|
|
|
|
bool m_needs_window_resize { false };
|
|
bool m_bar_open { false };
|
|
};
|