diff options
author | Giovanni Campagna <gcampagn@redhat.com> | 2013-08-13 12:57:41 +0200 |
---|---|---|
committer | Giovanni Campagna <gcampagn@redhat.com> | 2013-08-19 16:09:53 +0200 |
commit | 2ae7454f36bb5b73732ac3a01244a5862e3e8f1c (patch) | |
tree | a98d87d8c277121d111e8f570969bd72b15d0f8f /src/wayland/meta-wayland-seat.c | |
parent | 4fd3c63da9b68b47ad74534e2fec18399657e03a (diff) | |
download | mutter-2ae7454f36bb5b73732ac3a01244a5862e3e8f1c.tar.gz |
Add MetaCursorTracker, a new helper for tracking the cursor sprite
Under X, we need to use XFixes to watch the cursor changing, while
on wayland, we're in charge of setting and painting the cursor.
MetaCursorTracker provides the abstraction layer for gnome-shell,
which can thus drop ShellXFixesCursor. In the future, it may grow
the ability to watch for pointer position too, especially if
CursorEvents are added to the next version of XInput2, and thus
it would also replace the PointerWatcher we use for gnome-shell's
magnifier.
https://bugzilla.gnome.org/show_bug.cgi?id=705911
Diffstat (limited to 'src/wayland/meta-wayland-seat.c')
-rw-r--r-- | src/wayland/meta-wayland-seat.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c index 0d2b729e5..3ea739919 100644 --- a/src/wayland/meta-wayland-seat.c +++ b/src/wayland/meta-wayland-seat.c @@ -36,6 +36,7 @@ #include "meta-window-actor-private.h" #include "meta/meta-shaped-texture.h" #include "meta-wayland-stage.h" +#include "meta-cursor-tracker-private.h" #define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int (10) @@ -73,10 +74,14 @@ transform_stage_point_fixed (MetaWaylandSurface *surface, static void pointer_unmap_sprite (MetaWaylandSeat *seat) { - if (seat->current_stage) + if (seat->cursor_tracker) { - MetaWaylandStage *stage = META_WAYLAND_STAGE (seat->current_stage); - meta_wayland_stage_set_invisible_cursor (stage); + meta_cursor_tracker_set_sprite (seat->cursor_tracker, + NULL, 0, 0); + + if (seat->current_stage) + meta_cursor_tracker_queue_redraw (seat->cursor_tracker, + CLUTTER_ACTOR (seat->current_stage)); } if (seat->sprite) @@ -89,22 +94,29 @@ pointer_unmap_sprite (MetaWaylandSeat *seat) void meta_wayland_seat_update_sprite (MetaWaylandSeat *seat) { + ClutterBackend *backend; + CoglContext *context; + struct wl_resource *buffer; + CoglTexture2D *texture; + + if (seat->cursor_tracker == NULL) + return; + + backend = clutter_get_default_backend (); + context = clutter_backend_get_cogl_context (backend); + buffer = seat->sprite->buffer_ref.buffer->resource; + texture = cogl_wayland_texture_2d_new_from_buffer (context, buffer, NULL); + + meta_cursor_tracker_set_sprite (seat->cursor_tracker, + texture, + seat->hotspot_x, + seat->hotspot_y); + if (seat->current_stage) - { - MetaWaylandStage *stage = META_WAYLAND_STAGE (seat->current_stage); - ClutterBackend *backend = clutter_get_default_backend (); - CoglContext *context = clutter_backend_get_cogl_context (backend); - struct wl_resource *buffer = seat->sprite->buffer_ref.buffer->resource; - CoglTexture2D *texture = - cogl_wayland_texture_2d_new_from_buffer (context, buffer, NULL); - - meta_wayland_stage_set_cursor_from_texture (stage, - COGL_TEXTURE (texture), - seat->hotspot_x, - seat->hotspot_y); - - cogl_object_unref (texture); - } + meta_cursor_tracker_queue_redraw (seat->cursor_tracker, + CLUTTER_ACTOR (seat->current_stage)); + + cogl_object_unref (texture); } static void |