MetaCursorTracker: add methods for setting the cursor visibility

clutter_stage_show_cursor()/hide_cursor() only works in the X11
backend (where someone else is in charge of showing the cursor),
and even then, it has confusing effects when running nested wayland,
so an abstraction layer is needed.

https://bugzilla.gnome.org/show_bug.cgi?id=707474
This commit is contained in:
Giovanni Campagna 2013-09-04 16:56:00 +02:00
parent 6f4f611ba8
commit 5b3340e585
2 changed files with 29 additions and 1 deletions

View File

@ -426,7 +426,7 @@ meta_cursor_tracker_paint (MetaCursorTracker *tracker)
{ {
g_assert (meta_is_wayland_compositor ()); g_assert (meta_is_wayland_compositor ());
if (tracker->sprite == NULL) if (tracker->sprite == NULL || tracker->is_showing == FALSE)
return; return;
/* FIXME: try to use a DRM cursor when possible */ /* FIXME: try to use a DRM cursor when possible */
@ -513,3 +513,29 @@ meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker,
else else
get_pointer_position_gdk (x, y, (int*)mods); get_pointer_position_gdk (x, y, (int*)mods);
} }
void
meta_cursor_tracker_set_pointer_visible (MetaCursorTracker *tracker,
gboolean visible)
{
if (visible == tracker->is_showing)
return;
tracker->is_showing = visible;
if (meta_is_wayland_compositor ())
{
MetaWaylandCompositor *compositor;
compositor = meta_wayland_compositor_get_default ();
meta_cursor_tracker_queue_redraw (tracker, compositor->stage);
}
else
{
if (visible)
XFixesShowCursor (tracker->screen->display->xdisplay,
tracker->screen->xroot);
else
XFixesHideCursor (tracker->screen->display->xdisplay,
tracker->screen->xroot);
}
}

View File

@ -52,5 +52,7 @@ void meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker,
int *x, int *x,
int *y, int *y,
ClutterModifierType *mods); ClutterModifierType *mods);
void meta_cursor_tracker_set_pointer_visible (MetaCursorTracker *tracker,
gboolean visible);
#endif #endif