summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-09 16:40:13 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-09 16:40:13 +0200
commit7aa2acefd020ba7776bbe9de773a0b36024f4f52 (patch)
treeaebd6b0d8fc747cd4810769207830041baf2428e
parent4330046aff8097919e4ea97dbb848edcf0f73a42 (diff)
downloadserenity-7aa2acefd020ba7776bbe9de773a0b36024f4f52.zip
WindowServer: Cancel any ongoing input tracking when a menu pops up
When the user opens a context menu by right-clicking on something, we now immediately stop sending mouse events to whoever was doing active input window tracking before. There are probably more situations where we should do this, and maybe there's also a more generic way to express it, but this works for now.
-rw-r--r--Services/WindowServer/Menu.cpp2
-rw-r--r--Services/WindowServer/WindowManager.cpp9
-rw-r--r--Services/WindowServer/WindowManager.h2
3 files changed, 13 insertions, 0 deletions
diff --git a/Services/WindowServer/Menu.cpp b/Services/WindowServer/Menu.cpp
index 07c460b9b2..4b9dc71a19 100644
--- a/Services/WindowServer/Menu.cpp
+++ b/Services/WindowServer/Menu.cpp
@@ -551,6 +551,8 @@ void Menu::popup(const Gfx::Point& position, bool is_submenu)
window.move_to(adjusted_pos);
window.set_visible(true);
MenuManager::the().set_current_menu(this, is_submenu);
+
+ WindowManager::the().did_popup_a_menu({});
}
bool Menu::is_menu_ancestor_of(const Menu& other) const
diff --git a/Services/WindowServer/WindowManager.cpp b/Services/WindowServer/WindowManager.cpp
index 2b168107d1..f45cf2d2f6 100644
--- a/Services/WindowServer/WindowManager.cpp
+++ b/Services/WindowServer/WindowManager.cpp
@@ -1314,4 +1314,13 @@ bool WindowManager::update_theme(String theme_path, String theme_name)
return true;
}
+void WindowManager::did_popup_a_menu(Badge<Menu>)
+{
+ // Clear any ongoing input gesture
+ if (!m_active_input_window)
+ return;
+ m_active_input_window->set_automatic_cursor_tracking_enabled(false);
+ m_active_input_window = nullptr;
+}
+
}
diff --git a/Services/WindowServer/WindowManager.h b/Services/WindowServer/WindowManager.h
index 0c7ec8429f..7a0b03a3f3 100644
--- a/Services/WindowServer/WindowManager.h
+++ b/Services/WindowServer/WindowManager.h
@@ -173,6 +173,8 @@ public:
void set_hovered_window(Window*);
void deliver_mouse_event(Window& window, MouseEvent& event);
+ void did_popup_a_menu(Badge<Menu>);
+
private:
NonnullRefPtr<Cursor> get_cursor(const String& name);
NonnullRefPtr<Cursor> get_cursor(const String& name, const Gfx::Point& hotspot);