[mutter] seat: Move cursor storage to MetaWaylandPointer



commit ae0853ed86dbd67ee5470bee08edce6ce9b25a70
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Apr 17 16:54:30 2014 -0400

    seat: Move cursor storage to MetaWaylandPointer

 src/backends/meta-cursor-tracker.c       |    2 +-
 src/backends/native/meta-weston-launch.c |    2 +-
 src/wayland/meta-wayland-pointer.c       |   27 ++++++++++++++
 src/wayland/meta-wayland-pointer.h       |   10 +++++
 src/wayland/meta-wayland-seat.c          |   56 ++++++++++-------------------
 src/wayland/meta-wayland-seat.h          |    6 ---
 src/wayland/meta-wayland-stage.c         |    4 +-
 src/wayland/meta-wayland-surface.c       |    2 +-
 8 files changed, 61 insertions(+), 48 deletions(-)
---
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
index 83fc7f6..2996921 100644
--- a/src/backends/meta-cursor-tracker.c
+++ b/src/backends/meta-cursor-tracker.c
@@ -147,7 +147,7 @@ make_wayland_cursor_tracker (MetaScreen *screen)
   self->pipeline = cogl_pipeline_new (ctx);
 
   compositor = meta_wayland_compositor_get_default ();
-  compositor->seat->cursor_tracker = self;
+  compositor->seat->pointer.cursor_tracker = self;
   meta_cursor_tracker_update_position (self,
                                        wl_fixed_to_int (compositor->seat->pointer.x),
                                        wl_fixed_to_int (compositor->seat->pointer.y));
diff --git a/src/backends/native/meta-weston-launch.c b/src/backends/native/meta-weston-launch.c
index 135767b..49c967c 100644
--- a/src/backends/native/meta-weston-launch.c
+++ b/src/backends/native/meta-weston-launch.c
@@ -222,7 +222,7 @@ meta_launcher_enter (MetaLauncher *launcher)
      * update. */
 
     clutter_actor_queue_redraw (compositor->stage);
-    meta_cursor_tracker_force_update (compositor->seat->cursor_tracker);
+    meta_cursor_tracker_force_update (compositor->seat->pointer.cursor_tracker);
   }
 }
 
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 6929dbd..20defa9 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -49,6 +49,8 @@
 
 #include "meta-wayland-pointer.h"
 #include "meta-wayland-private.h"
+#include "meta-cursor.h"
+#include "meta-cursor-tracker-private.h"
 
 #include <string.h>
 
@@ -599,3 +601,28 @@ meta_wayland_pointer_update_current_focus (MetaWaylandPointer *pointer,
       interface->focus (pointer->grab, surface);
     }
 }
+
+void
+meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer)
+{
+  MetaCursorReference *cursor;
+
+  if (pointer->cursor_tracker == NULL)
+    return;
+
+  if (pointer->cursor_surface && pointer->cursor_surface->buffer)
+    {
+      struct wl_resource *buffer = pointer->cursor_surface->buffer->resource;
+      cursor = meta_cursor_reference_from_buffer (pointer->cursor_tracker,
+                                                  buffer,
+                                                  pointer->hotspot_x,
+                                                  pointer->hotspot_y);
+    }
+  else
+    cursor = NULL;
+
+  meta_cursor_tracker_set_window_cursor (pointer->cursor_tracker, cursor);
+
+  if (cursor)
+    meta_cursor_reference_unref (cursor);
+}
diff --git a/src/wayland/meta-wayland-pointer.h b/src/wayland/meta-wayland-pointer.h
index 43c82fb..9675bc1 100644
--- a/src/wayland/meta-wayland-pointer.h
+++ b/src/wayland/meta-wayland-pointer.h
@@ -26,6 +26,8 @@
 
 #include "meta-wayland-types.h"
 
+#include <meta/meta-cursor-tracker.h>
+
 struct _MetaWaylandPointerGrabInterface
 {
   void (*focus) (MetaWaylandPointerGrab *grab,
@@ -47,6 +49,11 @@ struct _MetaWaylandPointer
   struct wl_list resource_list;
   struct wl_list focus_resource_list;
 
+  MetaCursorTracker *cursor_tracker;
+  MetaWaylandSurface *cursor_surface;
+  struct wl_listener cursor_surface_destroy_listener;
+  int hotspot_x, hotspot_y;
+
   MetaWaylandSurface *focus_surface;
   struct wl_listener focus_surface_listener;
   guint32 focus_serial;
@@ -97,4 +104,7 @@ void
 meta_wayland_pointer_update_current_focus (MetaWaylandPointer *pointer,
                                            MetaWaylandSurface *surface);
 
+void
+meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer);
+
 #endif /* __META_WAYLAND_POINTER_H__ */
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index 482e233..e4cc10e 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -52,42 +52,23 @@ static void
 set_cursor_surface (MetaWaylandSeat    *seat,
                     MetaWaylandSurface *surface)
 {
-  if (seat->cursor_surface == surface)
+  if (seat->pointer.cursor_surface == surface)
     return;
 
-  if (seat->cursor_surface)
-    wl_list_remove (&seat->cursor_surface_destroy_listener.link);
+  if (seat->pointer.cursor_surface)
+    wl_list_remove (&seat->pointer.cursor_surface_destroy_listener.link);
 
-  seat->cursor_surface = surface;
+  seat->pointer.cursor_surface = surface;
 
-  if (seat->cursor_surface)
-    wl_resource_add_destroy_listener (seat->cursor_surface->resource,
-                                      &seat->cursor_surface_destroy_listener);
+  if (seat->pointer.cursor_surface)
+    wl_resource_add_destroy_listener (seat->pointer.cursor_surface->resource,
+                                      &seat->pointer.cursor_surface_destroy_listener);
 }
 
 void
 meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
 {
-  MetaCursorReference *cursor;
-
-  if (seat->cursor_tracker == NULL)
-    return;
-
-  if (seat->cursor_surface && seat->cursor_surface->buffer)
-    {
-      struct wl_resource *buffer = seat->cursor_surface->buffer->resource;
-      cursor = meta_cursor_reference_from_buffer (seat->cursor_tracker,
-                                                  buffer,
-                                                  seat->hotspot_x,
-                                                  seat->hotspot_y);
-    }
-  else
-    cursor = NULL;
-
-  meta_cursor_tracker_set_window_cursor (seat->cursor_tracker, cursor);
-
-  if (cursor)
-    meta_cursor_reference_unref (cursor);
+  meta_wayland_pointer_update_cursor_surface (&seat->pointer);
 }
 
 static void
@@ -109,8 +90,8 @@ pointer_set_cursor (struct wl_client *client,
   if (seat->pointer.focus_serial - serial > G_MAXUINT32 / 2)
     return;
 
-  seat->hotspot_x = x;
-  seat->hotspot_y = y;
+  seat->pointer.hotspot_x = x;
+  seat->pointer.hotspot_y = y;
   set_cursor_surface (seat, surface);
   meta_wayland_seat_update_cursor_surface (seat);
 }
@@ -221,7 +202,8 @@ bind_seat (struct wl_client *client,
 static void
 pointer_handle_cursor_surface_destroy (struct wl_listener *listener, void *data)
 {
-  MetaWaylandSeat *seat = wl_container_of (listener, seat, cursor_surface_destroy_listener);
+  MetaWaylandPointer *pointer = wl_container_of (listener, pointer, cursor_surface_destroy_listener);
+  MetaWaylandSeat *seat = wl_container_of (pointer, seat, pointer);
 
   set_cursor_surface (seat, NULL);
   meta_wayland_seat_update_cursor_surface (seat);
@@ -243,10 +225,10 @@ meta_wayland_seat_new (struct wl_display *display)
 
   seat->current_stage = 0;
 
-  seat->cursor_surface = NULL;
-  seat->cursor_surface_destroy_listener.notify = pointer_handle_cursor_surface_destroy;
-  seat->hotspot_x = 16;
-  seat->hotspot_y = 16;
+  seat->pointer.cursor_surface = NULL;
+  seat->pointer.cursor_surface_destroy_listener.notify = pointer_handle_cursor_surface_destroy;
+  seat->pointer.hotspot_x = 16;
+  seat->pointer.hotspot_y = 16;
 
   wl_global_create (display, &wl_seat_interface, META_WL_SEAT_VERSION, seat, bind_seat);
 
@@ -397,14 +379,14 @@ meta_wayland_seat_update_pointer (MetaWaylandSeat    *seat,
 
   seat->pointer.button_count = count_buttons (event);
 
-  if (seat->cursor_tracker)
+  if (seat->pointer.cursor_tracker)
     {
-      meta_cursor_tracker_update_position (seat->cursor_tracker,
+      meta_cursor_tracker_update_position (seat->pointer.cursor_tracker,
                                           wl_fixed_to_int (seat->pointer.x),
                                           wl_fixed_to_int (seat->pointer.y));
 
       if (seat->pointer.current == NULL)
-       meta_cursor_tracker_unset_window_cursor (seat->cursor_tracker);
+       meta_cursor_tracker_unset_window_cursor (seat->pointer.cursor_tracker);
     }
 }
 
diff --git a/src/wayland/meta-wayland-seat.h b/src/wayland/meta-wayland-seat.h
index 1cd0c83..72af963 100644
--- a/src/wayland/meta-wayland-seat.h
+++ b/src/wayland/meta-wayland-seat.h
@@ -27,7 +27,6 @@
 #include <clutter/clutter.h>
 #include <glib.h>
 
-#include <meta/meta-cursor-tracker.h>
 #include "meta-wayland-types.h"
 #include "meta-wayland-keyboard.h"
 #include "meta-wayland-pointer.h"
@@ -59,11 +58,6 @@ struct _MetaWaylandSeat
 
   struct wl_display *display;
 
-  MetaCursorTracker *cursor_tracker;
-  MetaWaylandSurface *cursor_surface;
-  int hotspot_x, hotspot_y;
-  struct wl_listener cursor_surface_destroy_listener;
-
   ClutterActor *current_stage;
 };
 
diff --git a/src/wayland/meta-wayland-stage.c b/src/wayland/meta-wayland-stage.c
index b795dd5..1a63f33 100644
--- a/src/wayland/meta-wayland-stage.c
+++ b/src/wayland/meta-wayland-stage.c
@@ -41,8 +41,8 @@ meta_wayland_stage_paint (ClutterActor *actor)
   CLUTTER_ACTOR_CLASS (meta_wayland_stage_parent_class)->paint (actor);
 
   compositor = meta_wayland_compositor_get_default ();
-  if (compositor->seat->cursor_tracker)
-    meta_cursor_tracker_paint (compositor->seat->cursor_tracker);
+  if (compositor->seat->pointer.cursor_tracker)
+    meta_cursor_tracker_paint (compositor->seat->pointer.cursor_tracker);
 }
 
 static void
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index b7d1b1b..a414e53 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -337,7 +337,7 @@ commit_double_buffered_state (MetaWaylandSurface             *surface,
 
   actor_surface_commit (surface, pending);
 
-  if (surface == compositor->seat->cursor_surface)
+  if (surface == compositor->seat->pointer.cursor_surface)
     cursor_surface_commit (surface, pending);
   else if (surface->window)
     toplevel_surface_commit (surface, pending);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]