I'm doing some cleanup/refactoring, came across some interesting code,
and wondered if anybody had a good reason why it might be right.  It
sure doesn't seem to be.

We have values stashed up for the maximum window width and height.
You can configure them via MaxWindowSize, but they need some value
even if you don't set it, so we initialize it during startup.  We do
that here[0].

X (the window system, not the axis) coordinates are signed 16-bit
ints, so 32767 is the max possible in either direction.  That makes
sense.  Then we subtract from that...  the screen width/height?
That...   what?  Apart from some field renaming and trivial
whitespacery, those lines are unchanged in our history, exist just the
same in twm to this day[1], and are also untouched in vtwm[2].

What the heck?  The bigger our screen gets, the smaller the maximum
window size is?  "4k" monitors tend to be 3840 pixels wide, so if you
had 8 of 'em laid out side by side for your desktop (a ridiculous and
impractical, but nowadays no longer impossible setup[3]), your x
coordinate would go up to 30720, which means you couldn't have a
window wider than 2047 pixels (half a monitor)!  There's no way that
can be right.


My theory that what's _actually_ desired here is not subtracting the
width/height of the root window, but the x/y coordinate, since the
root window isn't necessarily at (0,0).   e.g., if you have multiple
Screen's (:0.0 and :0.1, say), one of them probably starts to the
right of or under the other, so has a positive x or y coordinate for
the origin.  And so the limit of the window size actually has to be be
reduced by that amount in that direction.

If it _is_ incorrect as it stands, it's a little surprising that it's
gone unnoticed everywhere for this long, but I guess 2**15-1 is still
a big enough number as desktop resolutions go that nobody's hit it in
practice...




[0] https://bazaar.launchpad.net/~ctwm/ctwm/trunk/view/641/ctwm_main.c#L424

[1] 
https://cgit.freedesktop.org/xorg/app/twm/tree/src/twm.c?id=777236e942ae85bcacfdc2e086944a42cfed5b45#n500

[2] 
https://sourceforge.net/p/vtwm/code/ci/70991cca915cdd7b5da1f78d18fb97d5bc7dff96/tree/twm.c#l602

[3] 8 "5k" monitors is over 40k pixels, so is actually bigger than the
    X protocol can handle.  4 "8k" (which do exist now) are almost at
    the limit too.  I guess after 31 years, we're finally gonna need
    to move to X12...


-- 
Matthew Fuller     (MF4839)   |  [email protected]
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.

Reply via email to