mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 21:10:30 +00:00
WindowServer: Stop exposing open_menu_stack in MenuManager
The open menu stack is an internal data structure that outside classes shouldn't really need to know about. Add MenuManager::has_open_menu() so that the WindowManager can still know whether a menu is open or not.
This commit is contained in:
parent
238b6871e0
commit
088d7be19c
Notes:
sideshowbarker
2024-07-19 09:11:48 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/088d7be19c7 Pull-request: https://github.com/SerenityOS/serenity/pull/1254
3 changed files with 7 additions and 8 deletions
|
@ -173,8 +173,8 @@ void MenuManager::handle_mouse_event(MouseEvent& mouse_event)
|
|||
if (handled_menubar_event)
|
||||
return;
|
||||
|
||||
if (!open_menu_stack().is_empty()) {
|
||||
auto* topmost_menu = open_menu_stack().last().ptr();
|
||||
if (has_open_menu()) {
|
||||
auto* topmost_menu = m_open_menu_stack.last().ptr();
|
||||
ASSERT(topmost_menu);
|
||||
auto* window = topmost_menu->menu_window();
|
||||
ASSERT(window);
|
||||
|
@ -207,7 +207,7 @@ void MenuManager::handle_mouse_event(MouseEvent& mouse_event)
|
|||
}
|
||||
|
||||
if (mouse_event.type() == Event::MouseMove) {
|
||||
for (auto& menu : open_menu_stack()) {
|
||||
for (auto& menu : m_open_menu_stack) {
|
||||
if (!menu)
|
||||
continue;
|
||||
if (!menu->menu_window()->rect().contains(mouse_event.position()))
|
||||
|
@ -227,7 +227,7 @@ void MenuManager::handle_mouse_event(MouseEvent& mouse_event)
|
|||
void MenuManager::handle_menu_mouse_event(Menu& menu, const MouseEvent& event)
|
||||
{
|
||||
bool is_hover_with_any_menu_open = event.type() == MouseEvent::MouseMove
|
||||
&& !m_open_menu_stack.is_empty()
|
||||
&& has_open_menu()
|
||||
&& (m_open_menu_stack.first()->menubar() || m_open_menu_stack.first() == m_system_menu.ptr());
|
||||
bool is_mousedown_with_left_button = event.type() == MouseEvent::MouseDown && event.button() == MouseButton::Left;
|
||||
bool should_open_menu = &menu != m_current_menu && (is_hover_with_any_menu_open || is_mousedown_with_left_button);
|
||||
|
@ -251,7 +251,7 @@ void MenuManager::set_needs_window_resize()
|
|||
|
||||
void MenuManager::close_all_menus_from_client(Badge<ClientConnection>, ClientConnection& client)
|
||||
{
|
||||
if (m_open_menu_stack.is_empty())
|
||||
if (!has_open_menu())
|
||||
return;
|
||||
if (m_open_menu_stack.first()->client() != &client)
|
||||
return;
|
||||
|
|
|
@ -45,8 +45,7 @@ public:
|
|||
void refresh();
|
||||
|
||||
bool is_open(const Menu&) const;
|
||||
|
||||
Vector<WeakPtr<Menu>>& open_menu_stack() { return m_open_menu_stack; }
|
||||
bool has_open_menu() const { return !m_open_menu_stack.is_empty(); }
|
||||
|
||||
Gfx::Rect menubar_rect() const;
|
||||
static int menubar_menu_margin() { return 16; }
|
||||
|
|
|
@ -748,7 +748,7 @@ void WindowManager::process_mouse_event(MouseEvent& event, Window*& hovered_wind
|
|||
}
|
||||
|
||||
// FIXME: Now that the menubar has a dedicated window, is this special-casing really necessary?
|
||||
if (!MenuManager::the().open_menu_stack().is_empty() || (!active_window_is_modal() && menubar_rect().contains(event.position()))) {
|
||||
if (MenuManager::the().has_open_menu() || (!active_window_is_modal() && menubar_rect().contains(event.position()))) {
|
||||
MenuManager::the().dispatch_event(event);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue