mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
core: Centralize cursor renderer and tracker updates
These use now more of a "pull" model, where they receive update notifications and the relevant input position is queried, instead of the coordinates being passed along. This allows to treat cursor renderers all the same independently of the device they track. This notifying of position changes should ideally be more backend-y than core-y, a better location will be figured out in future commits. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403
This commit is contained in:
parent
543d232b51
commit
0c92417178
@ -444,14 +444,14 @@ meta_cursor_renderer_force_update (MetaCursorRenderer *renderer)
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
||||
float x,
|
||||
float y)
|
||||
meta_cursor_renderer_update_position (MetaCursorRenderer *renderer)
|
||||
{
|
||||
MetaCursorRendererPrivate *priv = meta_cursor_renderer_get_instance_private (renderer);
|
||||
graphene_point_t pos;
|
||||
|
||||
priv->current_x = x;
|
||||
priv->current_y = y;
|
||||
clutter_input_device_get_coords (priv->device, NULL, &pos);
|
||||
priv->current_x = pos.x;
|
||||
priv->current_y = pos.y;
|
||||
|
||||
meta_cursor_renderer_update_cursor (renderer, priv->displayed_cursor);
|
||||
}
|
||||
|
@ -60,9 +60,7 @@ MetaCursorRenderer * meta_cursor_renderer_new (MetaBackend *backend,
|
||||
void meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
|
||||
MetaCursorSprite *cursor_sprite);
|
||||
|
||||
void meta_cursor_renderer_set_position (MetaCursorRenderer *renderer,
|
||||
float x,
|
||||
float y);
|
||||
void meta_cursor_renderer_update_position (MetaCursorRenderer *renderer);
|
||||
void meta_cursor_renderer_force_update (MetaCursorRenderer *renderer);
|
||||
|
||||
MetaCursorSprite * meta_cursor_renderer_get_cursor (MetaCursorRenderer *renderer);
|
||||
|
@ -41,9 +41,7 @@ void meta_cursor_tracker_unset_window_cursor (MetaCursorTracker *tracker);
|
||||
void meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
||||
MetaCursorSprite *cursor_sprite);
|
||||
|
||||
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
||||
float new_x,
|
||||
float new_y);
|
||||
void meta_cursor_tracker_update_position (MetaCursorTracker *tracker);
|
||||
|
||||
void meta_cursor_tracker_track_position (MetaCursorTracker *tracker);
|
||||
|
||||
|
@ -428,31 +428,9 @@ meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
|
||||
}
|
||||
|
||||
void
|
||||
meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
|
||||
float new_x,
|
||||
float new_y)
|
||||
meta_cursor_tracker_update_position (MetaCursorTracker *tracker)
|
||||
{
|
||||
MetaCursorTrackerPrivate *priv =
|
||||
meta_cursor_tracker_get_instance_private (tracker);
|
||||
MetaCursorRenderer *cursor_renderer =
|
||||
meta_backend_get_cursor_renderer (priv->backend);
|
||||
gboolean position_changed;
|
||||
|
||||
if (priv->x != new_x || priv->y != new_y)
|
||||
{
|
||||
position_changed = TRUE;
|
||||
priv->x = new_x;
|
||||
priv->y = new_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
position_changed = FALSE;
|
||||
}
|
||||
|
||||
meta_cursor_renderer_set_position (cursor_renderer, new_x, new_y);
|
||||
|
||||
if (position_changed)
|
||||
g_signal_emit (tracker, signals[CURSOR_MOVED], 0);
|
||||
g_signal_emit (tracker, signals[CURSOR_MOVED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2774,11 +2774,14 @@ meta_seat_native_warp_pointer (ClutterSeat *seat,
|
||||
{
|
||||
MetaSeatNative *seat_native = META_SEAT_NATIVE (seat);
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaCursorRenderer *cursor_renderer =
|
||||
meta_backend_get_cursor_renderer (backend);
|
||||
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
|
||||
|
||||
notify_absolute_motion (seat_native->core_pointer, 0, x, y, NULL);
|
||||
|
||||
meta_cursor_tracker_update_position (cursor_tracker, x, y);
|
||||
meta_cursor_renderer_update_position (cursor_renderer);
|
||||
meta_cursor_tracker_update_position (cursor_tracker);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -69,10 +69,8 @@ static void
|
||||
update_position (MetaCursorTrackerX11 *tracker_x11)
|
||||
{
|
||||
MetaCursorTracker *tracker = META_CURSOR_TRACKER (tracker_x11);
|
||||
int x, y;
|
||||
|
||||
meta_cursor_tracker_get_pointer (tracker, &x, &y, NULL);
|
||||
meta_cursor_tracker_update_position (tracker, x, y);
|
||||
meta_cursor_tracker_update_position (tracker);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -279,22 +279,21 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
#ifdef HAVE_WAYLAND
|
||||
if (meta_is_wayland_compositor () && event->type == CLUTTER_MOTION)
|
||||
{
|
||||
MetaWaylandCompositor *compositor;
|
||||
MetaCursorRenderer *cursor_renderer;
|
||||
ClutterInputDevice *device;
|
||||
|
||||
compositor = meta_wayland_compositor_get_default ();
|
||||
device = clutter_event_get_device (event);
|
||||
cursor_renderer = meta_backend_get_cursor_renderer_for_device (backend,
|
||||
device);
|
||||
if (cursor_renderer)
|
||||
meta_cursor_renderer_update_position (cursor_renderer);
|
||||
|
||||
if (meta_wayland_tablet_manager_consumes_event (compositor->tablet_manager, event))
|
||||
{
|
||||
meta_wayland_tablet_manager_update_cursor_position (compositor->tablet_manager, event);
|
||||
}
|
||||
else
|
||||
if (device == clutter_seat_get_pointer (clutter_input_device_get_seat (device)))
|
||||
{
|
||||
MetaCursorTracker *cursor_tracker =
|
||||
meta_backend_get_cursor_tracker (backend);
|
||||
|
||||
meta_cursor_tracker_update_position (cursor_tracker,
|
||||
event->motion.x,
|
||||
event->motion.y);
|
||||
meta_cursor_tracker_update_position (cursor_tracker);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -242,30 +242,3 @@ meta_wayland_tablet_manager_ensure_seat (MetaWaylandTabletManager *manager,
|
||||
|
||||
return tablet_seat;
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_tablet_manager_update_cursor_position (MetaWaylandTabletManager *manager,
|
||||
const ClutterEvent *event)
|
||||
{
|
||||
MetaWaylandTabletSeat *tablet_seat = NULL;
|
||||
MetaWaylandTabletTool *tool = NULL;
|
||||
ClutterInputDeviceTool *device_tool;
|
||||
ClutterInputDevice *device;
|
||||
|
||||
device = clutter_event_get_source_device (event);
|
||||
device_tool = clutter_event_get_device_tool (event);
|
||||
|
||||
if (device)
|
||||
tablet_seat = meta_wayland_tablet_manager_lookup_seat (manager, device);
|
||||
|
||||
if (tablet_seat && device_tool)
|
||||
tool = meta_wayland_tablet_seat_lookup_tool (tablet_seat, device_tool);
|
||||
|
||||
if (tool)
|
||||
{
|
||||
gfloat new_x, new_y;
|
||||
|
||||
clutter_event_get_coords (event, &new_x, &new_y);
|
||||
meta_wayland_tablet_tool_set_cursor_position (tool, new_x, new_y);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,4 @@ MetaWaylandTabletSeat *
|
||||
meta_wayland_tablet_manager_ensure_seat (MetaWaylandTabletManager *manager,
|
||||
MetaWaylandSeat *seat);
|
||||
|
||||
void meta_wayland_tablet_manager_update_cursor_position (MetaWaylandTabletManager *manager,
|
||||
const ClutterEvent *event);
|
||||
|
||||
#endif /* META_WAYLAND_TABLET_MANAGER_H */
|
||||
|
@ -984,15 +984,6 @@ meta_wayland_tablet_tool_handle_event (MetaWaylandTabletTool *tool,
|
||||
return CLUTTER_EVENT_STOP;
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *tool,
|
||||
float new_x,
|
||||
float new_y)
|
||||
{
|
||||
if (tool->cursor_renderer)
|
||||
meta_cursor_renderer_set_position (tool->cursor_renderer, new_x, new_y);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
|
||||
MetaWaylandSurface *surface)
|
||||
|
@ -78,10 +78,6 @@ void meta_wayland_tablet_tool_update (MetaWaylandTabletTool *t
|
||||
gboolean meta_wayland_tablet_tool_handle_event (MetaWaylandTabletTool *tool,
|
||||
const ClutterEvent *event);
|
||||
|
||||
void meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *tool,
|
||||
float new_x,
|
||||
float new_y);
|
||||
|
||||
gboolean meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
|
||||
MetaWaylandSurface *surface,
|
||||
uint32_t serial);
|
||||
|
Loading…
Reference in New Issue
Block a user