Detect and override illegal window size hints v2
commit62405fbb75126a7dcad45f3f656e9bc790dbd6dc
authorDavid Maciejak <david.maciejak@gmail.com>
Wed, 22 Feb 2023 11:29:23 +0000 (22 19:29 +0800)
committerCarlos R. Mafra <crmafra@gmail.com>
Wed, 22 Feb 2023 20:10:31 +0000 (22 20:10 +0000)
tree7b9e3330703cd113c6c081aef71c24d327896096
parentf1fef40f0d59a854ca759e3cb7d3e6b99ac8f648
Detect and override illegal window size hints v2

The patch is trying to mitigate and properly address the issue described at
https://github.com/window-maker/wmaker/issues/26
A buggy application (in that example virtualbox) is requesting a window size creation
that is way too big and basically at the limit of X11 protocol
(width and height are defined as CARD16).
See details at https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html
During the tests, virtualbox has been seen requesting for window creation of size 843x65508.
Even xprop is reporting incorrect values.

There had been an attempt before with the commit
https://repo.or.cz/wmaker-crm.git?a=commit;h=6668715402a5d8e2ecda6702076a06bf8988721e

But the patch is broken and not implemented at the right place.
As described in the wWindowConfigure function header, the size passed by the client app
should not be trusted and should be vetted with a prior call to wWindowConstrainSize.
wWindowConstrainSize call was missing only once in the wClientConfigure function from client.c
What wWindowConstrainSize doing now is basically setting a failsafe window size fo 640x480
if both width and height are above the size of CARD16.
If only one dimension is oversized, it's setting a default 4/3 window ratio.
Oversized here has not been changed and it's defined in windowmaker as double the screen size.
src/client.c
src/window.c