diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-06-02 21:24:10 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-06-02 21:24:10 +0000 |
commit | 48228efe4279dc0f080d0100d60fec5f7c1a9fdb (patch) | |
tree | 7a857f009a0e400b0f0e39f3fa9e3e437a59aa02 | |
parent | 0e6a3ab397b37da0f12263619b292c40d776f076 (diff) | |
parent | 4b41d4f78ce71b60f0d51837cd1b6a1b346d679d (diff) | |
download | gtk+-48228efe4279dc0f080d0100d60fec5f7c1a9fdb.tar.gz |
Merge branch 'wip/carlosg/activation-roundtrip-fix' into 'main'
gdk/wayland: Check the GdkSurface wl_surface before using it for activation
Closes gnome-control-center#1862
See merge request GNOME/gtk!4789
-rw-r--r-- | gdk/wayland/gdkapplaunchcontext-wayland.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gdk/wayland/gdkapplaunchcontext-wayland.c b/gdk/wayland/gdkapplaunchcontext-wayland.c index c8bf5afd25..ed3c4772b1 100644 --- a/gdk/wayland/gdkapplaunchcontext-wayland.c +++ b/gdk/wayland/gdkapplaunchcontext-wayland.c @@ -59,13 +59,17 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context if (display->xdg_activation) { struct xdg_activation_token_v1 *token; + struct wl_event_queue *event_queue; + struct wl_surface *wl_surface = NULL; GdkWaylandSeat *seat; GdkSurface *focus_surface; AppLaunchData app_launch_data = { 0 }; + event_queue = wl_display_create_queue (display->wl_display); + seat = GDK_WAYLAND_SEAT (gdk_display_get_default_seat (GDK_DISPLAY (display))); - focus_surface = gdk_wayland_device_get_focus (gdk_seat_get_keyboard (GDK_SEAT (seat))); token = xdg_activation_v1_get_activation_token (display->xdg_activation); + wl_proxy_set_queue ((struct wl_proxy *) token, event_queue); xdg_activation_token_v1_add_listener (token, &token_listener, @@ -73,16 +77,21 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context xdg_activation_token_v1_set_serial (token, _gdk_wayland_seat_get_last_implicit_grab_serial (seat, NULL), gdk_wayland_seat_get_wl_seat (GDK_SEAT (seat))); + + focus_surface = gdk_wayland_device_get_focus (gdk_seat_get_keyboard (GDK_SEAT (seat))); if (focus_surface) - xdg_activation_token_v1_set_surface (token, - gdk_wayland_surface_get_wl_surface (focus_surface)); + wl_surface = gdk_wayland_surface_get_wl_surface (focus_surface); + if (wl_surface) + xdg_activation_token_v1_set_surface (token, wl_surface); + xdg_activation_token_v1_commit (token); while (app_launch_data.token == NULL) - wl_display_roundtrip (display->wl_display); + wl_display_dispatch_queue (display->wl_display, event_queue); xdg_activation_token_v1_destroy (token); id = app_launch_data.token; + wl_event_queue_destroy (event_queue); } else if (display->gtk_shell_version >= 3) { |