mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 20:32:16 +00:00
cursor-tracker/x11: Also update sprite when updating position
Without doing this, we'd use the same sprite that was last set by mutter, most likely a leftptr cursor, and fail to update when e.g. moving the pointer above a text entry and the displayed cursor updated to a cursor position marker. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1391
This commit is contained in:
parent
2d010c9b84
commit
fc778e2bd3
@ -51,6 +51,8 @@ void meta_cursor_tracker_untrack_position (MetaCursorTracker *tracker);
|
||||
|
||||
MetaCursorSprite * meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker);
|
||||
|
||||
MetaBackend * meta_cursor_tracker_get_backend (MetaCursorTracker *tracker);
|
||||
|
||||
void meta_cursor_tracker_notify_cursor_changed (MetaCursorTracker *tracker);
|
||||
|
||||
#endif
|
||||
|
@ -543,7 +543,7 @@ meta_cursor_tracker_untrack_position (MetaCursorTracker *tracker)
|
||||
MetaCursorTrackerPrivate *priv =
|
||||
meta_cursor_tracker_get_instance_private (tracker);
|
||||
|
||||
g_return_if_fail (priv->track_position_count <= 0);
|
||||
g_return_if_fail (priv->track_position_count > 0);
|
||||
|
||||
priv->track_position_count--;
|
||||
if (priv->track_position_count == 0)
|
||||
@ -588,3 +588,12 @@ meta_cursor_tracker_get_displayed_cursor (MetaCursorTracker *tracker)
|
||||
|
||||
return priv->displayed_cursor;
|
||||
}
|
||||
|
||||
MetaBackend *
|
||||
meta_cursor_tracker_get_backend (MetaCursorTracker *tracker)
|
||||
{
|
||||
MetaCursorTrackerPrivate *priv =
|
||||
meta_cursor_tracker_get_instance_private (tracker);
|
||||
|
||||
return priv->backend;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ struct _MetaCursorTrackerX11
|
||||
G_DEFINE_TYPE (MetaCursorTrackerX11, meta_cursor_tracker_x11,
|
||||
META_TYPE_CURSOR_TRACKER)
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
ensure_xfixes_cursor (MetaCursorTrackerX11 *tracker_x11);
|
||||
|
||||
gboolean
|
||||
@ -75,27 +75,47 @@ update_position (MetaCursorTrackerX11 *tracker_x11)
|
||||
meta_cursor_tracker_update_position (tracker, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
ensure_xfixes_cursor (MetaCursorTrackerX11 *tracker_x11)
|
||||
{
|
||||
MetaDisplay *display = meta_get_display ();
|
||||
g_autoptr (GError) error = NULL;
|
||||
|
||||
if (tracker_x11->xfixes_cursor)
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
tracker_x11->xfixes_cursor = meta_cursor_sprite_xfixes_new (display, &error);
|
||||
if (!tracker_x11->xfixes_cursor)
|
||||
g_warning ("Failed to create XFIXES cursor: %s", error->message);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
update_position_timeout (gpointer user_data)
|
||||
update_cursor_timeout (gpointer user_data)
|
||||
{
|
||||
MetaCursorTrackerX11 *tracker_x11 = user_data;
|
||||
MetaCursorTracker *tracker = META_CURSOR_TRACKER (tracker_x11);
|
||||
MetaBackend *backend = meta_cursor_tracker_get_backend (tracker);
|
||||
MetaCursorRenderer *cursor_renderer =
|
||||
meta_backend_get_cursor_renderer (backend);
|
||||
gboolean cursor_changed;
|
||||
MetaCursorSprite *cursor_sprite;
|
||||
|
||||
update_position (tracker_x11);
|
||||
|
||||
cursor_changed = ensure_xfixes_cursor (tracker_x11);
|
||||
|
||||
if (tracker_x11->xfixes_cursor)
|
||||
cursor_sprite = META_CURSOR_SPRITE (tracker_x11->xfixes_cursor);
|
||||
else
|
||||
cursor_sprite = NULL;
|
||||
|
||||
meta_cursor_renderer_update_stage_overlay (cursor_renderer, cursor_sprite);
|
||||
|
||||
if (cursor_changed)
|
||||
meta_cursor_tracker_notify_cursor_changed (tracker);
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
@ -114,7 +134,7 @@ meta_cursor_tracker_x11_set_force_track_position (MetaCursorTracker *tracker,
|
||||
{
|
||||
tracker_x11->update_position_timeout_id =
|
||||
g_timeout_add (UPDATE_POSITION_TIMEOUT_MS,
|
||||
update_position_timeout,
|
||||
update_cursor_timeout,
|
||||
tracker_x11);
|
||||
update_position (tracker_x11);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user