]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed handling of vertical resize
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 18 Jun 2019 02:24:07 +0000 (22:24 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 18 Jun 2019 02:24:07 +0000 (22:24 -0400)
src/anvil.c

index 0e28a3fcd6c98a18eaad649acc3cc1a83986de82..884b3f0c625e28f60580bf6dd0b9252f76b06b91 100644 (file)
 #define BARHEIGHT(x) \
     ((x)->font->height + 3)
 
+enum {
+    TOO_SMALL = (1 << 0)
+};
+
 typedef struct Client {
     struct Client *next, *prev;
     Window win;
     Window frame;
     char* name;
     XftDraw* xft;
-    int x, y, w, h;
+    int flags, x, y, w, h;
 } Client;
 
 XConf X = {0};
@@ -65,9 +69,19 @@ void client_del(Client* c) {
 }
 
 void client_reconfig(XConf* xs, Client* c) {
-    int height = xs->font->height + 3;
-    XMoveResizeWindow(xs->display, c->frame, c->x, c->y,          c->w - 2, height);
-    XMoveResizeWindow(xs->display, c->win,   c->x, c->y + height, c->w - 2, c->h - height - 2);
+    int height = BARHEIGHT(xs);
+    XMoveResizeWindow(xs->display, c->frame, c->x, c->y, c->w - 2, height);
+    if (c->h <= height) {
+        XUnmapWindow(xs->display, c->win);
+        c->flags |= TOO_SMALL;
+    } else {
+        XMoveResizeWindow(xs->display, c->win, c->x, c->y + height, c->w - 2, c->h - height - 2);
+        if (c->flags & TOO_SMALL) {
+            c->flags &= ~TOO_SMALL;
+            XMapWindow(xs->display, c->win);
+        }
+    }
+    XSync(xs->display, False);
 }
 
 void client_config(XConf* xs, Client* c, int x, int y, int w, int h) {
@@ -161,12 +175,8 @@ void client_resize(XConf* x, Client* c, int dir) {
     int miny = prev->y + BARHEIGHT(x);
     int maxy = (c->next ? c->next->y : sh) - BARHEIGHT(x);
     int newy = min(max(miny, (c->y + dir)), maxy);
-
     prev->h = newy - prev->y;
-    if (c->next)
-        c->h = c->next->y - newy;
-    else
-        c->h = sh - newy;
+    c->h = (c->next ? (c->next->y - newy) : (sh - newy));
     c->y = newy;
 
     client_reconfig(x, prev);