From 4313fad15cf7c34711e00a282dbc1d6c4db0f7aa Mon Sep 17 00:00:00 2001 From: somiaj Date: Sat, 19 Jun 2021 17:50:58 -0600 Subject: [PATCH] FvwmPager: Snap small windows to page boundaries. FvwmPager windows that are smaller than the minimum size dimensions are set to the minimum size length. This can make windows appear in incorrect positions since their size is relatively larger than other windows and the page size. This makes it so small windows near a page boundary will snap to the boundary and not appear they are on the wrong page. Fixes #541. --- modules/FvwmPager/x_pager.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/FvwmPager/x_pager.c b/modules/FvwmPager/x_pager.c index 538a4ad06..3b5aa7e87 100644 --- a/modules/FvwmPager/x_pager.c +++ b/modules/FvwmPager/x_pager.c @@ -226,8 +226,35 @@ static rectangle CalcGeom(PagerWindow *t, bool is_icon) fvwmrec_to_pager(&rec, is_icon); - rec.width = max(MinSize, rec.width); - rec.height = max(MinSize, rec.height); + /* Set geometry to MinSize and snap to page boundary if needed */ + if (rec.width < MinSize) + { + int page_w = desk_w; + if (is_icon) + page_w = icon.width; + page_w = page_w / m->virtual_scr.VxPages; + + rec.width = MinSize; + if (rec.x > page_w - MinSize && + (rec.x + rec.width)%page_w < MinSize) + { + rec.x = ((rec.x / page_w) + 1)*page_w - MinSize + 1; + } + } + if (rec.height < MinSize) + { + int page_h = desk_h; + if (is_icon) + page_h = icon.height; + page_h = page_h / m->virtual_scr.VyPages; + + rec.height = MinSize; + if (rec.y > page_h - MinSize && + (rec.y + rec.height)%page_h < MinSize) + { + rec.y = ((rec.y / page_h) + 1)*page_h - MinSize + 1; + } + } return rec; }