diff options
author | Andreas Kling <kling@serenityos.org> | 2021-03-25 21:01:19 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-25 22:14:09 +0100 |
commit | e76771bfad3afbe3c32b8aff12304fa6f45a3452 (patch) | |
tree | 44c9a11dfccc0ace18be3c85fae998c764c7ea49 /Userland/Libraries/LibGUI | |
parent | 1daaa4f38d74572133f6bec1c66d2a7e806939a5 (diff) | |
download | serenity-e76771bfad3afbe3c32b8aff12304fa6f45a3452.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/Window.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Window.h | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index b375ac5d80..a7f3c79911 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -35,6 +35,7 @@ #include <LibGUI/Application.h> #include <LibGUI/Desktop.h> #include <LibGUI/Event.h> +#include <LibGUI/MenuBar.h> #include <LibGUI/Painter.h> #include <LibGUI/Widget.h> #include <LibGUI/Window.h> @@ -1052,4 +1053,13 @@ Gfx::Bitmap* Window::back_bitmap() return m_back_store ? &m_back_store->bitmap() : nullptr; } +void Window::set_menubar(RefPtr<MenuBar> menubar) +{ + if (m_menubar == menubar) + return; + m_menubar = move(menubar); + if (m_window_id && m_menubar) + WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowMenubar>(m_window_id, m_menubar->menubar_id()); +} + } diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h index 516a07b100..306788d8e7 100644 --- a/Userland/Libraries/LibGUI/Window.h +++ b/Userland/Libraries/LibGUI/Window.h @@ -211,6 +211,8 @@ public: void did_disable_focused_widget(Badge<Widget>); + void set_menubar(RefPtr<MenuBar>); + protected: Window(Core::Object* parent = nullptr); virtual void wm_event(WMEvent&); @@ -241,6 +243,8 @@ private: OwnPtr<WindowBackingStore> m_front_store; OwnPtr<WindowBackingStore> m_back_store; + RefPtr<MenuBar> m_menubar; + RefPtr<Gfx::Bitmap> m_icon; RefPtr<Gfx::Bitmap> m_custom_cursor; int m_window_id { 0 }; |