From e9866eee0fa2afd3da65a8db0b6aa6e0bce009c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Fri, 1 Mar 2024 23:10:56 +0100 Subject: [PATCH] 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: --- src/compositor/compositor.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index 7fb104763..7068fdaa4 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -1586,12 +1586,16 @@ meta_compositor_drag_window (MetaCompositor *compositor, if (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); + + 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; }