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.
*/
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

View File

@ -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);