From 528455045c80dfff5a54561f5f01691a236e428c Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 8 Jan 2017 15:25:54 +0100 Subject: [PATCH] Print warnings on invalid resizes These warnings might help catching some problems in the future. These could be asserts, but printing a warning is a lot nicer than dying. Signed-off-by: Uli Schlachter --- objects/client.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/objects/client.c b/objects/client.c index d347d084..309d021e 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1176,12 +1176,33 @@ client_geometry_refresh(void) area_t real_geometry = c->geometry; if (!c->fullscreen) { + if ((real_geometry.width < c->titlebar[CLIENT_TITLEBAR_LEFT].size + + c->titlebar[CLIENT_TITLEBAR_RIGHT].size) || + (real_geometry.height < c->titlebar[CLIENT_TITLEBAR_TOP].size + + c->titlebar[CLIENT_TITLEBAR_BOTTOM].size)) + warn("Resizing a window to a negative size!? Have width %d-%d-%d=%d" + " and height %d-%d-%d=%d", real_geometry.width, + c->titlebar[CLIENT_TITLEBAR_LEFT].size, + c->titlebar[CLIENT_TITLEBAR_RIGHT].size, + real_geometry.width - + c->titlebar[CLIENT_TITLEBAR_LEFT].size - + c->titlebar[CLIENT_TITLEBAR_RIGHT].size, + real_geometry.height, + c->titlebar[CLIENT_TITLEBAR_TOP].size, + c->titlebar[CLIENT_TITLEBAR_BOTTOM].size, + real_geometry.height - + c->titlebar[CLIENT_TITLEBAR_TOP].size - + c->titlebar[CLIENT_TITLEBAR_BOTTOM].size); + real_geometry.x = c->titlebar[CLIENT_TITLEBAR_LEFT].size; real_geometry.y = c->titlebar[CLIENT_TITLEBAR_TOP].size; real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_LEFT].size; real_geometry.width -= c->titlebar[CLIENT_TITLEBAR_RIGHT].size; real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_TOP].size; real_geometry.height -= c->titlebar[CLIENT_TITLEBAR_BOTTOM].size; + + if (real_geometry.width == 0 || real_geometry.height == 0) + warn("Resizing a window to size zero!?"); } else { real_geometry.x = 0; real_geometry.y = 0;