From 5e4d69c3a8f889dc999c375c7c8e080d579b915a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 29 Sep 2022 17:13:56 +0200 Subject: [PATCH] core: Make meta_window_begin_grab_op() more generic Currently, it is thought out to be called with META_GRAB_OP_KEYBOARD* grab op parameters. Make it more generic so it can also be called for pointer operations (avoiding pointer warping in that situation). Part-of: --- src/core/window.c | 47 +++++++++++++++++++++++++++++++---------------- src/meta/window.h | 8 ++++---- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 3385be8fd..d35c7709b 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -6668,10 +6668,10 @@ meta_window_is_ancestor_of_transient (MetaWindow *window, * return root coordinates where pointer ended up. */ static gboolean -warp_grab_pointer (MetaWindow *window, - MetaGrabOp grab_op, - int *x, - int *y) +warp_grab_pointer (MetaWindow *window, + MetaGrabOp grab_op, + int *x, + int *y) { MetaRectangle rect; MetaRectangle display_rect = { 0 }; @@ -6730,7 +6730,7 @@ warp_grab_pointer (MetaWindow *window, return TRUE; } -void +gboolean meta_window_begin_grab_op (MetaWindow *window, MetaGrabOp op, gboolean frame_action, @@ -6738,18 +6738,33 @@ meta_window_begin_grab_op (MetaWindow *window, { int x, y; - warp_grab_pointer (window, - op, &x, &y); + if ((op & META_GRAB_OP_KEYBOARD_MOVING) == META_GRAB_OP_KEYBOARD_MOVING) + { + warp_grab_pointer (window, op, &x, &y); + } + else + { + MetaBackend *backend = backend_from_window (window); + ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); + ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend); + ClutterInputDevice *device; + graphene_point_t pos; - meta_display_begin_grab_op (window->display, - window, - op, - FALSE, - frame_action, - 0 /* button */, - 0, - timestamp, - x, y); + device = clutter_seat_get_pointer (seat); + clutter_seat_query_state (seat, device, NULL, &pos, NULL); + x = pos.x; + y = pos.y; + } + + return meta_display_begin_grab_op (window->display, + window, + op, + FALSE, + frame_action, + 0 /* button */, + 0, + timestamp, + x, y); } void diff --git a/src/meta/window.h b/src/meta/window.h index d5d07a061..20b2e8831 100644 --- a/src/meta/window.h +++ b/src/meta/window.h @@ -409,10 +409,10 @@ void meta_window_get_work_area_all_monitors (MetaWindow *window, MetaRectangle *area); META_EXPORT -void meta_window_begin_grab_op (MetaWindow *window, - MetaGrabOp op, - gboolean frame_action, - guint32 timestamp); +gboolean meta_window_begin_grab_op (MetaWindow *window, + MetaGrabOp op, + gboolean frame_action, + guint32 timestamp); META_EXPORT gboolean meta_window_can_maximize (MetaWindow *window);