implemented exact focus next, if arg != NULL to focus{next,prev}
authorAnselm R Garbe <garbeam@gmail.com>
Sun, 11 May 2008 14:40:37 +0100
changeset 1188 1765468a0546
parent 1187 264e671527e6
child 1189 58366c12324e
implemented exact focus next, if arg != NULL to focus{next,prev}
config.def.h
config.mk
dwm.1
dwm.c
--- a/config.def.h	Tue May 06 15:52:44 2008 +0100
+++ b/config.def.h	Sun May 11 14:40:37 2008 +0100
@@ -53,7 +53,9 @@
 		"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
 	{ MODKEY|ShiftMask,		XK_Return,	spawn,		"exec uxterm" },
 	{ MODKEY,			XK_j,		focusnext,	NULL },
+	{ MODKEY|ShiftMask,		XK_j,		focusnext,	"exact" },
 	{ MODKEY,			XK_k,		focusprev,	NULL },
+	{ MODKEY|ShiftMask,		XK_k,		focusprev,	"exact" },
 	{ MODKEY,			XK_r,		reapply,	NULL },
 	{ MODKEY,			XK_h,		setmfact,	"-0.05" },
 	{ MODKEY,			XK_l,		setmfact,	"+0.05" },
--- a/config.mk	Tue May 06 15:52:44 2008 +0100
+++ b/config.mk	Sun May 11 14:40:37 2008 +0100
@@ -17,8 +17,8 @@
 # flags
 CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
 LDFLAGS = -s ${LIBS}
-#CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
-#LDFLAGS = -g ${LIBS}
+CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
+LDFLAGS = -g ${LIBS}
 
 # Solaris
 #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
--- a/dwm.1	Tue May 06 15:52:44 2008 +0100
+++ b/dwm.1	Sun May 11 14:40:37 2008 +0100
@@ -66,9 +66,15 @@
 .B Mod1\-j
 Focus next window.
 .TP
+.B Mod1\-Shift\-j
+Focus next window with exactly the same tags as the current one.
+.TP
 .B Mod1\-k
 Focus previous window.
 .TP
+.B Mod1\-Shift\-k
+Focus previous window with exactly the same tags as the current one.
+.TP
 .B Mod1\-h
 Decrease master area size.
 .TP
--- a/dwm.c	Tue May 06 15:52:44 2008 +0100
+++ b/dwm.c	Sun May 11 14:40:37 2008 +0100
@@ -160,7 +160,7 @@
 Bool isoccupied(unsigned int t);
 Bool isprotodel(Client *c);
 Bool isurgent(unsigned int t);
-Bool isvisible(Client *c);
+Bool isvisible(Client *c, Bool *cmp);
 void keypress(XEvent *e);
 void killclient(const char *arg);
 void manage(Window w, XWindowAttributes *wa);
@@ -287,7 +287,7 @@
 	Client *c;
 
 	for(c = clients; c; c = c->next)
-		if(isvisible(c)) {
+		if(isvisible(c, NULL)) {
 			unban(c);
 			if(lt->isfloating || c->isfloating)
 				resize(c, c->fx, c->fy, c->fw, c->fh, True);
@@ -469,7 +469,7 @@
 			if((ev->value_mask & (CWX|CWY))
 			&& !(ev->value_mask & (CWWidth|CWHeight)))
 				configure(c);
-			if(isvisible(c))
+			if(isvisible(c, NULL))
 				XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
 		}
 		else
@@ -536,7 +536,7 @@
 		drawtext(geom->symbol, dc.norm, False);
 		dc.x += bgw;
 	}
-	for(c = stack; c && !isvisible(c); c = c->snext);
+	for(c = stack; c && !isvisible(c, NULL); c = c->snext);
 	for(i = 0; i < LENGTH(tags); i++) {
 		dc.w = textw(tags[i]);
 		if(tagset[seltags][i]) {
@@ -676,8 +676,8 @@
 
 void
 focus(Client *c) {
-	if(!c || (c && !isvisible(c)))
-		for(c = stack; c && !isvisible(c); c = c->snext);
+	if(!c || (c && !isvisible(c, NULL)))
+		for(c = stack; c && !isvisible(c, NULL); c = c->snext);
 	if(sel && sel != c) {
 		grabbuttons(sel, False);
 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
@@ -711,9 +711,9 @@
 
 	if(!sel)
 		return;
-	for(c = sel->next; c && !isvisible(c); c = c->next);
+	for(c = sel->next; c && !isvisible(c, arg ? sel->tags : NULL); c = c->next);
 	if(!c)
-		for(c = clients; c && !isvisible(c); c = c->next);
+		for(c = clients; c && !isvisible(c, arg ? sel->tags : NULL); c = c->next);
 	if(c) {
 		focus(c);
 		restack();
@@ -726,10 +726,10 @@
 
 	if(!sel)
 		return;
-	for(c = sel->prev; c && !isvisible(c); c = c->prev);
+	for(c = sel->prev; c && !isvisible(c, arg ? sel->tags : NULL); c = c->prev);
 	if(!c) {
 		for(c = clients; c && c->next; c = c->next);
-		for(; c && !isvisible(c); c = c->prev);
+		for(; c && !isvisible(c, arg ? sel->tags : NULL); c = c->prev);
 	}
 	if(c) {
 		focus(c);
@@ -930,11 +930,13 @@
 }
 
 Bool
-isvisible(Client *c) {
+isvisible(Client *c, Bool *cmp) {
 	unsigned int i;
 
+	if(!cmp)
+		cmp = tagset[seltags];
 	for(i = 0; i < LENGTH(tags); i++)
-		if(c->tags[i] && tagset[seltags][i])
+		if(c->tags[i] && cmp[i])
 			return True;
 	return False;
 }
@@ -1061,7 +1063,7 @@
 	Client *c;
 
 	for(c = clients; c; c = c->next)
-		if((lt->isfloating || !c->isfloating) &&  isvisible(c))
+		if((lt->isfloating || !c->isfloating) &&  isvisible(c, NULL))
 			resize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS);
 }
 
@@ -1115,7 +1117,7 @@
 
 Client *
 nexttiled(Client *c) {
-	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
+	for(; c && (c->isfloating || !isvisible(c, NULL)); c = c->next);
 	return c;
 }
 
@@ -1292,7 +1294,7 @@
 		wc.stack_mode = Below;
 		wc.sibling = barwin;
 		for(c = stack; c; c = c->snext)
-			if(!c->isfloating && isvisible(c)) {
+			if(!c->isfloating && isvisible(c, NULL)) {
 				XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
 				wc.sibling = c->win;
 			}