From 1e2d72144a8135e91cbccd963adc3efa261ec6e8 Mon Sep 17 00:00:00 2001 From: Alberto Fanjul Date: Thu, 23 Apr 2020 11:43:24 +0200 Subject: [PATCH] Prevent crashes on gdk wayland implementation using offscreen windows --- gdk/wayland/gdkwindow-wayland.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index 7a89ece98d..cc5e98e5f3 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -2535,12 +2535,17 @@ calculate_moved_to_rect_result (GdkWindow *window, gboolean *flipped_x, gboolean *flipped_y) { - GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); + GdkWindowImplWayland *impl; GdkWindow *parent; gint window_x, window_y; gint window_width, window_height; GdkRectangle best_rect; + g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window)); + g_return_if_fail (GDK_IS_WINDOW_IMPL_WAYLAND (window->impl)); + + impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); + parent = translate_from_real_parent_window_geometry (window, &x, &y); *final_rect = (GdkRectangle) { .x = x, @@ -5328,10 +5333,16 @@ void gdk_wayland_window_restore_shortcuts (GdkWindow *window, GdkSeat *gdk_seat) { - GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); - struct wl_seat *seat = gdk_wayland_seat_get_wl_seat (gdk_seat); + GdkWindowImplWayland *impl; + struct wl_seat *seat; struct zwp_keyboard_shortcuts_inhibitor_v1 *inhibitor; + g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window)); + g_return_if_fail (GDK_IS_WINDOW_IMPL_WAYLAND (window->impl)); + + impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); + seat = gdk_wayland_seat_get_wl_seat (gdk_seat); + inhibitor = gdk_wayland_window_get_inhibitor (impl, seat); if (inhibitor == NULL) return; /* Not inhibitted */