[gtk/gtk-4-6: 1/3] surface/wayland: Handle no current monitor when calculating bounds
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-4-6: 1/3] surface/wayland: Handle no current monitor when calculating bounds
- Date: Thu, 6 Oct 2022 10:42:37 +0000 (UTC)
commit 0b312d878ca464eab3311b1335a44d14ede6d436
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 | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 0b3315075e..f7c98b5e20 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -1395,7 +1395,6 @@ configure_toplevel_geometry (GdkSurface *surface)
GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
GdkDisplay *display = gdk_surface_get_display (surface);
GdkMonitor *monitor;
- GdkRectangle monitor_geometry;
int bounds_width, bounds_height;
GdkToplevelSize size;
GdkToplevelLayout *layout;
@@ -1403,10 +1402,20 @@ configure_toplevel_geometry (GdkSurface *surface)
GdkSurfaceHints mask;
monitor = g_list_model_get_item (gdk_display_get_monitors (display), 0);
- gdk_monitor_get_geometry (monitor, &monitor_geometry);
- g_object_unref (monitor);
- bounds_width = monitor_geometry.width;
- bounds_height = monitor_geometry.height;
+ if (monitor)
+ {
+ GdkRectangle monitor_geometry;
+
+ gdk_monitor_get_geometry (monitor, &monitor_geometry);
+ g_object_unref (monitor);
+ bounds_width = monitor_geometry.width;
+ bounds_height = monitor_geometry.height;
+ }
+ else
+ {
+ bounds_width = 0;
+ bounds_height = 0;
+ }
gdk_toplevel_size_init (&size, bounds_width, bounds_height);
gdk_toplevel_notify_compute_size (GDK_TOPLEVEL (surface), &size);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]