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
Notes: sideshowbarker 2024-07-18 21:05:48 +09:00
21 changed files with 335 additions and 44 deletions

View file

@ -104,7 +104,7 @@ void ClientConnection::notify_about_new_screen_rect(const Gfx::IntRect& rect)
OwnPtr<Messages::WindowServer::CreateMenubarResponse> ClientConnection::handle(const Messages::WindowServer::CreateMenubar&)
{
int menubar_id = m_next_menubar_id++;
auto menubar = make<MenuBar>(*this, menubar_id);
auto menubar = MenuBar::create(*this, menubar_id);
m_menubars.set(menubar_id, move(menubar));
return make<Messages::WindowServer::CreateMenubarResponse>(menubar_id);
}
@ -160,6 +160,30 @@ OwnPtr<Messages::WindowServer::SetApplicationMenubarResponse> ClientConnection::
return make<Messages::WindowServer::SetApplicationMenubarResponse>();
}
OwnPtr<Messages::WindowServer::SetWindowMenubarResponse> ClientConnection::handle(const Messages::WindowServer::SetWindowMenubar& message)
{
RefPtr<Window> window;
{
auto it = m_windows.find(message.window_id());
if (it == m_windows.end()) {
did_misbehave("SetWindowMenubar: Bad window ID");
return {};
}
window = it->value;
}
RefPtr<MenuBar> menubar;
if (message.menubar_id() != -1) {
auto it = m_menubars.find(message.menubar_id());
if (it == m_menubars.end()) {
did_misbehave("SetWindowMenubar: Bad menubar ID");
return {};
}
menubar = *(*it).value;
}
window->set_menubar(menubar);
return make<Messages::WindowServer::SetWindowMenubarResponse>();
}
OwnPtr<Messages::WindowServer::AddMenuToMenubarResponse> ClientConnection::handle(const Messages::WindowServer::AddMenuToMenubar& message)
{
int menubar_id = message.menubar_id();