From 6668715402a5d8e2ecda6702076a06bf8988721e Mon Sep 17 00:00:00 2001 From: Gaspar Chilingarov Date: Mon, 21 May 2018 08:35:36 +0000 Subject: [PATCH] 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/window.c b/src/window.c index cb4ff4e7..195c3e6a 100644 --- a/src/window.c +++ b/src/window.c @@ -2087,6 +2087,14 @@ void wWindowConfigure(WWindow *wwin, int req_x, int req_y, int req_width, int re int synth_notify = False; int resize; + /* if window size is guaranteed to fail - fix it to some reasonable + * defaults */ + if (req_height > SHRT_MAX) + req_height = 480; + + if (req_width > SHRT_MAX) + req_height = 640; + resize = (req_width != wwin->client.width || req_height != wwin->client.height); /* * if the window is being moved but not resized then