[mutter] seat: Move update_pointer to MetaWaylandPointer



commit 4b7d77864a866e56cf46d7cfe73c12b7658392c3
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Apr 17 17:52:11 2014 -0400

    seat: Move update_pointer to MetaWaylandPointer

 src/wayland/meta-wayland-pointer.c |   95 ++++++++++++++++++++++++++---------
 src/wayland/meta-wayland-pointer.h |    4 ++
 src/wayland/meta-wayland-seat.c    |   49 +-----------------
 3 files changed, 77 insertions(+), 71 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index d805877..f3ec987 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -329,6 +329,76 @@ meta_wayland_pointer_release (MetaWaylandPointer *pointer)
   set_cursor_surface (pointer, NULL);
 }
 
+static int
+count_buttons (const ClutterEvent *event)
+{
+  static gint maskmap[5] =
+    {
+      CLUTTER_BUTTON1_MASK, CLUTTER_BUTTON2_MASK, CLUTTER_BUTTON3_MASK,
+      CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK
+    };
+  ClutterModifierType mod_mask;
+  int i, count;
+
+  mod_mask = clutter_event_get_state (event);
+  count = 0;
+  for (i = 0; i < 5; i++)
+    {
+      if (mod_mask & maskmap[i])
+       count++;
+    }
+
+  return count;
+}
+
+void
+meta_wayland_pointer_update (MetaWaylandPointer *pointer,
+                             const ClutterEvent *event)
+{
+  float x, y;
+
+  clutter_event_get_coords (event, &x, &y);
+  pointer->x = wl_fixed_from_double (x);
+  pointer->y = wl_fixed_from_double (y);
+
+  pointer->button_count = count_buttons (event);
+
+  if (pointer->cursor_tracker)
+    {
+      meta_cursor_tracker_update_position (pointer->cursor_tracker,
+                                          wl_fixed_to_int (pointer->x),
+                                          wl_fixed_to_int (pointer->y));
+
+      if (pointer->current == NULL)
+       meta_cursor_tracker_unset_window_cursor (pointer->cursor_tracker);
+    }
+}
+
+static void
+pointer_set_cursor (struct wl_client *client,
+                    struct wl_resource *resource,
+                    uint32_t serial,
+                    struct wl_resource *surface_resource,
+                    int32_t x, int32_t y)
+{
+  MetaWaylandPointer *pointer = wl_resource_get_user_data (resource);
+  MetaWaylandSurface *surface;
+
+  surface = (surface_resource ? wl_resource_get_user_data (surface_resource) : NULL);
+
+  if (pointer->focus_surface == NULL)
+    return;
+  if (wl_resource_get_client (pointer->focus_surface->resource) != client)
+    return;
+  if (pointer->focus_serial - serial > G_MAXUINT32 / 2)
+    return;
+
+  pointer->hotspot_x = x;
+  pointer->hotspot_y = y;
+  set_cursor_surface (pointer, surface);
+  meta_wayland_pointer_update_cursor_surface (pointer);
+}
+
 static void
 move_resources (struct wl_list *destination, struct wl_list *source)
 {
@@ -665,31 +735,6 @@ meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer)
 }
 
 static void
-pointer_set_cursor (struct wl_client *client,
-                    struct wl_resource *resource,
-                    uint32_t serial,
-                    struct wl_resource *surface_resource,
-                    int32_t x, int32_t y)
-{
-  MetaWaylandPointer *pointer = wl_resource_get_user_data (resource);
-  MetaWaylandSurface *surface;
-
-  surface = (surface_resource ? wl_resource_get_user_data (surface_resource) : NULL);
-
-  if (pointer->focus_surface == NULL)
-    return;
-  if (wl_resource_get_client (pointer->focus_surface->resource) != client)
-    return;
-  if (pointer->focus_serial - serial > G_MAXUINT32 / 2)
-    return;
-
-  pointer->hotspot_x = x;
-  pointer->hotspot_y = y;
-  set_cursor_surface (pointer, surface);
-  meta_wayland_pointer_update_cursor_surface (pointer);
-}
-
-static void
 pointer_release (struct wl_client *client,
                  struct wl_resource *resource)
 {
diff --git a/src/wayland/meta-wayland-pointer.h b/src/wayland/meta-wayland-pointer.h
index 281d4d9..4c9d927 100644
--- a/src/wayland/meta-wayland-pointer.h
+++ b/src/wayland/meta-wayland-pointer.h
@@ -80,6 +80,10 @@ void
 meta_wayland_pointer_release (MetaWaylandPointer *pointer);
 
 void
+meta_wayland_pointer_update (MetaWaylandPointer *pointer,
+                             const ClutterEvent *event);
+
+void
 meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
                                 MetaWaylandSurface *surface);
 
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index b734cef..9fbe582 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -162,51 +162,6 @@ meta_wayland_seat_free (MetaWaylandSeat *seat)
   g_slice_free (MetaWaylandSeat, seat);
 }
 
-static int
-count_buttons (const ClutterEvent *event)
-{
-  static gint maskmap[5] =
-    {
-      CLUTTER_BUTTON1_MASK, CLUTTER_BUTTON2_MASK, CLUTTER_BUTTON3_MASK,
-      CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK
-    };
-  ClutterModifierType mod_mask;
-  int i, count;
-
-  mod_mask = clutter_event_get_state (event);
-  count = 0;
-  for (i = 0; i < 5; i++)
-    {
-      if (mod_mask & maskmap[i])
-       count++;
-    }
-
-  return count;
-}
-
-static void
-meta_wayland_seat_update_pointer (MetaWaylandSeat    *seat,
-                                  const ClutterEvent *event)
-{
-  float x, y;
-
-  clutter_event_get_coords (event, &x, &y);
-  seat->pointer.x = wl_fixed_from_double (x);
-  seat->pointer.y = wl_fixed_from_double (y);
-
-  seat->pointer.button_count = count_buttons (event);
-
-  if (seat->pointer.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->pointer.cursor_tracker);
-    }
-}
-
 void
 meta_wayland_seat_update (MetaWaylandSeat    *seat,
                           const ClutterEvent *event)
@@ -217,12 +172,14 @@ meta_wayland_seat_update (MetaWaylandSeat    *seat,
     case CLUTTER_BUTTON_PRESS:
     case CLUTTER_BUTTON_RELEASE:
     case CLUTTER_SCROLL:
-      meta_wayland_seat_update_pointer (seat, event);
+      meta_wayland_pointer_update (&seat->pointer, event);
       break;
+
     case CLUTTER_KEY_PRESS:
     case CLUTTER_KEY_RELEASE:
       meta_wayland_keyboard_update (&seat->keyboard, (const ClutterKeyEvent *) event);
       break;
+
     default:
       break;
     }


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