Merge branch 'wip/headless-infinite-bounds-4-8' into 'gtk-4-8'

[4.8] Fix shrinking windows on suspend/resume

See merge request GNOME/gtk!5090
This commit is contained in:
Matthias Clasen 2022-10-06 10:42:51 +00:00
commit 8070cfd173
2 changed files with 24 additions and 6 deletions

View File

@ -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;
}
/**

View 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);