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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
This commit is contained in:
Carlos Garnacho 2022-09-29 17:13:56 +02:00 committed by Marge Bot
parent 43081fc8bd
commit 5e4d69c3a8
2 changed files with 35 additions and 20 deletions

View File

@ -6668,10 +6668,10 @@ meta_window_is_ancestor_of_transient (MetaWindow *window,
* return root coordinates where pointer ended up. * return root coordinates where pointer ended up.
*/ */
static gboolean static gboolean
warp_grab_pointer (MetaWindow *window, warp_grab_pointer (MetaWindow *window,
MetaGrabOp grab_op, MetaGrabOp grab_op,
int *x, int *x,
int *y) int *y)
{ {
MetaRectangle rect; MetaRectangle rect;
MetaRectangle display_rect = { 0 }; MetaRectangle display_rect = { 0 };
@ -6730,7 +6730,7 @@ warp_grab_pointer (MetaWindow *window,
return TRUE; return TRUE;
} }
void gboolean
meta_window_begin_grab_op (MetaWindow *window, meta_window_begin_grab_op (MetaWindow *window,
MetaGrabOp op, MetaGrabOp op,
gboolean frame_action, gboolean frame_action,
@ -6738,18 +6738,33 @@ meta_window_begin_grab_op (MetaWindow *window,
{ {
int x, y; int x, y;
warp_grab_pointer (window, if ((op & META_GRAB_OP_KEYBOARD_MOVING) == META_GRAB_OP_KEYBOARD_MOVING)
op, &x, &y); {
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, device = clutter_seat_get_pointer (seat);
window, clutter_seat_query_state (seat, device, NULL, &pos, NULL);
op, x = pos.x;
FALSE, y = pos.y;
frame_action, }
0 /* button */,
0, return meta_display_begin_grab_op (window->display,
timestamp, window,
x, y); op,
FALSE,
frame_action,
0 /* button */,
0,
timestamp,
x, y);
} }
void void

View File

@ -409,10 +409,10 @@ void meta_window_get_work_area_all_monitors (MetaWindow *window,
MetaRectangle *area); MetaRectangle *area);
META_EXPORT META_EXPORT
void meta_window_begin_grab_op (MetaWindow *window, gboolean meta_window_begin_grab_op (MetaWindow *window,
MetaGrabOp op, MetaGrabOp op,
gboolean frame_action, gboolean frame_action,
guint32 timestamp); guint32 timestamp);
META_EXPORT META_EXPORT
gboolean meta_window_can_maximize (MetaWindow *window); gboolean meta_window_can_maximize (MetaWindow *window);