浏览代码

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.
Andreas Kling 5 年之前
父节点
当前提交
7aa2acefd0
共有 3 个文件被更改,包括 13 次插入0 次删除
  1. 2 0
      Services/WindowServer/Menu.cpp
  2. 9 0
      Services/WindowServer/WindowManager.cpp
  3. 2 0
      Services/WindowServer/WindowManager.h

+ 2 - 0
Services/WindowServer/Menu.cpp

@@ -551,6 +551,8 @@ void Menu::popup(const Gfx::Point& position, bool is_submenu)
     window.move_to(adjusted_pos);
     window.move_to(adjusted_pos);
     window.set_visible(true);
     window.set_visible(true);
     MenuManager::the().set_current_menu(this, is_submenu);
     MenuManager::the().set_current_menu(this, is_submenu);
+
+    WindowManager::the().did_popup_a_menu({});
 }
 }
 
 
 bool Menu::is_menu_ancestor_of(const Menu& other) const
 bool Menu::is_menu_ancestor_of(const Menu& other) const

+ 9 - 0
Services/WindowServer/WindowManager.cpp

@@ -1314,4 +1314,13 @@ bool WindowManager::update_theme(String theme_path, String theme_name)
     return true;
     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;
+}
+
 }
 }

+ 2 - 0
Services/WindowServer/WindowManager.h

@@ -173,6 +173,8 @@ public:
     void set_hovered_window(Window*);
     void set_hovered_window(Window*);
     void deliver_mouse_event(Window& window, MouseEvent& event);
     void deliver_mouse_event(Window& window, MouseEvent& event);
 
 
+    void did_popup_a_menu(Badge<Menu>);
+
 private:
 private:
     NonnullRefPtr<Cursor> get_cursor(const String& name);
     NonnullRefPtr<Cursor> get_cursor(const String& name);
     NonnullRefPtr<Cursor> get_cursor(const String& name, const Gfx::Point& hotspot);
     NonnullRefPtr<Cursor> get_cursor(const String& name, const Gfx::Point& hotspot);