compositor: Set priv->current_drag before calling meta_window_drag_begin()

priv->current_drag is the property that
meta_compositor_get_current_window_drag() and therefore also
meta_display_is_grabbed() bases its check on. We use
meta_display_is_grabbed() to select which cursor to use (window cursor
vs root cursor) when updating the cursor in MetaCursorTracker.

Since meta_window_drag_begin() sets a new cursor, and therefore triggers the
cursor tracker to update the current visible cursor, we should set
priv->current_drag before the call to meta_window_drag_begin(). This makes
sure the cursor tracker sees that there's a window drag and changes the
cursor right away when the window drag begins (instead of doing so on
subsequent pointer events).

Fixes: 525ed1166c ("wayland/pointer: Unset current surface during window drags")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3630>
This commit is contained in:
Jonas Dreßler 2024-03-01 23:10:56 +01:00 committed by Marge Bot
parent dcea30338c
commit e9866eee0f

View File

@ -1586,12 +1586,16 @@ meta_compositor_drag_window (MetaCompositor *compositor,
if (pos_hint) if (pos_hint)
meta_window_drag_set_position_hint (window_drag, pos_hint); meta_window_drag_set_position_hint (window_drag, pos_hint);
if (!meta_window_drag_begin (window_drag, device, sequence, timestamp))
return FALSE;
g_signal_connect (window_drag, "ended",
G_CALLBACK (on_window_drag_ended), compositor);
priv->current_drag = g_steal_pointer (&window_drag); priv->current_drag = g_steal_pointer (&window_drag);
if (!meta_window_drag_begin (priv->current_drag, device, sequence, timestamp))
{
g_clear_object (&priv->current_drag);
return FALSE;
}
g_signal_connect (priv->current_drag, "ended",
G_CALLBACK (on_window_drag_ended), compositor);
return TRUE; return TRUE;
} }