Hi,

On Sun, Jul 22, 2007 at 05:00:46PM +0200, Christian Dietrich wrote:
> I've written two patches:
> The one (windowscroll) give you the possibitlity to switch beetween
> visible clients by using your mouse wheel over the window title.
> 
> The other (selecttag) introduces the possibility to select the next or
> previous tag while calling selecttag("1") or selecttag("-1"). In the
> patch this is used to select the next/previous tag by "wheeling" over
> the tag buttons in the bar. selecttag could also be used to emulate
> Alt+Left/Alt+Right.
> 
> I divided this into two patches, because i know that the second is not
> the way you should use tags. But IMHO it is a way tag can be used.

After reading this thread I did the same and came up with something near
identical. However, I don't like the behaviour of selecttag() when more
then one tag is selected: The prev/next of the first tag is selected in
addition to all other tags and these are sweeped by multiple next's. 

In my patch selecttag() (or shiftview() as I called it) does nothing
when multiple tags are selected, because there is no sane prev/next.

Regards,
-- 
Jeroen Schot

[EMAIL PROTECTED] (mail & jabber)
http://schot.a-eskwadraat.nl
diff -ruNd dwm-4.3.orig/dwm.h dwm-4.3/dwm.h
--- dwm-4.3.orig/dwm.h	2007-07-14 21:11:29.000000000 +0200
+++ dwm-4.3/dwm.h	2007-07-23 11:20:46.562651000 +0200
@@ -144,6 +144,7 @@
 void toggletag(const char *arg);	/* toggles sel tags with arg's index */
 void toggleview(const char *arg);	/* toggles the tag with arg's index (in)visible */
 void view(const char *arg);		/* views the tag with arg's index */
+void shiftview(const char *arg);        /* views next(1)/previous(-1) tag */
 
 /* util.c */
 void *emallocz(unsigned int size);	/* allocates zero-initialized memory, exits on error */
diff -ruNd dwm-4.3.orig/event.c dwm-4.3/event.c
--- dwm-4.3.orig/event.c	2007-07-14 21:11:29.000000000 +0200
+++ dwm-4.3/event.c	2007-07-23 11:30:31.943651000 +0200
@@ -135,6 +135,10 @@
 					else
 						toggleview(buf);
 				}
+                                else if(ev->button == Button4)
+                                  shiftview("-1");
+                                else if( ev->button == Button5)
+                                  shiftview("1");
 				return;
 			}
 		}
diff -ruNd dwm-4.3.orig/tag.c dwm-4.3/tag.c
--- dwm-4.3.orig/tag.c	2007-07-14 21:11:29.000000000 +0200
+++ dwm-4.3/tag.c	2007-07-23 11:44:57.380651000 +0200
@@ -150,3 +150,21 @@
 		seltag[i] = True;
 	lt->arrange();
 }
+
+void 
+shiftview(const char *arg) {
+	int i, j;
+
+	for(i = 0; !seltag[i]; i++);
+	for(j = i + 1; j < ntags && !seltag[j]; j++);
+	if(j < ntags)
+		return; /* more then one tag selected */
+	seltag[i] = False;
+	i += arg ? atoi(arg) : 0;
+	if(i < 0)
+		i = ntags - 1;
+	else if(i >= ntags)
+		i = 0;
+	seltag[i] = True;
+	lt->arrange();
+}

Reply via email to