On Sat, Nov 27, 2021 at 02:44:07PM -0700, Jaimos Skriletz wrote:
> On Sat, Nov 27, 2021 at 1:59 PM Dominik Vogt <dominik.v...@gmx.de> wrote:
> >
> > From commit 601c5c294a6a48fd402fbfca02b62142796167eb
> >
> > >    * Improved use of sizehints to set both minimum window size, and to
> > >       preserve aspect ratio when resizing the pager. The aspect ratio is
> > >       set to the initial size of the window unless the user sets window
> > >       size with the Geometry option.
> >
> > x_pager.c:
> > > +         sizehints.flags = (sizehints.flags | PAspect);
> > > +         sizehints.min_aspect.x = sizehints.max_aspect.x = window_w;
> > > +         sizehints.min_aspect.y = sizehints.max_aspect.y = window_h;
> >
> > I'm against this change.
> >
> >  1) It breaks sliding the pager from a panel button.
> >  2) fvwm's module were always supposed to deal with any size, even
> >     1x1 or 65535x65535.

> Not strictly true, there are some size increment hints that force the
> pager's size to be an integer multiple of the number of pages shown,
> so each page has the same number of pixels. So there were already some
> restrictions on the sizes it could be.

Right.  The whole sizehints can be removed, except the width,
height, usposition and gravity.  All they do is impose unnecessary
limitations:

 * Nobody cares if the width is not a multiple of the number of
   pages.  If the pager is 299 pixels wide and there are three
   pages, then two of them have 100 pixels assigned and one has 99.
   So what?

 * Base size:  If the pager gets unusable below a certain size,
   then do not make it smaller than that if you don't like it.  I
   do resize modules to a very small size to get them out of the
   way sometimes (mostly FvwmButtons).

Twenty years ago I personally removed all limitations on pager
size.  It seems I missed the standalone limitations because I only
have one in the pager.  FvwmPager is abolutely happy with any
geometry (although it doesn't look good if it doesn't have at
least two pixels per page).  It still displays useful information
even if it's only one pixel high.  :-)

> >  3) It makes it virtually impossible to have the pager fill the whole
> >     allocated area inside FvwmButtons.
>
> Can FvwmButtons be fixed to better deal with this?

1) No.  Sliding breaks aspect ratio by design.

3) It's not FvwmButton's fault, it just honours the requersted
aspect ratio because it has to.  Programs might behave badly if
their hints are ignored.  Fvwm's modules are always fine if their
hints are ignored because they are written to be fine.

> > I see no benefit in these new limits.  Nobody resizes the pager
> > manually, and insde FvwmButtons it's really harmful.  Can I remove
> > this please?  (See attached patch.)
>
> This can currently be disabled by proving an initial Geometry (though
> it needs to be bigger than some minimum size I recall like 100x100)

That's the value in the sizehints, but fvwm ignores that anyway.
To get the initial size it looks at the real window size, not at
the hints.

In reality it's only 1 pixel per displayed page, and even that's
unnecessary.  The drawing and page management code can deal with
pages that have not even a single pixel allocated to them.

Let's remove the lower limit too.

> then FvwmButtons will resize to fit without preserving aspect ratio.

FvwmButtons does honour the aspect ratio (see above).

> At the time we chose to have it be disabled via just setting a
> geometry string vs having an additional option to turn preserving
> aspect ratio on/off. I would rather have an option to allow users to
> toggle this vs just disable it.

I disagree.  From experience, using the aspect ratio always annoys
the user when resizing a window.  It's fine for initial size
calcualtions, but after that, leave it to the user.  There are
rare exceptions like video players.  It also causes uncommon
problems like with sliding, swallowing in FvwmButtons, or using
"maximize grow grow" in a script.

Imposing limitations on the use of fvwm's modules is
not the fvwm way of doing things.  FvwmPager is capable of dealing
with any geometry, like all other modules.

New patch attached -> no problem with 1x1 pixels even when the
desktop is 50x50.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt
From 565d878e776ca2cc21d89c1ff05a6c9e36f5cf57 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <dominik.v...@gmx.de>
Date: Sat, 27 Nov 2021 21:57:29 +0100
Subject: [PATCH] Remove size and resize limitation from FvwmPager.

The limits are unnecessary, and the aspect ratio gives FvwmButtons
a hard time to accomodate the pager when swallowed.
---
 modules/FvwmPager/x_pager.c | 42 +++++++++++--------------------------
 1 file changed, 12 insertions(+), 30 deletions(-)

diff --git a/modules/FvwmPager/x_pager.c b/modules/FvwmPager/x_pager.c
index 4718cd56..b2f22a62 100644
--- a/modules/FvwmPager/x_pager.c
+++ b/modules/FvwmPager/x_pager.c
@@ -122,7 +122,7 @@ Window icon_win;	       /* icon window */

 static int MyVx, MyVy;		/* copy of Scr.Vx/y for drag logic */

-static void adjust_for_sizehints(int, int, bool);
+static void adjust_for_sizehints(int, int);
 static rectangle CalcGeom(PagerWindow *, bool);
 static rectangle set_vp_size_and_loc(void);
 static void fvwmrec_to_pager(rectangle *, bool);
@@ -401,7 +401,7 @@ void draw_desk_background(int i, int page_w, int page_h)
 char *pager_name = "Fvwm Pager";
 XSizeHints sizehints =
 {
-	(PMinSize | PResizeInc | PBaseSize | PWinGravity), /* flags */
+	(PWinGravity),		/* flags */
 	0, 0, 100, 100,		/* x, y, width and height (legacy) */
 	1, 1,			/* Min width and height */
 	0, 0,			/* Max width and height */
@@ -446,33 +446,20 @@ void initialize_balloon_window(void)
  * should get added to a clean up TODO at some point.
  */
 static void
-adjust_for_sizehints(int VxPages, int VyPages, bool check_aspect)
+adjust_for_sizehints(int VxPages, int VyPages)
 {
-	/* Resize increments are one pixel per visible page. */
-	sizehints.width_inc = Columns * VxPages;
-	sizehints.height_inc = Rows * VyPages;
-	/* Set Min size for 1 pixel pages */
-	sizehints.min_width = VxPages * Columns + Columns - 1;
-	sizehints.min_height = (VyPages + label_h + 1) * Rows - 1;
-	sizehints.base_width = sizehints.min_width;
-	sizehints.base_height = sizehints.min_height;
+	int w_mult;
+	int h_mult;
+
+	w_mult = Columns * VxPages;
+	h_mult = Rows * VyPages;

 	/* Adjust window size to be even multiples of increment size. */
 	if (pwindow.width > 0) {
-		pwindow.width = (pwindow.width - sizehints.base_width) /
-			sizehints.width_inc;
-		pwindow.width = pwindow.width * sizehints.width_inc +
-			sizehints.base_width;
+		pwindow.width = (pwindow.width / w_mult + 1) * w_mult;
 	}
 	if (pwindow.height > 0) {
-		pwindow.height = (pwindow.height - sizehints.base_height) /
-			sizehints.height_inc;
- 		pwindow.height = pwindow.height * sizehints.height_inc +
-			sizehints.base_height;
-	}
-	if (check_aspect && sizehints.min_aspect.x > 0) {
-		sizehints.min_aspect.x = sizehints.max_aspect.x = pwindow.width;
-		sizehints.min_aspect.y = sizehints.max_aspect.y = pwindow.height;
+		pwindow.height = (pwindow.height / h_mult + 1) * h_mult;
 	}

 	desk_w = (pwindow.width - Columns + 1) / Columns;
@@ -714,14 +701,11 @@ void initialize_pager(void)
 		  pwindow.height = (VyPages * vHeight * Rows) / Scr.VScale +
 			  label_h * Rows + Rows;
 	  }
-	  sizehints.flags = (sizehints.flags | PAspect);
-	  sizehints.min_aspect.x = sizehints.max_aspect.x = pwindow.width;
-	  sizehints.min_aspect.y = sizehints.max_aspect.y = pwindow.height;
   }
   /* Adjust the window to handle these new sizehints.  This is also called
    * from ReConfigure().
    */
-  adjust_for_sizehints(VxPages, VyPages, true);
+  adjust_for_sizehints(VxPages, VyPages);

   if (is_transient)
   {
@@ -759,8 +743,6 @@ void initialize_pager(void)
     else
       sizehints.win_gravity = SouthWestGravity;
   }
-  sizehints.width = pwindow.width;
-  sizehints.height = pwindow.height;

   if(usposition)
     sizehints.flags |= USPosition;
@@ -1462,7 +1444,7 @@ void ReConfigure(void)
   }
   is_size_changed = (old_ww != pwindow.width || old_wh != pwindow.height);

-  adjust_for_sizehints(VxPages, VyPages, false);
+  adjust_for_sizehints(VxPages, VyPages);

   XSetWMNormalHints(dpy,Scr.Pager_w,&sizehints);

--
2.30.2

Reply via email to