Detect and override illegal window size hints
commit6668715402a5d8e2ecda6702076a06bf8988721e
authorGaspar Chilingarov <gasparch@gmail.com>
Mon, 21 May 2018 08:35:36 +0000 (21 08:35 +0000)
committerCarlos R. Mafra <crmafra@gmail.com>
Mon, 21 May 2018 12:02:22 +0000 (21 13:02 +0100)
tree9f02c7a3a94d8ec7f397e03ffe72be5d613db68c
parent100745d356322843437a61a7ee7482eaae9bfa5a
Detect and override illegal window size hints

The problem - when VirtualBox starts virtual machine, window has very
small height (couple of pixels) and it requires some manual fiddling
to resize it to something usable.

See related bugs here:

https://www.virtualbox.org/ticket/14718#comment:19 - small horizontal
line in the middle of the screen is newly opened virtual machine's
window.

https://www.virtualbox.org/ticket/15863

Inspecting with xdebug and xprop reveals that VirtualBox sends wrong hints:

Request(12): ConfigureWindow window=0x0660000a values={x=27 y=559
width=720 height=65512}

Which is interpreted by X server wrongly and shown with xprop as

WM_NORMAL_HINTS(WM_SIZE_HINTS)
:
                user specified location: 27, 559
                user specified size: 720 by -24
                program specified minimum size: 254 by 109
                window gravity: Static

Some part of X11 interprets such large value as signed int and wraps
it to negative value.

The solution will be if program requests such big window - detect it,
ignore requested size and resize it to some reasonable defaults.

Disclaimer - I tested it only on Ubuntu 16.04, but should apply to
another systems as well - see bug reports.
src/window.c