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
This commit is contained in:
Carlos Garnacho 2020-07-13 12:06:12 +02:00
parent 6c5bba94fd
commit 7bb3fe25aa
8 changed files with 25 additions and 31 deletions

View File

@ -457,24 +457,16 @@ meta_cursor_tracker_update_position (MetaCursorTracker *tracker,
void void
meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker, meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker,
int *x, graphene_point_t *coords,
int *y,
ClutterModifierType *mods) ClutterModifierType *mods)
{ {
ClutterSeat *seat; ClutterSeat *seat;
ClutterInputDevice *cdevice; ClutterInputDevice *cdevice;
graphene_point_t point;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
cdevice = clutter_seat_get_pointer (seat); cdevice = clutter_seat_get_pointer (seat);
clutter_input_device_get_coords (cdevice, NULL, &point); clutter_seat_query_state (seat, cdevice, NULL, coords, mods);
if (x)
*x = point.x;
if (y)
*y = point.y;
if (mods)
*mods = clutter_input_device_get_modifier_state (cdevice);
} }
void void

View File

@ -178,10 +178,11 @@ meta_backend_native_get_current_logical_monitor (MetaBackend *backend)
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
MetaMonitorManager *monitor_manager = MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend); meta_backend_get_monitor_manager (backend);
int x, y; graphene_point_t point;
meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL); meta_cursor_tracker_get_pointer (cursor_tracker, &point, NULL);
return meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y); return meta_monitor_manager_get_logical_monitor_at (monitor_manager,
point.x, point.y);
} }
static void static void

View File

@ -677,7 +677,7 @@ meta_backend_x11_get_current_logical_monitor (MetaBackend *backend)
MetaBackendX11 *x11 = META_BACKEND_X11 (backend); MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11); MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
MetaCursorTracker *cursor_tracker; MetaCursorTracker *cursor_tracker;
int x, y; graphene_point_t point;
MetaMonitorManager *monitor_manager; MetaMonitorManager *monitor_manager;
MetaLogicalMonitor *logical_monitor; MetaLogicalMonitor *logical_monitor;
@ -685,10 +685,11 @@ meta_backend_x11_get_current_logical_monitor (MetaBackend *backend)
return priv->cached_current_logical_monitor; return priv->cached_current_logical_monitor;
cursor_tracker = meta_backend_get_cursor_tracker (backend); 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); monitor_manager = meta_backend_get_monitor_manager (backend);
logical_monitor = 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) if (!logical_monitor && monitor_manager->logical_monitors)
logical_monitor = monitor_manager->logical_monitors->data; logical_monitor = monitor_manager->logical_monitors->data;

View File

@ -3705,18 +3705,18 @@ meta_display_get_pointer_window (MetaDisplay *display,
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
MetaWindow *window; MetaWindow *window;
int x, y; graphene_point_t point;
if (not_this_one) if (not_this_one)
meta_topic (META_DEBUG_FOCUS, meta_topic (META_DEBUG_FOCUS,
"Focusing mouse window excluding %s\n", not_this_one->desc); "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, window = meta_stack_get_default_focus_window_at_point (display->stack,
workspace_manager->active_workspace, workspace_manager->active_workspace,
not_this_one, not_this_one,
x, y); point.x, point.y);
return window; return window;
} }

View File

@ -8183,19 +8183,19 @@ window_focus_on_pointer_rest_callback (gpointer data)
MetaDisplay *display = window->display; MetaDisplay *display = window->display;
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
int root_x, root_y; graphene_point_t point;
guint32 timestamp; guint32 timestamp;
if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK) if (meta_prefs_get_focus_mode () == G_DESKTOP_FOCUS_MODE_CLICK)
goto out; 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 || if ((int) point.x != focus_data->pointer_x ||
root_y != focus_data->pointer_y) (int) point.y != focus_data->pointer_y)
{ {
focus_data->pointer_x = root_x; focus_data->pointer_x = point.x;
focus_data->pointer_y = root_y; focus_data->pointer_y = point.y;
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }

View File

@ -50,8 +50,7 @@ CoglTexture *meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker);
META_EXPORT META_EXPORT
void meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker, void meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker,
int *x, graphene_point_t *coords,
int *y,
ClutterModifierType *mods); ClutterModifierType *mods);
META_EXPORT META_EXPORT

View File

@ -78,10 +78,11 @@ dnd_surface_find_logical_monitor (MetaWaylandActorSurface *actor_surface)
meta_backend_get_cursor_tracker (backend); meta_backend_get_cursor_tracker (backend);
MetaMonitorManager *monitor_manager = MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend); meta_backend_get_monitor_manager (backend);
int x, y; graphene_point_t point;
meta_cursor_tracker_get_pointer (cursor_tracker, &x, &y, NULL); meta_cursor_tracker_get_pointer (cursor_tracker, &point, NULL);
return meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y); return meta_monitor_manager_get_logical_monitor_at (monitor_manager,
point.x, point.y);
} }
static double static double

View File

@ -2802,7 +2802,7 @@ query_pressed_buttons (MetaWindow *window)
ClutterModifierType mods; ClutterModifierType mods;
int button = 0; 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) if (mods & CLUTTER_BUTTON1_MASK)
button |= 1 << 1; button |= 1 << 1;