mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibGUI, WindowServer: Greatly simplify menubar logic
Currently, any number of menubars can be plugged in and out of a window. This is unnecessary complexity, since we only need one menubar on a window. This commit removes most of the logic for dynamically attaching and detaching menubars and makes one menubar always available. The menubar is only considered existent if it has at least a single menu in it (in other words, an empty menubar will not be shown). This commit additionally fixes a bug wherein menus added after a menubar has been attached would not have their rects properly setup, and would therefore appear glitched out on the top left corner of the menubar.
This commit is contained in:
parent
95ab61e3db
commit
611370e7dc
19 changed files with 150 additions and 255 deletions
|
@ -13,7 +13,6 @@
|
|||
#include <WindowServer/Compositor.h>
|
||||
#include <WindowServer/Menu.h>
|
||||
#include <WindowServer/MenuItem.h>
|
||||
#include <WindowServer/Menubar.h>
|
||||
#include <WindowServer/Screen.h>
|
||||
#include <WindowServer/Window.h>
|
||||
#include <WindowServer/WindowClientEndpoint.h>
|
||||
|
@ -91,22 +90,6 @@ void ClientConnection::notify_about_new_screen_rects()
|
|||
async_screen_rects_changed(Screen::rects(), Screen::main().index(), wm.window_stack_rows(), wm.window_stack_columns());
|
||||
}
|
||||
|
||||
void ClientConnection::create_menubar(i32 menubar_id)
|
||||
{
|
||||
auto menubar = Menubar::create(*this, menubar_id);
|
||||
m_menubars.set(menubar_id, move(menubar));
|
||||
}
|
||||
|
||||
void ClientConnection::destroy_menubar(i32 menubar_id)
|
||||
{
|
||||
auto it = m_menubars.find(menubar_id);
|
||||
if (it == m_menubars.end()) {
|
||||
did_misbehave("DestroyMenubar: Bad menubar ID");
|
||||
return;
|
||||
}
|
||||
m_menubars.remove(it);
|
||||
}
|
||||
|
||||
void ClientConnection::create_menu(i32 menu_id, String const& menu_title)
|
||||
{
|
||||
auto menu = Menu::construct(this, menu_id, menu_title);
|
||||
|
@ -126,44 +109,21 @@ void ClientConnection::destroy_menu(i32 menu_id)
|
|||
remove_child(menu);
|
||||
}
|
||||
|
||||
void ClientConnection::set_window_menubar(i32 window_id, i32 menubar_id)
|
||||
void ClientConnection::add_menu(i32 window_id, i32 menu_id)
|
||||
{
|
||||
RefPtr<Window> window;
|
||||
{
|
||||
auto it = m_windows.find(window_id);
|
||||
if (it == m_windows.end()) {
|
||||
did_misbehave("SetWindowMenubar: Bad window ID");
|
||||
return;
|
||||
}
|
||||
window = it->value;
|
||||
}
|
||||
RefPtr<Menubar> menubar;
|
||||
if (menubar_id != -1) {
|
||||
auto it = m_menubars.find(menubar_id);
|
||||
if (it == m_menubars.end()) {
|
||||
did_misbehave("SetWindowMenubar: Bad menubar ID");
|
||||
return;
|
||||
}
|
||||
menubar = *(*it).value;
|
||||
}
|
||||
window->set_menubar(menubar);
|
||||
}
|
||||
|
||||
void ClientConnection::add_menu_to_menubar(i32 menubar_id, i32 menu_id)
|
||||
{
|
||||
auto it = m_menubars.find(menubar_id);
|
||||
auto it = m_windows.find(window_id);
|
||||
auto jt = m_menus.find(menu_id);
|
||||
if (it == m_menubars.end()) {
|
||||
did_misbehave("AddMenuToMenubar: Bad menubar ID");
|
||||
if (it == m_windows.end()) {
|
||||
did_misbehave("AddMenu: Bad window ID");
|
||||
return;
|
||||
}
|
||||
if (jt == m_menus.end()) {
|
||||
did_misbehave("AddMenuToMenubar: Bad menu ID");
|
||||
did_misbehave("AddMenu: Bad menu ID");
|
||||
return;
|
||||
}
|
||||
auto& menubar = *(*it).value;
|
||||
auto& window = *(*it).value;
|
||||
auto& menu = *(*jt).value;
|
||||
menubar.add_menu(menu);
|
||||
window.add_menu(menu);
|
||||
}
|
||||
|
||||
void ClientConnection::add_menu_item(i32 menu_id, i32 identifier, i32 submenu_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue