[gtk: 2/3] toplevel-size: Report zero bounds as infinite




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

    toplevel-size: Report zero bounds as infinite
    
    Empty/zero bounds are sent by the Wayland compositor if there are no
    valid bounds to report, e.g. if there are no connected monitors. Report
    this to GTK, which uses this to clamp calculated sizes, as INT_MAX, so
    that clamping isn't done until there are actual valid bounds to clamp
    to.
    
    This fixes clients sometimes shrinking to their minimum size during
    hotplugs or after having suspended the session.

 gdk/gdktoplevelsize.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gdk/gdktoplevelsize.c b/gdk/gdktoplevelsize.c
index 186edb4d9b..b586ff2c62 100644
--- a/gdk/gdktoplevelsize.c
+++ b/gdk/gdktoplevelsize.c
@@ -32,6 +32,9 @@ G_DEFINE_POINTER_TYPE (GdkToplevelSize, gdk_toplevel_size)
 #define UNCONFIGURED_WIDTH 400
 #define UNCONFIGURED_HEIGHT 300
 
+#define DEFAULT_BOUNDS_WIDTH INT_MAX
+#define DEFAULT_BOUNDS_HEIGHT INT_MAX
+
 void
 gdk_toplevel_size_init (GdkToplevelSize *size,
                         int              bounds_width,
@@ -68,8 +71,15 @@ gdk_toplevel_size_get_bounds (GdkToplevelSize *size,
   g_return_if_fail (bounds_width);
   g_return_if_fail (bounds_height);
 
-  *bounds_width = size->bounds_width;
-  *bounds_height = size->bounds_height;
+  if (size->bounds_width > 0)
+    *bounds_width = size->bounds_width;
+  else
+    *bounds_width = DEFAULT_BOUNDS_WIDTH;
+
+  if (size->bounds_height > 0)
+    *bounds_height = size->bounds_height;
+  else
+    *bounds_height = DEFAULT_BOUNDS_HEIGHT;
 }
 
 /**


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