diff -r ec42705c5fac config.mk --- a/config.mk Thu May 22 14:15:30 2008 +0100 +++ b/config.mk Fri May 23 11:16:17 2008 -0700 @@ -22,7 +22,7 @@ CPPFLAGS = -DVERSION=\"${VERSION}\" ${XI CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} #CFLAGS = -Os ${INCS} ${CPPFLAGS} #LDFLAGS = -s ${LIBS} -CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} ${CPPFLAGS} +CFLAGS = -g -std=c99 -pedantic -Wall ${INCS} ${CPPFLAGS} LDFLAGS = -g ${LIBS} # Solaris diff -r ec42705c5fac dwm.c --- a/dwm.c Thu May 22 14:15:30 2008 +0100 +++ b/dwm.c Fri May 23 16:39:38 2008 -0700 @@ -124,6 +124,7 @@ void buttonpress(XEvent *e); void buttonpress(XEvent *e); void checkotherwm(void); void cleanup(void); +void col(void); void configure(Client *c); void configurenotify(XEvent *e); void configurerequest(XEvent *e); @@ -146,6 +147,7 @@ Bool gettextprop(Window w, Atom atom, ch Bool gettextprop(Window w, Atom atom, char *text, uint size); void grabbuttons(Client *c, Bool focused); void grabkeys(void); +void grid(void); void initfont(const char *fontstr); Bool isoccupied(uint t); Bool isprotodel(Client *c); @@ -189,6 +191,7 @@ void updatewmhints(Client *c); void updatewmhints(Client *c); void view(const void *arg); void viewprevtag(const void *arg); +void viewtagsel(const void *arg); int xerror(Display *dpy, XErrorEvent *ee); int xerrordummy(Display *dpy, XErrorEvent *ee); int xerrorstart(Display *dpy, XErrorEvent *ee); @@ -199,6 +202,7 @@ int screen, sx, sy, sw, sh; int screen, sx, sy, sw, sh; int bx, by, bw, bh, blw, wx, wy, ww, wh; int mx, my, mw, mh, tx, ty, tw, th; +int rows = 1; uint seltags = 0; int (*xerrorxlib)(Display *, XErrorEvent *); uint numlockmask = 0; @@ -389,6 +393,26 @@ cleanup(void) { } void +col(void) { + int x, y, h, w; + uint i, n; + Client *c; + + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + w = (n < 3) ? ww / n : ww / 3; + + for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { + h = (i < 2) ? wh : wh / (n-2); + x = wx + ((i < 2) ? i * w : 2 * w); + y = wy + ((i < 3) ? 0 : h * (i-2)); + tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw); + } +} + +void configure(Client *c) { XConfigureEvent ce; @@ -660,32 +684,43 @@ void void focusnext(const void *arg) { Client *c; + uint i; if(!sel) return; - for(c = sel->next; c && !VISIBLE(c); c = c->next); - if(!c) - for(c = clients; c && !VISIBLE(c); c = c->next); - if(c) { - focus(c); - restack(); + if(!arg) + arg = (void *)rows; + + for(i = 0; i < (uint) arg; i++) { + for(c = sel->next; c && !VISIBLE(c); c = c->next); + if(!c) + for(c = clients; c && !VISIBLE(c); c = c->next); + if(c) { + focus(c); + restack(); + } } } void focusprev(const void *arg) { Client *c; + uint i; if(!sel) return; - for(c = sel->prev; c && !VISIBLE(c); c = c->prev); - if(!c) { - for(c = clients; c && c->next; c = c->next); - for(; c && !VISIBLE(c); c = c->prev); - } - if(c) { - focus(c); - restack(); + if(!arg) + arg = (void *)rows; + for(i = 0; i < (uint) arg; i++) { + for(c = sel->prev; c && !VISIBLE(c); c = c->prev); + if(!c) { + for(c = clients; c && c->next; c = c->next); + for(; c && !VISIBLE(c); c = c->prev); + } + if(c) { + focus(c); + restack(); + } } } @@ -1196,6 +1231,10 @@ restack(void) { drawbar(); if(!sel) return; + + XWarpPointer(dpy, None, RootWindow(dpy, DefaultScreen(dpy)), 0, 0, 0, 0, sel->x + sel->w / 2, sel->y + sel->h / 2); + XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); + if(sel->isfloating || !lt->arrange) XRaiseWindow(dpy, sel->win); if(lt->arrange) { @@ -1445,6 +1484,29 @@ textw(const char *text) { } void +grid(void) { + int x, y, h, w, cols; + uint i, n; + Client *c; + + for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + for(cols = 0; cols * cols < n; cols++); + rows = n / cols + !!(n % cols); + + h = wh / rows; + w = ww / cols; + + for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { + x = wx + i / rows * w; + y = wy + i % rows * h; + tileresize(c, x, y, w - 2 * c->bw, h - 2 * c->bw); + } +} + +void tile(void) { int x, y, h, w; uint i, n; @@ -1728,6 +1790,13 @@ viewprevtag(const void *arg) { viewprevtag(const void *arg) { seltags ^= 1; /* toggle sel tagset */ arrange(); +} + +void +viewtagsel(const void *arg) { + if(!sel) + return; + view((uint[]){ sel->tags }); } /* There's no way to check accesses to destroyed windows, thus those cases are