[dwm] Small patch that allows user to select next and previous tags

2008-07-22 Thread Mika Westerberg
Hi,

First of all, thanks for the great WM!

Anyway, I have small patch set that allows user to select tags
using Mod1-Left|Right (or whatever user wants to map them)
in case someone is interested. It is similar that was suggested
by Jukka Salmi in thread:

http://lists.suckless.org/dwm/0607/0026.html

but works against latest dwm sources.

Note that if user has several tags selected, only one
next/prev tag is then selected.

MW
diff -r f8c445284353 -r a3c47fa966ee config.def.h
--- a/config.def.h	Fri Jul 18 20:18:45 2008 +0100
+++ b/config.def.h	Tue Jul 22 11:21:22 2008 +0300
@@ -67,6 +67,8 @@ static Key keys[] = {
 	{ MODKEY|ShiftMask, XK_space,  togglefloating, {0} },
 	{ MODKEY,   XK_0,  view,   {.ui = ~0 } },
 	{ MODKEY|ShiftMask, XK_0,  tag,{.ui = ~0 } },
+	{ MODKEY,			XK_Left,   view_prev_tag,  {0} },
+	{ MODKEY,			XK_Right,  view_next_tag,  {0} },
 	TAGKEYS(XK_1,  0)
 	TAGKEYS(XK_2,  1)
 	TAGKEYS(XK_3,  2)
diff -r f8c445284353 -r a3c47fa966ee dwm.1
--- a/dwm.1	Fri Jul 18 20:18:45 2008 +0100
+++ b/dwm.1	Tue Jul 22 11:21:22 2008 +0300
@@ -117,6 +117,14 @@ tag.
 .B Mod1\-0
 View all windows with any tag.
 .TP
+.B Mod1\-Left
+View all windows with tag previous than current.  E.g.
+if tag 4 is selected, previous tag would be 3.
+.TP
+.B Mod1\-Right
+View all windows with tag next than current.  E.g.
+if tag 4 is selected, next tag would be 5.
+.TP
 .B Mod1\-Control\-[1..n]
 Add/remove all windows with
 .BR nth
diff -r f8c445284353 -r a3c47fa966ee dwm.c
--- a/dwm.c	Fri Jul 18 20:18:45 2008 +0100
+++ b/dwm.c	Tue Jul 22 11:21:22 2008 +0300
@@ -197,6 +197,9 @@ static void updatetitle(Client *c);
 static void updatetitle(Client *c);
 static void updatewmhints(Client *c);
 static void view(const Arg *arg);
+static void view_next_tag(const Arg *);
+static void view_prev_tag(const Arg *);
+static void view_adjacent_tag(int);
 static int xerror(Display *dpy, XErrorEvent *ee);
 static int xerrordummy(Display *dpy, XErrorEvent *ee);
 static int xerrorstart(Display *dpy, XErrorEvent *ee);
@@ -1672,6 +1675,66 @@ view(const Arg *arg) {
 	arrange();
 }
 
+/*
+ * Views adjacent tag based on current selected
+ * tag(s) and distance.  Distance is expressed
+ * as relative to first selected tag(s), for
+ * example  if first selected tag is 4 and
+ * distance is +2 then we display tag 4 + 2 = 6.
+ *
+ * Note that this function only selects one tag
+ * even though user has multiple tags selected
+ * before.
+ */
+static void
+view_adjacent_tag(int distance)
+{
+	int i, curtags;
+	int seltag = 0;
+	Arg arg;
+
+	/*
+	 * Check first tag currently selected.  If there are
+	 * several tags selected we only pick first one.
+	 */
+	curtags = (tagset[seltags]  TAGMASK);
+	for (i = 0; i  LENGTH(tags); i++) {
+		if ((curtags  (1  i)) != 0) {
+			seltag = i;
+			break;
+		}
+	}
+
+	/*
+	 * Calculate next selected tag wrapping around
+	 * when tag overflows.
+	 */
+	seltag = (seltag + distance) % (int)LENGTH(tags);
+	if (seltag  0)
+		seltag += LENGTH(tags);
+
+	arg.i = (1  seltag);
+	view(arg);
+}
+
+/*ARGSUSED*/
+static void
+view_next_tag(const Arg *arg)
+{
+	(void)arg;
+
+	view_adjacent_tag(+1);
+}
+
+/*ARGSUSED*/
+static void
+view_prev_tag(const Arg *arg)
+{
+	(void)arg;
+
+	view_adjacent_tag(-1);
+}
+
 /* There's no way to check accesses to destroyed windows, thus those cases are
  * ignored (especially on UnmapNotify's).  Other types of errors call Xlibs
  * default error handler, which may call exit.  */


Re: [dwm] 5.0.1 : Xorg crashed with VLC movie

2008-07-22 Thread Deleuze
Hi folks,


 I tried with hg tip and I'm also running ubuntu 8.04 with the
 vlc package. I can't confirm, for me it works without any crash
 at all.

 On Fri, Jul 18, 2008 at 10:48:58PM +0200, Albert Cardona wrote:
  I have just upgraded from 4.7 to 5.0.1.
  I'm running ubuntu 8.04 updated to today.
  1 - download this movie:
  http://www.ini.uzh.ch/~acardona/movies/48.avi
  2 - run:  $ vlc 48.avi
  ... then Xorg crashes. With dwm 4.7 this doesn't happen: VLC crashes, 
  but not Xorg. From gnome desktop, VLC runs the movie normally.
  Did anybody run into this sort of issue?

I tried to watch this movie with my heavily outdated vlc.Still using 
XFree86-Server-4.3.0_14 which does NOT crash.  
Log can be found here:  http://www.netbeisser.de/vlc.txt

,dwm  -v
dwm-5.0.1, © 2006-2008 dwm engineers, see LICENSE for details


Maybe updating vlc helps. Did you have any new state on that?

regards
Deleuze

btw. did we discuss this in the chat? could not find anything about it with a 
fast grep.

-- 
http://www.netbeisser.de/quotes.html

GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196