diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-09-07 21:04:35 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-08 10:53:49 +0200 |
commit | 45126655cdda1c04857b238c65211b188a5decb1 (patch) | |
tree | a51c1756f872476fa57a0966d8b40e0f1f3f9ec7 /Userland/Services | |
parent | bde3c7301e89bade65231a2f3d2a96eaa1da1e91 (diff) | |
download | serenity-45126655cdda1c04857b238c65211b188a5decb1.zip |
LibGUI+WindowServer: Introduce new mouse tracking mechanism
Diffstat (limited to 'Userland/Services')
5 files changed, 17 insertions, 3 deletions
diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index 8823fba3c7..b6466ccaeb 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -663,6 +663,11 @@ void ClientConnection::set_global_cursor_tracking(i32 window_id, bool enabled) it->value->set_global_cursor_tracking_enabled(enabled); } +void ClientConnection::set_global_mouse_tracking(bool enabled) +{ + m_does_global_mouse_tracking = enabled; +} + void ClientConnection::set_window_cursor(i32 window_id, i32 cursor_type) { auto it = m_windows.find(window_id); diff --git a/Userland/Services/WindowServer/ClientConnection.h b/Userland/Services/WindowServer/ClientConnection.h index eddfc8bb02..56aca66c31 100644 --- a/Userland/Services/WindowServer/ClientConnection.h +++ b/Userland/Services/WindowServer/ClientConnection.h @@ -38,6 +38,7 @@ public: ~ClientConnection() override; bool is_unresponsive() const { return m_unresponsive; } + bool does_global_mouse_tracking() const { return m_does_global_mouse_tracking; } static ClientConnection* from_client_id(int client_id); static void for_each_client(Function<void(ClientConnection&)>); @@ -113,6 +114,7 @@ private: virtual void invalidate_rect(i32, Vector<Gfx::IntRect> const&, bool) override; virtual void did_finish_painting(i32, Vector<Gfx::IntRect> const&) override; virtual void set_global_cursor_tracking(i32, bool) override; + virtual void set_global_mouse_tracking(bool) override; virtual void set_window_opacity(i32, float) override; virtual void set_window_backing_store(i32, i32, i32, IPC::File const&, i32, bool, Gfx::IntSize const&, bool) override; virtual void set_window_has_alpha_channel(i32, bool) override; @@ -179,6 +181,7 @@ private: bool m_has_display_link { false }; bool m_show_screen_number { false }; bool m_unresponsive { false }; + bool m_does_global_mouse_tracking { false }; // Need this to get private client connection stuff friend WMClientConnection; diff --git a/Userland/Services/WindowServer/WindowClient.ipc b/Userland/Services/WindowServer/WindowClient.ipc index 2b8b3c839f..e9a6ac9bf3 100644 --- a/Userland/Services/WindowServer/WindowClient.ipc +++ b/Userland/Services/WindowServer/WindowClient.ipc @@ -44,5 +44,7 @@ endpoint WindowClient display_link_notification() =| + track_mouse_move(Gfx::IntPoint mouse_position) =| + ping() =| } diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index c816377c71..a2388d51ef 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -1200,15 +1200,18 @@ void WindowManager::process_mouse_event(MouseEvent& event) if (process_ongoing_drag(event)) return; - // 2. Send the mouse event to all windows with global cursor tracking enabled. - // The active input tracking window is excluded here because we're sending the event to it - // in the next step. + // 2. Send the mouse event to all clients with global cursor tracking enabled. auto& window_stack = current_window_stack(); for_each_visible_window_from_front_to_back([&](Window& window) { if (window.global_cursor_tracking() && &window != window_stack.active_input_tracking_window()) deliver_mouse_event(window, event, false); return IterationDecision::Continue; }); + ClientConnection::for_each_client([&](ClientConnection& conn) { + if (conn.does_global_mouse_tracking()) { + conn.async_track_mouse_move(event.position()); + } + }); // 3. If there's an active input tracking window, all mouse events go there. // Tracking ends after all mouse buttons have been released. diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc index 41accd5251..dfa282c36d 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -75,6 +75,7 @@ endpoint WindowServer did_finish_painting(i32 window_id, Vector<Gfx::IntRect> rects) =| set_global_cursor_tracking(i32 window_id, bool enabled) =| + set_global_mouse_tracking(bool enabled) =| set_window_opacity(i32 window_id, float opacity) =| set_window_alpha_hit_threshold(i32 window_id, float threshold) =| |