mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 17:37:47 +00:00
LibGUI+WindowServer: Introduce new mouse tracking mechanism
This commit is contained in:
parent
bde3c7301e
commit
45126655cd
10 changed files with 94 additions and 3 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -44,5 +44,7 @@ endpoint WindowClient
|
|||
|
||||
display_link_notification() =|
|
||||
|
||||
track_mouse_move(Gfx::IntPoint mouse_position) =|
|
||||
|
||||
ping() =|
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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) =|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue