[mutter] seat: Move set_cursor_surface and all that tracking to MetaWaylandPointer



commit 4510b8236135a7092dce08ab970ffdbfde8cbb5f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Apr 17 17:00:59 2014 -0400

    seat: Move set_cursor_surface and all that tracking to MetaWaylandPointer

 src/wayland/meta-wayland-pointer.c |   40 +++++++++++++++++++++++++++++++++++-
 src/wayland/meta-wayland-pointer.h |    4 +++
 src/wayland/meta-wayland-seat.c    |   29 +-------------------------
 3 files changed, 44 insertions(+), 29 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 20defa9..7614ad9 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -57,6 +57,32 @@
 static void meta_wayland_pointer_end_popup_grab (MetaWaylandPointer *pointer);
 
 static void
+set_cursor_surface (MetaWaylandPointer *pointer,
+                    MetaWaylandSurface *surface)
+{
+  if (pointer->cursor_surface == surface)
+    return;
+
+  if (pointer->cursor_surface)
+    wl_list_remove (&pointer->cursor_surface_destroy_listener.link);
+
+  pointer->cursor_surface = surface;
+
+  if (pointer->cursor_surface)
+    wl_resource_add_destroy_listener (pointer->cursor_surface->resource,
+                                      &pointer->cursor_surface_destroy_listener);
+}
+
+static void
+pointer_handle_cursor_surface_destroy (struct wl_listener *listener, void *data)
+{
+  MetaWaylandPointer *pointer = wl_container_of (listener, pointer, cursor_surface_destroy_listener);
+
+  set_cursor_surface (pointer, NULL);
+  meta_wayland_pointer_update_cursor_surface (pointer);
+}
+
+static void
 pointer_handle_focus_surface_destroy (struct wl_listener *listener, void *data)
 {
   MetaWaylandPointer *pointer = wl_container_of (listener, pointer, focus_surface_listener);
@@ -284,12 +310,17 @@ meta_wayland_pointer_init (MetaWaylandPointer *pointer)
   clutter_input_device_get_coords (device, NULL, &current);
   pointer->x = wl_fixed_from_double (current.x);
   pointer->y = wl_fixed_from_double (current.y);
+
+  pointer->cursor_surface = NULL;
+  pointer->cursor_surface_destroy_listener.notify = pointer_handle_cursor_surface_destroy;
+  pointer->hotspot_x = 16;
+  pointer->hotspot_y = 16;
 }
 
 void
 meta_wayland_pointer_release (MetaWaylandPointer *pointer)
 {
-  /* Do nothing. */
+  set_cursor_surface (pointer, NULL);
 }
 
 static void
@@ -626,3 +657,10 @@ meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer)
   if (cursor)
     meta_cursor_reference_unref (cursor);
 }
+
+void
+meta_wayland_pointer_set_cursor_surface (MetaWaylandPointer *pointer,
+                                         MetaWaylandSurface *surface)
+{
+  set_cursor_surface (pointer, surface);
+}
diff --git a/src/wayland/meta-wayland-pointer.h b/src/wayland/meta-wayland-pointer.h
index 9675bc1..c82167d 100644
--- a/src/wayland/meta-wayland-pointer.h
+++ b/src/wayland/meta-wayland-pointer.h
@@ -107,4 +107,8 @@ meta_wayland_pointer_update_current_focus (MetaWaylandPointer *pointer,
 void
 meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer);
 
+void
+meta_wayland_pointer_set_cursor_surface (MetaWaylandPointer *pointer,
+                                         MetaWaylandSurface *surface);
+
 #endif /* __META_WAYLAND_POINTER_H__ */
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index e4cc10e..2303379 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -52,17 +52,7 @@ static void
 set_cursor_surface (MetaWaylandSeat    *seat,
                     MetaWaylandSurface *surface)
 {
-  if (seat->pointer.cursor_surface == surface)
-    return;
-
-  if (seat->pointer.cursor_surface)
-    wl_list_remove (&seat->pointer.cursor_surface_destroy_listener.link);
-
-  seat->pointer.cursor_surface = surface;
-
-  if (seat->pointer.cursor_surface)
-    wl_resource_add_destroy_listener (seat->pointer.cursor_surface->resource,
-                                      &seat->pointer.cursor_surface_destroy_listener);
+  meta_wayland_pointer_set_cursor_surface (&seat->pointer, surface);
 }
 
 void
@@ -199,16 +189,6 @@ bind_seat (struct wl_client *client,
     wl_seat_send_name (resource, "seat0");
 }
 
-static void
-pointer_handle_cursor_surface_destroy (struct wl_listener *listener, void *data)
-{
-  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);
-}
-
 MetaWaylandSeat *
 meta_wayland_seat_new (struct wl_display *display)
 {
@@ -225,11 +205,6 @@ meta_wayland_seat_new (struct wl_display *display)
 
   seat->current_stage = 0;
 
-  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);
 
   return seat;
@@ -238,8 +213,6 @@ meta_wayland_seat_new (struct wl_display *display)
 void
 meta_wayland_seat_free (MetaWaylandSeat *seat)
 {
-  set_cursor_surface (seat, NULL);
-
   meta_wayland_pointer_release (&seat->pointer);
   meta_wayland_keyboard_release (&seat->keyboard);
 


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