From 5b3340e5856b9b90d1c8ad938053a18e0e891c01 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Wed, 4 Sep 2013 16:56:00 +0200 Subject: [PATCH] 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 --- src/core/meta-cursor-tracker.c | 28 +++++++++++++++++++++++++++- src/meta/meta-cursor-tracker.h | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/core/meta-cursor-tracker.c b/src/core/meta-cursor-tracker.c index 0ae1786fa..8c3815edd 100644 --- a/src/core/meta-cursor-tracker.c +++ b/src/core/meta-cursor-tracker.c @@ -426,7 +426,7 @@ meta_cursor_tracker_paint (MetaCursorTracker *tracker) { g_assert (meta_is_wayland_compositor ()); - if (tracker->sprite == NULL) + if (tracker->sprite == NULL || tracker->is_showing == FALSE) return; /* FIXME: try to use a DRM cursor when possible */ @@ -513,3 +513,29 @@ meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker, else 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); + } +} diff --git a/src/meta/meta-cursor-tracker.h b/src/meta/meta-cursor-tracker.h index 8862e4345..39202951a 100644 --- a/src/meta/meta-cursor-tracker.h +++ b/src/meta/meta-cursor-tracker.h @@ -52,5 +52,7 @@ void meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker, int *x, int *y, ClutterModifierType *mods); +void meta_cursor_tracker_set_pointer_visible (MetaCursorTracker *tracker, + gboolean visible); #endif