Commits

Anonymous committed 28cb114

implement wrapping around the ends of tags

Comments (0)

Files changed (1)

 # HG changeset patch
-# Parent e674327ac3e3cd37afd76dd04937d47b0b089091
+# Parent 6e1d30add9c0148785fe53c45e8f2db88414edf2
 
-diff -r e674327ac3e3 shifttags.c
+diff -r 6e1d30add9c0 shifttags.c
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/shifttags.c	Sun Aug 05 21:26:18 2012 +0200
-@@ -0,0 +1,17 @@
++++ b/shifttags.c	Tue Aug 07 07:57:53 2012 +0200
+@@ -0,0 +1,28 @@
 +static void
 +shifttags(const Arg *arg) {
-+	/* attention: shifting tags doesn't wrap around the first/last tag */
 +	Arg shift;
++	/* wrap around tags when shifting over the ends of tagmask */
++	/* only activate wrapping when the number of tags fits twice into an
++	 * unsigned int */
++	Bool wrap = LENGTH(tags) <= (sizeof(shift.ui) * 4) ? True : False;
 +
 +	if(arg->i == 0)
 +		return;
 +
 +	if(arg->i > 0)
 +		shift.ui = selmon->tagset[selmon->seltags] << arg->i;
-+	else
-+		shift.ui = selmon->tagset[selmon->seltags] >> (-1 * arg->i);
++	else {
++		if(wrap) {
++			shift.ui = selmon->tagset[selmon->seltags] << LENGTH(tags);
++			shift.ui = shift.ui >> (-1 * arg->i);
++		}
++		else
++			shift.ui = selmon->tagset[selmon->seltags] >> (-1 * arg->i);
++	}
++	if(wrap)
++		shift.ui |= shift.ui >> LENGTH(tags);
 +
 +	if(!(shift.ui & TAGMASK))
 +		return;