From: Michael D. Lowis Date: Tue, 17 Mar 2020 15:34:01 +0000 (-0400) Subject: minor tweaks and sketched out logic for stacked and expanded tiling modes X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=76d9e530c020a331c594a6a6f101d358606531ab;p=proto%2Fanvil.git minor tweaks and sketched out logic for stacked and expanded tiling modes --- diff --git a/anvil.h b/anvil.h index b465e1c..4082f2c 100644 --- a/anvil.h +++ b/anvil.h @@ -44,7 +44,8 @@ typedef struct { } XConf; enum { - F_WM_DELETE = (1 << 0) + F_WM_DELETE = (1 << 0), + F_DIALOG = (1 << 1), }; typedef struct Client { @@ -130,6 +131,7 @@ void client_initall(void); Client* client_add(Window win, XWindowAttributes* attr); void client_draw(Client* c); Client* client_get(Window w, Location* loc); +void client_adjust(Client* c); void client_move(Client* c, int xdiff, int ydiff); void client_resize(Client* c, int xdiff, int ydiff); void client_close(Client* c); diff --git a/client.c b/client.c index 7019815..e302c33 100644 --- a/client.c +++ b/client.c @@ -86,16 +86,10 @@ Client* client_get(Window w, Location* loc) return c; } -void client_raise(Client* c) +void client_adjust(Client* c) { - XRaiseWindow(X.disp, c->frame); - XRaiseWindow(X.disp, c->win); -} - -void client_lower(Client* c) -{ - XLowerWindow(X.disp, c->win); - XLowerWindow(X.disp, c->frame); + client_move(c, 0, 0); + client_resize(c, 0, 0); } void client_move(Client* c, int xdiff, int ydiff) @@ -105,7 +99,6 @@ void client_move(Client* c, int xdiff, int ydiff) XMoveWindow(X.disp, c->frame, c->x - BORDER_WIDTH, c->y - TITLE_HEIGHT - BORDER_WIDTH); - XSync(X.disp, False); mons_place(c); } @@ -119,7 +112,6 @@ void client_resize(Client* c, int xdiff, int ydiff) XResizeWindow(X.disp, c->frame, c->w + 2*BORDER_WIDTH, c->h + 2*BORDER_WIDTH + TITLE_HEIGHT); - XSync(X.disp, False); mons_place(c); } @@ -157,13 +149,26 @@ void client_show(Client* c, int show) void client_readprops(Client* c) { - Atom *protos = NULL, actual_type; + Atom *protos = NULL, actual_type, *wintype; int format, nprotos = 0; unsigned long n, extra; + + /* get window title */ xfree(c->name); c->name = NULL; XGetWindowProperty( - X.disp, c->win, XA_WM_NAME, 0L, 100L, False, AnyPropertyType, &actual_type, &format, &n, &extra, (unsigned char **)&c->name); + X.disp, c->win, XA_WM_NAME, 0, -1, False, AnyPropertyType, &actual_type, &format, &n, &extra, (unsigned char **)&c->name); + + /* check if the window is a dialog */ + XGetWindowProperty( + X.disp, c->win, atom("_NET_WM_WINDOW_TYPE"), 0L, -1, False, XA_ATOM, &actual_type, &format, &n, &extra, (unsigned char **)&wintype); + if (wintype && *wintype == atom("_NET_WM_WINDOW_TYPE_DIALOG")) + { + c->flags |= F_DIALOG; + } + xfree(wintype); + + /* get the other hints and protocols */ XGetWMNormalHints(X.disp, c->win, &(c->hints), &(c->hint_flags)); XGetWMProtocols(X.disp, c->win, &protos, &nprotos); for (int i = 0; i < nprotos; i++) diff --git a/mons.c b/mons.c index b842801..b04e6c9 100644 --- a/mons.c +++ b/mons.c @@ -44,11 +44,14 @@ void mons_init(void) static void coldims(Monitor* mon, Column* col, int *x, int *y, int *w, int *h) { *x = mon->x, *y = mon->y, *w = col->width, *h = mon->h; +// printf("bef: %d %d %d %d\n", mon->x, mon->y, col->width, mon->h); +// printf("mon: %d %d %d %d\n", mon->x, mon->y, mon->w, mon->h); for (Column* c = mon->cspace->columns; c != col; *x += c->width, c = c->next); *x += BORDER_WIDTH; *y += BORDER_WIDTH + TITLE_HEIGHT; - *w -= 2*BORDER_WIDTH; - *h -= 2*BORDER_WIDTH + TITLE_HEIGHT; + *w -= (2*BORDER_WIDTH) + 2; + *h -= (2*BORDER_WIDTH + TITLE_HEIGHT) + 2; +// printf("%d %d %d %d\n", *x, *y, *w, *h); } void mons_layer(Monitor* mon) @@ -73,14 +76,17 @@ void mons_layer(Monitor* mon) static void tile_monocle(Monitor* mon, Column* col, Client* c) { coldims(mon, col, &(c->x), &(c->y), &(c->w), &(c->h)); - client_move(c, 0, 0); - client_resize(c, 0, 0); + client_adjust(c); c->next = col->clients; col->clients = c; } static void tile_expand(Monitor* mon, Column* col, Client* client) { + /* + * stack all existing clients top to bottom only showing title bars + * move+resize new client to fill remaining space or place its title bar at bottom of screen + */ (void)mon, (void)col; client->next = col->clients; col->clients = client; @@ -88,6 +94,11 @@ static void tile_expand(Monitor* mon, Column* col, Client* client) static void tile_stacked(Monitor* mon, Column* col, Client* client) { + /* + * find biggest client in stack + * split that client in half + * move+resize new client to fill the gap + */ (void)mon, (void)col; client->next = col->clients; col->clients = client; @@ -100,7 +111,7 @@ void mons_addclient(Client* c) int ptrx = 0, ptry = 0, winx = 0, winy = 0, mask = 0; XQueryPointer(X.disp, X.root, &root, &child, &ptrx, &ptry, &winx, &winy, (unsigned int*)&mask); Monitor* mon = pickmon(ptrx, ptry); - if (X.mode == M_INIT) + if (X.mode == M_INIT || c->flags & F_DIALOG) { c->next = mon->cspace->floating; mon->cspace->floating = c; @@ -297,12 +308,10 @@ static Column* pickcol(Column* cols, int relx) /* otherwise, return the current column */ if (!col) { -// puts("searching for active col"); int left = 0, right = 0; for (col = cols; col; col = col->next) { left = right, right += col->width; -// printf("%d <= %d < %d\n", left, relx, right); if (left <= relx && relx < right) { break; /* we found the column holding the mouse */