[gtk/gtk-4-8: 1/3] surface/wayland: Handle no current monitor when calculating bounds




commit 79eab08797e1121f0fe7d84f570d28055d3f12b0
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Sep 30 09:30:30 2022 +0200

    surface/wayland: Handle no current monitor when calculating bounds
    
    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 | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 86392923e5..225d380536 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]