1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:07:36 +00:00

WindowServer+LibGfx: Show menus in windows! :^)

This patch begins the transition away from the global menu towards
per-window menus instead.

The global menu looks neat, but has always felt clunky, and there
are a number of usability problems with it, especially in programs
with multiple windows.

You can now call GUI::Window::set_menubar() to add a menubar to
your window. It will be specific to that one window only.
This commit is contained in:
Andreas Kling 2021-03-25 21:01:19 +01:00
parent 1daaa4f38d
commit e76771bfad
21 changed files with 335 additions and 44 deletions

View file

@ -42,6 +42,7 @@ namespace WindowServer {
class ClientConnection;
class Cursor;
class Menu;
class MenuBar;
class MenuItem;
class MouseEvent;
@ -192,6 +193,7 @@ public:
void invalidate(bool with_frame = true, bool re_render_frame = false);
void invalidate(const Gfx::IntRect&, bool with_frame = false);
void invalidate_menubar();
bool invalidate_no_notify(const Gfx::IntRect& rect, bool with_frame = false);
void refresh_client_size();
@ -326,6 +328,10 @@ public:
Gfx::DisjointRectSet& transparency_rects() { return m_transparency_rects; }
Gfx::DisjointRectSet& transparency_wallpaper_rects() { return m_transparency_wallpaper_rects; }
MenuBar* menubar() { return m_menubar; }
const MenuBar* menubar() const { return m_menubar; }
void set_menubar(MenuBar*);
private:
void handle_mouse_event(const MouseEvent&);
void update_menu_item_text(PopupMenuItem item);
@ -341,6 +347,8 @@ private:
Vector<WeakPtr<Window>> m_child_windows;
Vector<WeakPtr<Window>> m_accessory_windows;
RefPtr<MenuBar> m_menubar;
String m_title;
Gfx::IntRect m_rect;
Gfx::IntRect m_saved_nonfullscreen_rect;