mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
WindowServer: Fix not all menus closing after system menu toggle
We were failing to check if the current menu being set was already open. This could result in multiple occurrences of the menu in the open menu stack. When we close all menus descending from a menu we only delete the first occurrence of a given menu from the menu stack (a fair assumption to make as a menu should only be open once). Because of this a menu (or multiple instances of it) could remain in the open menu stack when it should actually be closed, leading to goofy behaviour. Fixes #1238
This commit is contained in:
parent
6e2a16c8a8
commit
238b6871e0
Notes:
sideshowbarker
2024-07-19 09:11:51 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/238b6871e03 Pull-request: https://github.com/SerenityOS/serenity/pull/1254
1 changed files with 6 additions and 1 deletions
|
@ -178,6 +178,7 @@ void MenuManager::handle_mouse_event(MouseEvent& mouse_event)
|
|||
ASSERT(topmost_menu);
|
||||
auto* window = topmost_menu->menu_window();
|
||||
ASSERT(window);
|
||||
ASSERT(window->is_visible());
|
||||
|
||||
bool event_is_inside_current_menu = window->rect().contains(mouse_event.position());
|
||||
if (event_is_inside_current_menu) {
|
||||
|
@ -340,6 +341,9 @@ void MenuManager::open_menu(Menu& menu)
|
|||
|
||||
void MenuManager::set_current_menu(Menu* menu, bool is_submenu)
|
||||
{
|
||||
if (menu == m_current_menu)
|
||||
return;
|
||||
|
||||
if (!is_submenu) {
|
||||
if (menu)
|
||||
close_everyone_not_in_lineage(*menu);
|
||||
|
@ -352,8 +356,9 @@ void MenuManager::set_current_menu(Menu* menu, bool is_submenu)
|
|||
return;
|
||||
}
|
||||
|
||||
m_open_menu_stack.append(menu->make_weak_ptr());
|
||||
m_current_menu = menu->make_weak_ptr();
|
||||
if (m_open_menu_stack.find([menu](auto& other) { return menu == other.ptr(); }).is_end())
|
||||
m_open_menu_stack.append(menu->make_weak_ptr());
|
||||
}
|
||||
|
||||
void MenuManager::close_bar()
|
||||
|
|
Loading…
Reference in a new issue