From dfeb6680594bcfc6952ab108a2a67d744e72508d Mon Sep 17 00:00:00 2001 From: somiaj Date: Fri, 9 Jul 2021 20:47:07 -0600 Subject: [PATCH] FvwmButtons: Shrink windows when honoring Hints. When Swallowing a window and honoring 'Hints', shrink the window to fit the button (instead of growing it) so the window fits inside the button and isn't cut off. Fallback to growing the window if shrinking makes it smaller than min size. Fixes #573 --- modules/FvwmButtons/misc.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/FvwmButtons/misc.c b/modules/FvwmButtons/misc.c index 1ecbc71fb..8e1d94ff6 100644 --- a/modules/FvwmButtons/misc.c +++ b/modules/FvwmButtons/misc.c @@ -148,20 +148,20 @@ void ConstrainSize (XSizeHints *hints, int *widthp, int *heightp) if (minAspectX * dheight > minAspectY * dwidth) { delta = makemult( - minAspectX * dheight / minAspectY - dwidth, - xinc); - if (dwidth + delta <= maxWidth) + dheight - minAspectY * dwidth / minAspectX, + yinc); + if (dheight - delta >= minHeight) { - dwidth += delta; + dheight -= delta; } else { delta = makemult( - dheight - minAspectY*dwidth/minAspectX, - yinc); - if (dheight - delta >= minHeight) + minAspectX * dheight / minAspectY - + dwidth, xinc); + if (dwidth + delta <= maxWidth) { - dheight -= delta; + dwidth += delta; } } } @@ -169,20 +169,20 @@ void ConstrainSize (XSizeHints *hints, int *widthp, int *heightp) if (maxAspectX * dheight < maxAspectY * dwidth) { delta = makemult( - dwidth * maxAspectY / maxAspectX - dheight, - yinc); - if (dheight + delta <= maxHeight) + dwidth - maxAspectX * dheight / maxAspectY, + xinc); + if (dwidth - delta >= minWidth) { - dheight += delta; + dwidth -= delta; } else { delta = makemult( - dwidth - maxAspectX*dheight/maxAspectY, - xinc); - if (dwidth - delta >= minWidth) + dwidth * maxAspectY / maxAspectX - + dheight, yinc); + if (dheight + delta <= maxHeight) { - dwidth -= delta; + dheight += delta; } } }