From: Michael D. Lowis Date: Tue, 18 Jun 2019 02:24:07 +0000 (-0400) Subject: fixed handling of vertical resize X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=0b53560e727d2ad347f3def4a63e8855195ab78e;p=projs%2Ftide.git fixed handling of vertical resize --- diff --git a/src/anvil.c b/src/anvil.c index 0e28a3f..884b3f0 100644 --- a/src/anvil.c +++ b/src/anvil.c @@ -14,13 +14,17 @@ #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);