home · contact · privacy
Client: Changed window sizing algorithm to fix bug of too large negative window
[plomrogue] / src / client / windows.c
index dcf450b3fecff04703bb513d256cb021f5f594d4..0ebe56dd949dbd9a063d432fe4b2da84a450a86e 100644 (file)
@@ -1,6 +1,7 @@
 /* src/client/windows.c */
 
 #include "windows.h"
+#include <stddef.h> /* NULL */
 #include <stdint.h> /* uint8_t, uint16_t, uint32_t, UINT16_MAX */
 #include <stdio.h> /* sprintf() */
 #include <stdlib.h> /* free() */
@@ -460,21 +461,23 @@ extern void init_win(struct Win ** wp, char * title, int16_t height,
     w->draw         = func;
     w->center.y     = 0;
     w->center.x     = 0;
-    if      (0 < width)
+    w->framesize.y  = world.wmeta.padsize.y - 1;
+    if      (0 < height && height <= world.wmeta.padsize.y - 1)
     {
-        w->framesize.x = width;
+        w->framesize.y = height;
     }
-    else if (0 >= width)
+    else if (0 > height && world.wmeta.padsize.y + (height - 1) > 0)
     {
-        w->framesize.x = world.wmeta.padsize.x + width;
+        w->framesize.y = world.wmeta.padsize.y + (height - 1);
     }
-    if      (0 < height && height <= world.wmeta.padsize.y - 1)
+    w->framesize.x  = world.wmeta.padsize.x;
+    if      (0 < width)
     {
-        w->framesize.y = height;
+        w->framesize.x = width;
     }
-    else if (0 >= height && world.wmeta.padsize.y + (height - 1) > 0)
+    else if (0 > width && world.wmeta.padsize.x + width > 0)
     {
-        w->framesize.y = world.wmeta.padsize.y + (height - 1);
+        w->framesize.x = world.wmeta.padsize.x + width;
     }
     *wp = w;
 }