From 1537172a6b378c1b9e01495214b557abffd16bc9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 18 Jun 2021 17:25:15 +0200 Subject: [PATCH] WindowServer: Simplify handling of the window resize candidate Always clear the current resize candidate when starting new mouse event processing (instead of trying to be smart about it.) --- Userland/Services/WindowServer/WindowFrame.cpp | 2 -- Userland/Services/WindowServer/WindowManager.cpp | 9 ++++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp index 04370ff94e..fe799039d5 100644 --- a/Userland/Services/WindowServer/WindowFrame.cpp +++ b/Userland/Services/WindowServer/WindowFrame.cpp @@ -682,7 +682,6 @@ bool WindowFrame::handle_titlebar_icon_mouse_event(MouseEvent const& event) void WindowFrame::handle_titlebar_mouse_event(MouseEvent const& event) { auto& wm = WindowManager::the(); - wm.clear_resize_candidate(); if (titlebar_icon_rect().contains(event.position())) { if (handle_titlebar_icon_mouse_event(event)) @@ -733,7 +732,6 @@ void WindowFrame::handle_mouse_event(MouseEvent const& event) } if (menubar_rect().contains(event.position())) { - wm.clear_resize_candidate(); handle_menubar_mouse_event(event); return; } diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 387db5ac76..08d980b877 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -955,9 +955,6 @@ void WindowManager::process_mouse_event_for_window(HitTestResult& result, MouseE return; } - if (&window != m_resize_candidate.ptr()) - clear_resize_candidate(); - // First check if we should initiate a move or resize (Super+LMB or Super+RMB). // In those cases, the event is swallowed by the window manager. if (window.is_movable()) { @@ -994,6 +991,10 @@ void WindowManager::process_mouse_event_for_window(HitTestResult& result, MouseE void WindowManager::process_mouse_event(MouseEvent& event) { + // 0. Forget the resize candidate (window that we could initiate a resize of from the current cursor position.) + // A new resize candidate may be determined if we hit an appropriate part of a window. + clear_resize_candidate(); + // 1. Process ongoing drag events. This is done first to avoid clashing with global cursor tracking. if (process_ongoing_drag(event)) return; @@ -1038,7 +1039,6 @@ void WindowManager::process_mouse_event(MouseEvent& event) if (MenuManager::the().has_open_menu() || hitting_menu_in_window_with_active_menu) { - clear_resize_candidate(); if (!hitting_menu_in_window_with_active_menu) { MenuManager::the().dispatch_event(event); @@ -1056,7 +1056,6 @@ void WindowManager::process_mouse_event(MouseEvent& event) // FIXME: Is this actually necessary? The desktop window should catch everything anyway. set_active_window(nullptr); } - clear_resize_candidate(); return; }