aewl
diff client.c @ 27:f96fb3fd8203
added grid mode on Mod1Mask g
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Wed, 12 Jul 2006 16:00:51 +0200 |
parents | e8f627998d6f |
children | 3dceb132082d |
line diff
1.1 --- a/client.c Wed Jul 12 15:17:22 2006 +0200 1.2 +++ b/client.c Wed Jul 12 16:00:51 2006 +0200 1.3 @@ -3,6 +3,7 @@ 1.4 * See LICENSE file for license details. 1.5 */ 1.6 1.7 +#include <math.h> 1.8 #include <stdlib.h> 1.9 #include <string.h> 1.10 #include <X11/Xatom.h> 1.11 @@ -10,6 +11,73 @@ 1.12 #include "util.h" 1.13 #include "wm.h" 1.14 1.15 +void 1.16 +arrange(void *aux) 1.17 +{ 1.18 + Client *c; 1.19 + int n, cols, rows, gw, gh, i, j; 1.20 + float rt, fd; 1.21 + 1.22 + if(!clients) 1.23 + return; 1.24 + for(n = 0, c = clients; c; c = c->next, n++); 1.25 + rt = sqrt(n); 1.26 + if(modff(rt, &fd) < 0.5) 1.27 + rows = floor(rt); 1.28 + else 1.29 + rows = ceil(rt); 1.30 + if(rows * rows < n) 1.31 + cols = rows + 1; 1.32 + else 1.33 + cols = rows; 1.34 + 1.35 + gw = (sw - 1) / cols; 1.36 + gh = (sh - bh - 1) / rows; 1.37 + 1.38 + for(i = j = 0, c = clients; c; c = c->next) { 1.39 + c->x = i * gw; 1.40 + c->y = j * gh + bh; 1.41 + c->w = gw; 1.42 + c->h = gh; 1.43 + resize(c); 1.44 + if(++i == cols) { 1.45 + j++; 1.46 + i = 0; 1.47 + } 1.48 + } 1.49 +} 1.50 + 1.51 +void 1.52 +sel(void *aux) 1.53 +{ 1.54 + const char *arg = aux; 1.55 + Client *c = NULL; 1.56 + 1.57 + if(!arg || !stack) 1.58 + return; 1.59 + if(!strncmp(arg, "next", 5)) 1.60 + c = stack->snext ? stack->snext : stack; 1.61 + else if(!strncmp(arg, "prev", 5)) 1.62 + for(c = stack; c && c->snext; c = c->snext); 1.63 + if(!c) 1.64 + c = stack; 1.65 + raise(c); 1.66 + focus(c); 1.67 +} 1.68 + 1.69 +void 1.70 +kill(void *aux) 1.71 +{ 1.72 + Client *c = stack; 1.73 + 1.74 + if(!c) 1.75 + return; 1.76 + if(c->proto & WM_PROTOCOL_DELWIN) 1.77 + send_message(c->win, wm_atom[WMProtocols], wm_atom[WMDelete]); 1.78 + else 1.79 + XKillClient(dpy, c->win); 1.80 +} 1.81 + 1.82 static void 1.83 resize_title(Client *c) 1.84 { 1.85 @@ -113,7 +181,7 @@ 1.86 draw_client(old); 1.87 } 1.88 XUnmapWindow(dpy, c->title); 1.89 - draw_client(old); 1.90 + draw_client(c); 1.91 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 1.92 XFlush(dpy); 1.93 }