window: Throttle window move grab updates

There is no point in moving a window at the input event refresh rate,
when the end result will only be used once per update, thus, throttle
the move done during grabs to once per stage update.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2233
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2652>
This commit is contained in:
Jonas Ådahl 2022-10-05 14:56:21 +02:00 committed by Marge Bot
parent 11a50fffa2
commit bd6b14a843

View File

@ -132,10 +132,6 @@ static void ensure_mru_position_after (MetaWindow *window,
static void meta_window_unqueue (MetaWindow *window, static void meta_window_unqueue (MetaWindow *window,
MetaQueueType queuebits); MetaQueueType queuebits);
static void update_move (MetaWindow *window,
MetaEdgeResistanceFlags flags,
int x,
int y);
static gboolean should_be_on_all_workspaces (MetaWindow *window); static gboolean should_be_on_all_workspaces (MetaWindow *window);
static void meta_window_flush_calc_showing (MetaWindow *window); static void meta_window_flush_calc_showing (MetaWindow *window);
@ -5830,6 +5826,8 @@ update_move (MetaWindow *window,
display->grab_latest_motion_x = x; display->grab_latest_motion_x = x;
display->grab_latest_motion_y = y; display->grab_latest_motion_y = y;
meta_display_clear_grab_move_resize_later (display);
dx = x - display->grab_anchor_root_x; dx = x - display->grab_anchor_root_x;
dy = y - display->grab_anchor_root_y; dy = y - display->grab_anchor_root_y;
@ -5999,6 +5997,45 @@ update_move (MetaWindow *window,
meta_window_move_frame (window, TRUE, new_x, new_y); meta_window_move_frame (window, TRUE, new_x, new_y);
} }
static gboolean
update_move_cb (gpointer user_data)
{
MetaWindow *window = user_data;
window->display->grab_move_resize_later_id = 0;
update_move (window,
window->display->grab_last_edge_resistance_flags,
window->display->grab_latest_motion_x,
window->display->grab_latest_motion_y);
return G_SOURCE_REMOVE;
}
static void
queue_update_move (MetaWindow *window,
MetaEdgeResistanceFlags flags,
int x,
int y)
{
MetaCompositor *compositor;
MetaLaters *laters;
window->display->grab_latest_motion_x = x;
window->display->grab_latest_motion_y = y;
if (window->display->grab_move_resize_later_id)
return;
compositor = meta_display_get_compositor (window->display);
laters = meta_compositor_get_laters (compositor);
window->display->grab_move_resize_later_id =
meta_laters_add (laters,
META_LATER_BEFORE_REDRAW,
update_move_cb,
window, NULL);
}
static void static void
update_resize (MetaWindow *window, update_resize (MetaWindow *window,
MetaEdgeResistanceFlags flags, MetaEdgeResistanceFlags flags,
@ -6288,7 +6325,7 @@ meta_window_handle_mouse_grab_op_event (MetaWindow *window,
meta_display_check_threshold_reached (window->display, x, y); meta_display_check_threshold_reached (window->display, x, y);
if (meta_grab_op_is_moving (window->display->grab_op)) if (meta_grab_op_is_moving (window->display->grab_op))
{ {
update_move (window, flags, x, y); queue_update_move (window, flags, x, y);
} }
else if (meta_grab_op_is_resizing (window->display->grab_op)) else if (meta_grab_op_is_resizing (window->display->grab_op))
{ {