[mutter/wip/carlosg/input-thread: 59/104] backends: Use graphene_point_t on meta_cursor_tracker_get_pointer()




commit dd78af0e0acfe479bffb5b9f2911f135665531fa
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jul 13 12:06:12 2020 +0200

    backends: Use graphene_point_t on meta_cursor_tracker_get_pointer()
    
    It's nicer to propagate along.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

 src/backends/meta-cursor-tracker.c        | 12 ++----------
 src/backends/native/meta-backend-native.c |  7 ++++---
 src/backends/x11/meta-backend-x11.c       |  7 ++++---
 src/core/display.c                        |  6 +++---
 src/core/window.c                         | 12 ++++++------
 src/meta/meta-cursor-tracker.h            |  3 +--
 src/wayland/meta-wayland-dnd-surface.c    |  7 ++++---
 src/x11/window-x11.c                      |  2 +-
 8 files changed, 25 insertions(+), 31 deletions(-)
---
diff --git a/src/backends/meta-cursor-tracker.c b/src/backends/meta-cursor-tracker.c
index 85deb798ba..3c6f6a0c43 100644
--- a/src/backends/meta-cursor-tracker.c
+++ b/src/backends/meta-cursor-tracker.c
@@ -457,24 +457,16 @@ meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
 
 void
 meta_cursor_tracker_get_pointer (MetaCursorTracker   *tracker,
-                                 int                 *x,
-                                 int                 *y,
+                                 graphene_point_t    *coords,
                                  ClutterModifierType *mods)
 {
   ClutterSeat *seat;
   ClutterInputDevice *cdevice;
-  graphene_point_t point;
 
   seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
   cdevice = clutter_seat_get_pointer (seat);
 
-  clutter_input_device_get_coords (cdevice, NULL, &point);
-  if (x)
-    *x = point.x;
-  if (y)
-    *y = point.y;
-  if (mods)
-    *mods = clutter_input_device_get_modifier_state (cdevice);
+  clutter_seat_query_state (seat, cdevice, NULL, coords, mods);
 }
 
 void
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 2c4730c5d3..9abf24cae3 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -221,10 +221,11 @@ meta_backend_native_get_current_logical_monitor (MetaBackend *backend)
   MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
-  int x, y;
+  graphene_point_t point;
 
-  meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL);
-  return meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y);
+  meta_cursor_tracker_get_pointer (cursor_tracker, &point, NULL);
+  return meta_monitor_manager_get_logical_monitor_at (monitor_manager,
+                                                      point.x, point.y);
 }
 
 static void
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 69e4ed85f9..cf4c9362e1 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -677,7 +677,7 @@ meta_backend_x11_get_current_logical_monitor (MetaBackend *backend)
   MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
   MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
   MetaCursorTracker *cursor_tracker;
-  int x, y;
+  graphene_point_t point;
   MetaMonitorManager *monitor_manager;
   MetaLogicalMonitor *logical_monitor;
 
@@ -685,10 +685,11 @@ meta_backend_x11_get_current_logical_monitor (MetaBackend *backend)
     return priv->cached_current_logical_monitor;
 
   cursor_tracker = meta_backend_get_cursor_tracker (backend);
-  meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL);
+  meta_cursor_tracker_get_pointer (cursor_tracker, &point, NULL);
   monitor_manager = meta_backend_get_monitor_manager (backend);
   logical_monitor =
-    meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y);
+    meta_monitor_manager_get_logical_monitor_at (monitor_manager,
+                                                 point.x, point.y);
 
   if (!logical_monitor && monitor_manager->logical_monitors)
     logical_monitor = monitor_manager->logical_monitors->data;
diff --git a/src/core/display.c b/src/core/display.c
index 6e146c76fa..81410b18e6 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -3705,18 +3705,18 @@ meta_display_get_pointer_window (MetaDisplay *display,
   MetaBackend *backend = meta_get_backend ();
   MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
   MetaWindow *window;
-  int x, y;
+  graphene_point_t point;
 
   if (not_this_one)
     meta_topic (META_DEBUG_FOCUS,
                 "Focusing mouse window excluding %s\n", not_this_one->desc);
 
-  meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL);
+  meta_cursor_tracker_get_pointer (cursor_tracker, &point, NULL);
 
   window = meta_stack_get_default_focus_window_at_point (display->stack,
                                                          workspace_manager->active_workspace,
                                                          not_this_one,
-                                                         x, y);
+                                                         point.x, point.y);
 
   return window;
 }
diff --git a/src/core/window.c b/src/core/window.c
index 681805c06c..dd1cd625ea 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -8183,19 +8183,19 @@ window_focus_on_pointer_rest_callback (gpointer data)
   MetaDisplay *display = window->display;
   MetaBackend *backend = meta_get_backend ();
   MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
-  int root_x, root_y;
+  graphene_point_t point;
   guint32 timestamp;
 
   if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK)
     goto out;
 
-  meta_cursor_tracker_get_pointer (cursor_tracker, &root_x, &root_y, NULL);
+  meta_cursor_tracker_get_pointer (cursor_tracker, &point, NULL);
 
-  if (root_x != focus_data->pointer_x ||
-      root_y != focus_data->pointer_y)
+  if ((int) point.x != focus_data->pointer_x ||
+      (int) point.y != focus_data->pointer_y)
     {
-      focus_data->pointer_x = root_x;
-      focus_data->pointer_y = root_y;
+      focus_data->pointer_x = point.x;
+      focus_data->pointer_y = point.y;
       return G_SOURCE_CONTINUE;
     }
 
diff --git a/src/meta/meta-cursor-tracker.h b/src/meta/meta-cursor-tracker.h
index 87e408d940..a3b71c4f6a 100644
--- a/src/meta/meta-cursor-tracker.h
+++ b/src/meta/meta-cursor-tracker.h
@@ -50,8 +50,7 @@ CoglTexture   *meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker);
 
 META_EXPORT
 void           meta_cursor_tracker_get_pointer (MetaCursorTracker   *tracker,
-                                                int                 *x,
-                                                int                 *y,
+                                                graphene_point_t    *coords,
                                                 ClutterModifierType *mods);
 
 META_EXPORT
diff --git a/src/wayland/meta-wayland-dnd-surface.c b/src/wayland/meta-wayland-dnd-surface.c
index eb0dc85df0..bdd80f53a2 100644
--- a/src/wayland/meta-wayland-dnd-surface.c
+++ b/src/wayland/meta-wayland-dnd-surface.c
@@ -78,10 +78,11 @@ dnd_surface_find_logical_monitor (MetaWaylandActorSurface *actor_surface)
     meta_backend_get_cursor_tracker (backend);
   MetaMonitorManager *monitor_manager =
      meta_backend_get_monitor_manager (backend);
-  int x, y;
+  graphene_point_t point;
 
-  meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL);
-  return meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y);
+  meta_cursor_tracker_get_pointer (cursor_tracker, &point, NULL);
+  return meta_monitor_manager_get_logical_monitor_at (monitor_manager,
+                                                      point.x, point.y);
 }
 
 static double
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index ea9e82c8f8..35cee5873e 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -2802,7 +2802,7 @@ query_pressed_buttons (MetaWindow *window)
   ClutterModifierType mods;
   int button = 0;
 
-  meta_cursor_tracker_get_pointer (tracker, NULL, NULL, &mods);
+  meta_cursor_tracker_get_pointer (tracker, NULL, &mods);
 
   if (mods & CLUTTER_BUTTON1_MASK)
     button |= 1 << 1;


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