From 2f9e8a982c054b60ced5eda5a0e60531813ecf56 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 18 Jun 2021 15:07:07 +0200 Subject: [PATCH] WindowServer: Unify hit testing between fullscreen/regular windows Even if a window is in fullscreen mode, we still want hit testing to walk the window stack. Otherwise child windows of the fullscreen window will not receive mouse events. --- .../Services/WindowServer/WindowManager.cpp | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 481e4279ff..bf4707d02b 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -1054,20 +1054,21 @@ void WindowManager::process_mouse_event(MouseEvent& event, Window*& hovered_wind } }; - if (auto* fullscreen_window = active_fullscreen_window()) { - process_mouse_event_for_window(*fullscreen_window); - } else { - m_window_stack.for_each_visible_window_from_front_to_back([&](Window& window) { - if (!window.hit_test(event.position()).has_value()) - return IterationDecision::Continue; - process_mouse_event_for_window(window); - return IterationDecision::Break; - }); + // Hit test the window stack to see what's under the cursor. + auto result = m_window_stack.hit_test(event.position()); + + if (!result.has_value()) { + // No window is outside the cursor. + if (event.type() == Event::MouseDown) { + // Clicked outside of any window -> no active window. + // FIXME: Is this actually necessary? The desktop window should catch everything anyway. + set_active_window(nullptr); + } + clear_resize_candidate(); + return; } - // Clicked outside of any window - if (!hovered_window && !event_window_with_frame && event.type() == Event::MouseDown) - set_active_window(nullptr); + process_mouse_event_for_window(*result->window); auto reverse_iterator = m_window_stack.windows().rbegin(); for (; reverse_iterator != m_window_stack.windows().rend(); ++reverse_iterator) {