1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 09:57:34 +00:00

WindowServer: Remove some leftover unused menubar things

This commit is contained in:
Andreas Kling 2021-03-26 08:54:33 +01:00
parent e94e94becc
commit 6ae174f80a
4 changed files with 9 additions and 24 deletions

View file

@ -322,7 +322,7 @@ void Menu::descend_into_submenu_at_hovered_item()
VERIFY(hovered_item()); VERIFY(hovered_item());
auto submenu = hovered_item()->submenu(); auto submenu = hovered_item()->submenu();
VERIFY(submenu); VERIFY(submenu);
MenuManager::the().open_menu(*submenu, false, false); MenuManager::the().open_menu(*submenu, false);
submenu->set_hovered_item(0); submenu->set_hovered_item(0);
VERIFY(submenu->hovered_item()->type() != MenuItem::Separator); VERIFY(submenu->hovered_item()->type() != MenuItem::Separator);
} }
@ -473,7 +473,7 @@ void Menu::did_activate(MenuItem& item)
if (on_item_activation) if (on_item_activation)
on_item_activation(item); on_item_activation(item);
MenuManager::the().close_bar(); MenuManager::the().close_everyone();
if (m_client) if (m_client)
m_client->post_message(Messages::WindowClient::MenuItemActivated(m_menu_id, item.identifier())); m_client->post_message(Messages::WindowClient::MenuItemActivated(m_menu_id, item.identifier()));
@ -553,7 +553,7 @@ void Menu::do_popup(const Gfx::IntPoint& position, bool make_input)
window.move_to(adjusted_pos); window.move_to(adjusted_pos);
window.set_visible(true); window.set_visible(true);
MenuManager::the().open_menu(*this, false, make_input); MenuManager::the().open_menu(*this, make_input);
WindowManager::the().did_popup_a_menu({}); WindowManager::the().did_popup_a_menu({});
} }

View file

@ -158,7 +158,7 @@ void MenuManager::event(Core::Event& event)
auto* target_menu = previous_menu(m_current_menu); auto* target_menu = previous_menu(m_current_menu);
if (target_menu) { if (target_menu) {
target_menu->ensure_menu_window().move_to(target_menu->rect_in_window_menubar().bottom_left().translated(wm.window_with_active_menu()->frame().rect().location()).translated(wm.window_with_active_menu()->frame().menubar_rect().location())); target_menu->ensure_menu_window().move_to(target_menu->rect_in_window_menubar().bottom_left().translated(wm.window_with_active_menu()->frame().rect().location()).translated(wm.window_with_active_menu()->frame().menubar_rect().location()));
open_menu(*target_menu, false); open_menu(*target_menu);
} }
} }
} }
@ -174,7 +174,7 @@ void MenuManager::event(Core::Event& event)
auto* target_menu = next_menu(m_current_menu); auto* target_menu = next_menu(m_current_menu);
if (target_menu) { if (target_menu) {
target_menu->ensure_menu_window().move_to(target_menu->rect_in_window_menubar().bottom_left().translated(wm.window_with_active_menu()->frame().rect().location()).translated(wm.window_with_active_menu()->frame().menubar_rect().location())); target_menu->ensure_menu_window().move_to(target_menu->rect_in_window_menubar().bottom_left().translated(wm.window_with_active_menu()->frame().rect().location()).translated(wm.window_with_active_menu()->frame().menubar_rect().location()));
open_menu(*target_menu, false); open_menu(*target_menu);
close_everyone_not_in_lineage(*target_menu); close_everyone_not_in_lineage(*target_menu);
} }
} }
@ -238,7 +238,7 @@ void MenuManager::handle_mouse_event(MouseEvent& mouse_event)
continue; continue;
return; return;
} }
close_bar(); MenuManager::the().close_everyone();
topmost_menu->set_window_menu_open(false); topmost_menu->set_window_menu_open(false);
} }
} }
@ -354,11 +354,8 @@ void MenuManager::set_hovered_menu(Menu* menu)
} }
} }
void MenuManager::open_menu(Menu& menu, bool from_menu_bar, bool as_current_menu) void MenuManager::open_menu(Menu& menu, bool as_current_menu)
{ {
if (from_menu_bar)
m_current_menu_bar_menu = &menu;
if (is_open(menu)) { if (is_open(menu)) {
if (as_current_menu || current_menu() != &menu) { if (as_current_menu || current_menu() != &menu) {
// This menu is already open. If requested, or if the current // This menu is already open. If requested, or if the current
@ -391,7 +388,6 @@ void MenuManager::clear_current_menu()
{ {
Menu* previous_current_menu = m_current_menu; Menu* previous_current_menu = m_current_menu;
m_current_menu = nullptr; m_current_menu = nullptr;
m_current_menu_bar_menu = nullptr;
if (previous_current_menu) { if (previous_current_menu) {
// When closing the last menu, restore the previous active input window // When closing the last menu, restore the previous active input window
auto& wm = WindowManager::the(); auto& wm = WindowManager::the();
@ -432,12 +428,6 @@ void MenuManager::set_current_menu(Menu* menu)
wm.set_active_input_window(m_current_menu->menu_window()); wm.set_active_input_window(m_current_menu->menu_window());
} }
void MenuManager::close_bar()
{
close_everyone();
m_bar_open = false;
}
Gfx::IntRect MenuManager::menubar_rect() const Gfx::IntRect MenuManager::menubar_rect() const
{ {
return { 0, 0, Screen::the().rect().width(), 19 }; return { 0, 0, Screen::the().rect().width(), 19 };

View file

@ -57,9 +57,8 @@ public:
Menu* current_menu() { return m_current_menu.ptr(); } Menu* current_menu() { return m_current_menu.ptr(); }
void set_current_menu(Menu*); void set_current_menu(Menu*);
void clear_current_menu(); void clear_current_menu();
void open_menu(Menu&, bool from_menu_bar, bool as_current_menu = true); void open_menu(Menu&, bool as_current_menu = true);
void close_bar();
void close_everyone(); void close_everyone();
void close_everyone_not_in_lineage(Menu&); void close_everyone_not_in_lineage(Menu&);
void close_menu_and_descendants(Menu&); void close_menu_and_descendants(Menu&);
@ -85,23 +84,19 @@ private:
virtual void event(Core::Event&) override; virtual void event(Core::Event&) override;
void handle_mouse_event(MouseEvent&); void handle_mouse_event(MouseEvent&);
void handle_menu_mouse_event(Menu&, const MouseEvent&);
void draw(); void draw();
RefPtr<Window> m_window; RefPtr<Window> m_window;
WeakPtr<Menu> m_current_menu; WeakPtr<Menu> m_current_menu;
WeakPtr<Menu> m_current_menu_bar_menu;
WeakPtr<Window> m_previous_input_window; WeakPtr<Window> m_previous_input_window;
Vector<WeakPtr<Menu>> m_open_menu_stack; Vector<WeakPtr<Menu>> m_open_menu_stack;
RefPtr<Core::Timer> m_search_timer; RefPtr<Core::Timer> m_search_timer;
StringBuilder m_current_search; StringBuilder m_current_search;
WeakPtr<Menu> m_system_menu;
bool m_needs_window_resize { false }; bool m_needs_window_resize { false };
bool m_bar_open { false };
int m_theme_index { 0 }; int m_theme_index { 0 };

View file

@ -759,7 +759,7 @@ void WindowFrame::handle_menu_mouse_event(Menu& menu, const MouseEvent& event)
if (should_open_menu) { if (should_open_menu) {
MenuManager::the().close_everyone(); MenuManager::the().close_everyone();
menu.ensure_menu_window().move_to(menu.rect_in_window_menubar().bottom_left().translated(rect().location()).translated(menubar_rect.location())); menu.ensure_menu_window().move_to(menu.rect_in_window_menubar().bottom_left().translated(rect().location()).translated(menubar_rect.location()));
MenuManager::the().open_menu(menu, false); MenuManager::the().open_menu(menu);
WindowManager::the().set_window_with_active_menu(&m_window); WindowManager::the().set_window_with_active_menu(&m_window);
invalidate(menubar_rect); invalidate(menubar_rect);
return; return;