From b36258f2042d610e59a04dde7eaad0aa37a249bf Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sun, 19 Jan 2020 01:56:35 +0200 Subject: [PATCH] gdk: Subtract base size when checking aspect ratio According to the ICCCM spec [1], one should subtract the base size from the window size before checking that the aspect ratio falls in range. This change fixes shrinking Firefox Picture-in-Picture windows when running KDE Plasma (with KWin as the window manager). [1] https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.3 --- gdk/gdksurface.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 8424576238..dbc709bea6 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -1726,6 +1726,16 @@ gdk_surface_constrain_size (GdkGeometry *geometry, { gint delta; + if (flags & GDK_HINT_BASE_SIZE) + { + width -= base_width; + height -= base_height; + min_width -= base_width; + min_height -= base_height; + max_width -= base_width; + max_height -= base_height; + } + if (geometry->min_aspect * height > width) { delta = FLOOR (height - width / geometry->min_aspect, yinc); @@ -1751,6 +1761,12 @@ gdk_surface_constrain_size (GdkGeometry *geometry, height += delta; } } + + if (flags & GDK_HINT_BASE_SIZE) + { + width += base_width; + height += base_height; + } } #undef FLOOR