From 022347fa85c4244e519e0c3afbee81ca4834617d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 19 Jan 2024 13:05:14 +0100 Subject: [PATCH 1/2] gdk/wayland: Avoid activation paths with no seats When a toplevel is focused programmatically and there is no underlying seat, we cannot attempt to focus it with no focus to be obtained, nor serials serials to use. Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6335 --- gdk/wayland/gdktoplevel-wayland.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gdk/wayland/gdktoplevel-wayland.c b/gdk/wayland/gdktoplevel-wayland.c index c3a0749d55..66d11848ca 100644 --- a/gdk/wayland/gdktoplevel-wayland.c +++ b/gdk/wayland/gdktoplevel-wayland.c @@ -2155,15 +2155,14 @@ gdk_wayland_toplevel_focus (GdkToplevel *toplevel, GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (toplevel); GdkDisplay *display = gdk_surface_get_display (surface); GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display); + GdkWaylandSeat *seat = + GDK_WAYLAND_SEAT (gdk_display_get_default_seat (display)); gchar *startup_id = NULL; startup_id = g_steal_pointer (&display_wayland->startup_notification_id); - if (display_wayland->xdg_activation) + if (seat && display_wayland->xdg_activation) { - GdkWaylandSeat *seat = - GDK_WAYLAND_SEAT (gdk_display_get_default_seat (display)); - /* If the focus request does not have a startup ID associated, get a * new token to activate the window. */ From 070f3a61ac9dc66f4204188dc04fe540fa74ed65 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 19 Jan 2024 13:19:11 +0100 Subject: [PATCH 2/2] gdk/wayland: Bail out on titlebar gestures with no seat This API might be called programmatically at a time that there's no seats, handle this situation by returning FALSE in the GDK API. Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/6335 --- gdk/wayland/gdktoplevel-wayland.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdk/wayland/gdktoplevel-wayland.c b/gdk/wayland/gdktoplevel-wayland.c index 66d11848ca..5125a283a9 100644 --- a/gdk/wayland/gdktoplevel-wayland.c +++ b/gdk/wayland/gdktoplevel-wayland.c @@ -1973,8 +1973,10 @@ gdk_wayland_toplevel_titlebar_gesture (GdkToplevel *toplevel, return FALSE; seat = gdk_display_get_default_seat (surface->display); - wl_seat = gdk_wayland_seat_get_wl_seat (seat); + if (!seat) + return FALSE; + wl_seat = gdk_wayland_seat_get_wl_seat (seat); serial = _gdk_wayland_seat_get_last_implicit_grab_serial (GDK_WAYLAND_SEAT (seat), NULL); gtk_surface1_titlebar_gesture (wayland_toplevel->display_server.gtk_surface,