From fcc8e3484f9c2312d80063fe8d6251830609385a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Mar 2021 21:19:05 +0100 Subject: [PATCH] WindowServer: Remove the global app menu The SetApplicationMenu IPC message is still there, since we also need to clean up all of the client code before we can remove that. --- .../Services/WindowServer/ClientConnection.cpp | 13 +------------ .../Services/WindowServer/ClientConnection.h | 3 --- Userland/Services/WindowServer/MenuManager.cpp | 18 ++---------------- Userland/Services/WindowServer/MenuManager.h | 5 ----- .../Services/WindowServer/WindowManager.cpp | 11 ----------- Userland/Services/WindowServer/WindowManager.h | 1 - 6 files changed, 3 insertions(+), 48 deletions(-) diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index db2f911043..f11c0945d7 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -117,8 +117,6 @@ OwnPtr ClientConnection::handle( did_misbehave("DestroyMenubar: Bad menubar ID"); return {}; } - auto& menubar = *(*it).value; - MenuManager::the().close_menubar(menubar); m_menubars.remove(it); return make(); } @@ -146,17 +144,8 @@ OwnPtr ClientConnection::handle(con return make(); } -OwnPtr ClientConnection::handle(const Messages::WindowServer::SetApplicationMenubar& message) +OwnPtr ClientConnection::handle(const Messages::WindowServer::SetApplicationMenubar&) { - int menubar_id = message.menubar_id(); - auto it = m_menubars.find(menubar_id); - if (it == m_menubars.end()) { - did_misbehave("SetApplicationMenubar: Bad menubar ID"); - return {}; - } - auto& menubar = *(*it).value; - m_app_menubar = menubar.make_weak_ptr(); - WindowManager::the().notify_client_changed_app_menubar(*this); return make(); } diff --git a/Userland/Services/WindowServer/ClientConnection.h b/Userland/Services/WindowServer/ClientConnection.h index 497b2b4505..b8b3e9c282 100644 --- a/Userland/Services/WindowServer/ClientConnection.h +++ b/Userland/Services/WindowServer/ClientConnection.h @@ -58,8 +58,6 @@ public: static ClientConnection* from_client_id(int client_id); static void for_each_client(Function); - MenuBar* app_menubar() { return m_app_menubar.ptr(); } - void notify_about_new_screen_rect(const Gfx::IntRect&); void post_paint_message(Window&, bool ignore_occlusion = false); @@ -169,7 +167,6 @@ private: HashMap> m_windows; HashMap> m_menubars; HashMap> m_menus; - WeakPtr m_app_menubar; RefPtr m_ping_timer; diff --git a/Userland/Services/WindowServer/MenuManager.cpp b/Userland/Services/WindowServer/MenuManager.cpp index 8fdc5cc6b8..98e692f105 100644 --- a/Userland/Services/WindowServer/MenuManager.cpp +++ b/Userland/Services/WindowServer/MenuManager.cpp @@ -54,7 +54,6 @@ MenuManager::MenuManager() s_the = this; m_needs_window_resize = true; - // NOTE: This ensures that the system menu has the correct dimensions. set_current_menubar(nullptr); m_window = Window::construct(*this, WindowType::Menubar); @@ -498,15 +497,8 @@ Gfx::IntRect MenuManager::menubar_rect() const return { 0, 0, Screen::the().rect().width(), 19 }; } -void MenuManager::set_current_menubar(MenuBar* menubar) +void MenuManager::set_current_menubar(MenuBar*) { - if (menubar) - m_current_menubar = *menubar; - else - m_current_menubar = nullptr; - - dbgln_if(MENUS_DEBUG, "[WM] Current menubar is now {}", menubar); - Gfx::IntPoint next_menu_location { MenuManager::menubar_menu_margin() / 2, 0 }; for_each_active_menubar_menu([&](Menu& menu) { int text_width = menu.title_font().width(menu.name()); @@ -521,16 +513,10 @@ void MenuManager::set_current_menubar(MenuBar* menubar) refresh(); } -void MenuManager::close_menubar(MenuBar& menubar) -{ - if (current_menubar() == &menubar) - set_current_menubar(nullptr); -} - void MenuManager::set_system_menu(Menu& menu) { m_system_menu = menu; - set_current_menubar(m_current_menubar); + set_current_menubar(nullptr); } Menu* MenuManager::previous_menu(Menu* current) diff --git a/Userland/Services/WindowServer/MenuManager.h b/Userland/Services/WindowServer/MenuManager.h index 1ca18dd100..d94b585c03 100644 --- a/Userland/Services/WindowServer/MenuManager.h +++ b/Userland/Services/WindowServer/MenuManager.h @@ -59,9 +59,7 @@ public: void clear_current_menu(); void open_menu(Menu&, bool from_menu_bar, bool as_current_menu = true); - MenuBar* current_menubar() { return m_current_menubar.ptr(); } void set_current_menubar(MenuBar*); - void close_menubar(MenuBar&); void close_bar(); void close_everyone(); @@ -84,8 +82,6 @@ public: if (callback(*system_menu()) == IterationDecision::Break) return; } - if (m_current_menubar) - m_current_menubar->for_each_menu(callback); } Menu* previous_menu(Menu* current); @@ -123,7 +119,6 @@ private: int m_theme_index { 0 }; - WeakPtr m_current_menubar; WeakPtr m_hovered_menu; }; diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 14f108e52e..b9ed2fd048 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -1370,11 +1370,6 @@ void WindowManager::set_active_window(Window* window, bool make_input) m_active_window = *window; Core::EventLoop::current().post_event(*m_active_window, make(Event::WindowActivated)); m_active_window->invalidate(true, true); - if (auto* client = window->client()) { - MenuManager::the().set_current_menubar(client->app_menubar()); - } else { - MenuManager::the().set_current_menubar(nullptr); - } tell_wm_listeners_window_state_changed(*m_active_window); } else { MenuManager::the().set_current_menubar(nullptr); @@ -1406,12 +1401,6 @@ const ClientConnection* WindowManager::active_client() const return nullptr; } -void WindowManager::notify_client_changed_app_menubar(ClientConnection& client) -{ - if (active_client() == &client) - MenuManager::the().set_current_menubar(client.app_menubar()); -} - const Cursor& WindowManager::active_cursor() const { if (m_dnd_client) diff --git a/Userland/Services/WindowServer/WindowManager.h b/Userland/Services/WindowServer/WindowManager.h index 96e5b63a4f..f71f055cf2 100644 --- a/Userland/Services/WindowServer/WindowManager.h +++ b/Userland/Services/WindowServer/WindowManager.h @@ -94,7 +94,6 @@ public: void notify_opacity_changed(Window&); void notify_occlusion_state_changed(Window&); void notify_progress_changed(Window&); - void notify_client_changed_app_menubar(ClientConnection&); Gfx::IntRect maximized_window_rect(const Window&) const;