surface/wayland: Handle no current monitor when calculating bounds
authorJonas Ådahl <jadahl@gmail.com>
Fri, 30 Sep 2022 07:30:30 +0000 (09:30 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Thu, 6 Oct 2022 08:42:27 +0000 (10:42 +0200)
We shouldn't assume there is always a monitor to derive bounds from.
If there is no monitor, pass empty bounds, as this matches what
xdg_toplevel.configure_bounds do in this case.

(cherry picked from commit 148c1336745a043a9660da6c4734ed905c628130)

gdk/wayland/gdksurface-wayland.c

index 86392923e58ba6a4c82de4459381fe75e4d2fea6..225d380536a27b4bb40eaef1d820cdc91466a881 100644 (file)
@@ -1419,10 +1419,18 @@ configure_toplevel_geometry (GdkSurface *surface)
       GdkRectangle monitor_geometry;
 
       monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
-      gdk_monitor_get_geometry (monitor, &monitor_geometry);
-      bounds_width = monitor_geometry.width;
-      bounds_height = monitor_geometry.height;
-      g_object_unref (monitor);
+      if (monitor)
+        {
+          gdk_monitor_get_geometry (monitor, &monitor_geometry);
+          bounds_width = monitor_geometry.width;
+          bounds_height = monitor_geometry.height;
+          g_object_unref (monitor);
+        }
+      else
+        {
+          bounds_width = 0;
+          bounds_height = 0;
+        }
     }
 
   gdk_toplevel_size_init (&size, bounds_width, bounds_height);