Sfoglia il codice sorgente

WindowServer: Fix 'sticky' mouse after resize

This fixes #9933 and some dead code I accidentally left over.
Thanks, @Maato!
Ben Wiederhake 3 anni fa
parent
commit
7684e4f726

+ 0 - 5
Userland/Services/WindowServer/Window.cpp

@@ -597,11 +597,6 @@ void Window::handle_keydown_event(const KeyEvent& event)
     m_client->async_key_down(m_window_id, (u32)event.code_point(), (u32)event.key(), event.modifiers(), (u32)event.scancode());
     m_client->async_key_down(m_window_id, (u32)event.code_point(), (u32)event.key(), event.modifiers(), (u32)event.scancode());
 }
 }
 
 
-void Window::set_global_cursor_tracking_enabled(bool enabled)
-{
-    m_global_cursor_tracking_enabled = enabled;
-}
-
 void Window::set_visible(bool b)
 void Window::set_visible(bool b)
 {
 {
     if (m_visible == b)
     if (m_visible == b)

+ 1 - 2
Userland/Services/WindowServer/Window.h

@@ -242,7 +242,7 @@ public:
 
 
     void set_global_cursor_tracking_enabled(bool);
     void set_global_cursor_tracking_enabled(bool);
     void set_automatic_cursor_tracking_enabled(bool enabled) { m_automatic_cursor_tracking_enabled = enabled; }
     void set_automatic_cursor_tracking_enabled(bool enabled) { m_automatic_cursor_tracking_enabled = enabled; }
-    bool global_cursor_tracking() const { return m_global_cursor_tracking_enabled || m_automatic_cursor_tracking_enabled; }
+    bool is_automatic_cursor_tracking() const { return m_automatic_cursor_tracking_enabled; }
 
 
     bool has_alpha_channel() const { return m_has_alpha_channel; }
     bool has_alpha_channel() const { return m_has_alpha_channel; }
     void set_has_alpha_channel(bool value);
     void set_has_alpha_channel(bool value);
@@ -409,7 +409,6 @@ private:
     Gfx::DisjointRectSet m_transparency_wallpaper_rects;
     Gfx::DisjointRectSet m_transparency_wallpaper_rects;
     HashMap<Window*, Gfx::DisjointRectSet> m_affected_transparency_rects;
     HashMap<Window*, Gfx::DisjointRectSet> m_affected_transparency_rects;
     WindowType m_type { WindowType::Normal };
     WindowType m_type { WindowType::Normal };
-    bool m_global_cursor_tracking_enabled { false };
     bool m_automatic_cursor_tracking_enabled { false };
     bool m_automatic_cursor_tracking_enabled { false };
     bool m_visible { true };
     bool m_visible { true };
     bool m_has_alpha_channel { false };
     bool m_has_alpha_channel { false };

+ 9 - 1
Userland/Services/WindowServer/WindowManager.cpp

@@ -1182,7 +1182,7 @@ void WindowManager::process_mouse_event_for_window(HitTestResult& result, MouseE
         return;
         return;
     }
     }
 
 
-    if (!window.global_cursor_tracking()) {
+    if (!window.is_automatic_cursor_tracking()) {
         deliver_mouse_event(window, event, true);
         deliver_mouse_event(window, event, true);
     }
     }
 
 
@@ -1206,6 +1206,14 @@ void WindowManager::process_mouse_event(MouseEvent& event)
             conn.async_track_mouse_move(event.position());
             conn.async_track_mouse_move(event.position());
         }
         }
     });
     });
+    // The active input tracking window is excluded here because we're sending the event to it
+    // in the next step.
+    auto& window_stack = current_window_stack();
+    for_each_visible_window_from_front_to_back([&](Window& window) {
+        if (window.is_automatic_cursor_tracking() && &window != window_stack.active_input_tracking_window())
+            deliver_mouse_event(window, event, false);
+        return IterationDecision::Continue;
+    });
 
 
     // 3. If there's an active input tracking window, all mouse events go there.
     // 3. If there's an active input tracking window, all mouse events go there.
     //    Tracking ends after all mouse buttons have been released.
     //    Tracking ends after all mouse buttons have been released.