From 18535928e789b6b4e2975f143c659a4cf45fe39a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 21 Oct 2022 19:36:59 +0200 Subject: [PATCH] wayland: Add device/sequence out parameters getting wayland grab info This information will become necessary for window move/resize ops. Part-of: --- src/wayland/meta-wayland-activation.c | 3 ++- src/wayland/meta-wayland-gtk-shell.c | 3 ++- src/wayland/meta-wayland-seat.c | 29 +++++++++++++++++++++------ src/wayland/meta-wayland-seat.h | 14 +++++++------ src/wayland/meta-wayland-xdg-shell.c | 9 ++++++--- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/wayland/meta-wayland-activation.c b/src/wayland/meta-wayland-activation.c index ae4596bbd..05a26e6d3 100644 --- a/src/wayland/meta-wayland-activation.c +++ b/src/wayland/meta-wayland-activation.c @@ -308,7 +308,8 @@ token_can_activate (MetaXdgActivationToken *token) return meta_wayland_seat_get_grab_info (seat, token->surface, token->serial, - FALSE, NULL, NULL); + FALSE, + NULL, NULL, NULL, NULL); } static gboolean diff --git a/src/wayland/meta-wayland-gtk-shell.c b/src/wayland/meta-wayland-gtk-shell.c index 1cc6093e7..f57768a22 100644 --- a/src/wayland/meta-wayland-gtk-shell.c +++ b/src/wayland/meta-wayland-gtk-shell.c @@ -235,7 +235,8 @@ gtk_surface_titlebar_gesture (struct wl_client *client, if (!window) return; - if (!meta_wayland_seat_get_grab_info (seat, surface, serial, FALSE, &x, &y)) + if (!meta_wayland_seat_get_grab_info (seat, surface, serial, FALSE, + NULL, NULL, &x, &y)) return; switch (gesture) diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c index 4aa60eefa..7f1a24c48 100644 --- a/src/wayland/meta-wayland-seat.c +++ b/src/wayland/meta-wayland-seat.c @@ -433,12 +433,14 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat, } gboolean -meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat, - MetaWaylandSurface *surface, - uint32_t serial, - gboolean require_pressed, - gfloat *x, - gfloat *y) +meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat, + MetaWaylandSurface *surface, + uint32_t serial, + gboolean require_pressed, + ClutterInputDevice **device_out, + ClutterEventSequence **sequence_out, + float *x, + float *y) { MetaWaylandCompositor *compositor; MetaWaylandTabletSeat *tablet_seat; @@ -456,6 +458,11 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat, serial); if (sequence) { + if (device_out) + *device_out = seat->pointer->device; + if (sequence_out) + *sequence_out = sequence; + meta_wayland_touch_get_press_coords (seat->touch, sequence, x, y); return TRUE; } @@ -466,6 +473,11 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat, if ((!require_pressed || seat->pointer->button_count > 0) && meta_wayland_pointer_can_grab_surface (seat->pointer, surface, serial)) { + if (device_out) + *device_out = seat->pointer->device; + if (sequence_out) + *sequence_out = NULL; + if (x) *x = seat->pointer->grab_x; if (y) @@ -482,6 +494,11 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat, if ((!require_pressed || tool->button_count > 0) && meta_wayland_tablet_tool_can_grab_surface (tool, surface, serial)) { + if (device_out) + *device_out = tool->device; + if (sequence_out) + *sequence_out = NULL; + if (x) *x = tool->grab_x; if (y) diff --git a/src/wayland/meta-wayland-seat.h b/src/wayland/meta-wayland-seat.h index 57937b936..852d601b8 100644 --- a/src/wayland/meta-wayland-seat.h +++ b/src/wayland/meta-wayland-seat.h @@ -67,12 +67,14 @@ gboolean meta_wayland_seat_handle_event (MetaWaylandSeat *seat, void meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat, MetaWaylandSurface *surface); -gboolean meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat, - MetaWaylandSurface *surface, - uint32_t serial, - gboolean require_pressed, - gfloat *x, - gfloat *y); +gboolean meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat, + MetaWaylandSurface *surface, + uint32_t serial, + gboolean require_pressed, + ClutterInputDevice **device_out, + ClutterEventSequence **sequence_out, + float *x, + float *y); gboolean meta_wayland_seat_can_popup (MetaWaylandSeat *seat, uint32_t serial); diff --git a/src/wayland/meta-wayland-xdg-shell.c b/src/wayland/meta-wayland-xdg-shell.c index 907d5139a..13fec6a7f 100644 --- a/src/wayland/meta-wayland-xdg-shell.c +++ b/src/wayland/meta-wayland-xdg-shell.c @@ -299,7 +299,8 @@ xdg_toplevel_show_window_menu (struct wl_client *client, if (!window) return; - if (!meta_wayland_seat_get_grab_info (seat, surface, serial, FALSE, NULL, NULL)) + if (!meta_wayland_seat_get_grab_info (seat, surface, serial, FALSE, + NULL, NULL, NULL, NULL)) return; monitor_scale = meta_window_wayland_get_geometry_scale (window); @@ -323,7 +324,8 @@ xdg_toplevel_move (struct wl_client *client, if (!window) return; - if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y)) + if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, + NULL, NULL, &x, &y)) return; meta_wayland_surface_begin_grab_op (surface, seat, META_GRAB_OP_MOVING, x, y); @@ -372,7 +374,8 @@ xdg_toplevel_resize (struct wl_client *client, if (!window->has_resize_func) return; - if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, &x, &y)) + if (!meta_wayland_seat_get_grab_info (seat, surface, serial, TRUE, + NULL, NULL, &x, &y)) return; grab_op = grab_op_for_xdg_toplevel_resize_edge (edges);