diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index e1dcfe7e973..481e4279ffe 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -940,6 +940,20 @@ bool WindowManager::process_ongoing_active_input_mouse_event(MouseEvent& event, return true; } +bool WindowManager::process_mouse_event_for_titlebar_buttons(MouseEvent& event) +{ + if (m_cursor_tracking_button) { + m_cursor_tracking_button->on_mouse_event(event.translated(-m_cursor_tracking_button->screen_rect().location())); + return true; + } + + // This is quite hackish, but it's how the Button hover effect is implemented. + if (m_hovered_button && event.type() == Event::MouseMove) + m_hovered_button->on_mouse_event(event.translated(-m_hovered_button->screen_rect().location())); + + return false; +} + void WindowManager::process_mouse_event(MouseEvent& event, Window*& hovered_window) { hovered_window = nullptr; @@ -957,12 +971,8 @@ void WindowManager::process_mouse_event(MouseEvent& event, Window*& hovered_wind if (process_ongoing_window_resize(event, hovered_window)) return; - if (m_cursor_tracking_button) - return m_cursor_tracking_button->on_mouse_event(event.translated(-m_cursor_tracking_button->screen_rect().location())); - - // This is quite hackish, but it's how the Button hover effect is implemented. - if (m_hovered_button && event.type() == Event::MouseMove) - m_hovered_button->on_mouse_event(event.translated(-m_hovered_button->screen_rect().location())); + if (process_mouse_event_for_titlebar_buttons(event)) + return; bool hitting_menu_in_window_with_active_menu = [&] { if (!m_window_with_active_menu) diff --git a/Userland/Services/WindowServer/WindowManager.h b/Userland/Services/WindowServer/WindowManager.h index 33fa087fa99..ecc65180fc9 100644 --- a/Userland/Services/WindowServer/WindowManager.h +++ b/Userland/Services/WindowServer/WindowManager.h @@ -240,6 +240,7 @@ private: bool process_ongoing_window_move(MouseEvent&, Window*& hovered_window); bool process_ongoing_drag(MouseEvent&, Window*& hovered_window); bool process_ongoing_active_input_mouse_event(MouseEvent&, Window*& hovered_window); + bool process_mouse_event_for_titlebar_buttons(MouseEvent&); template void for_each_window_manager(Callback);