Evidently, it hasn't been tested for much time. but here you have.
(I defined MOD+Scape to come back to previously selected tags,
probably a better solution is the key at the left of 1, but that's not
standard for all the keyboards...)

2007/8/23, Antoni Grzymala <[EMAIL PROTECTED]>:
> Tako rzecze y i y u s  (w e-mailu datowanym 2007-08-23, 23:09):
>
> > btw: the screen behaviour you talk about is easy to do in dwm. you
> > just need a Bool *prevtags and set it whenever view is called (also
> > with toggleview? I don't think so) and a function to view prevtags.
> > Send an email if you have problems.
>
> I can imagine it's pretty easy to program, but I'm not a C programmer
> and would waste tons of time on trying to implement it. Thought that
> maybe someone who likes the idea would do it for (her|him)self and me.
>
> Best,
>
> [a]
>
> --


-- 


- yiyus || JGL .
diff -up dwm-4.4/config.default.h dwm-4.4-prevtags/config.default.h
--- dwm-4.4/config.default.h	2007-08-23 18:11:41.000000000 +0200
+++ dwm-4.4-prevtags/config.default.h	2007-08-23 23:34:46.000000000 +0200
@@ -52,6 +52,7 @@ Key keys[] = { \
 	{ MODKEY,			XK_Return,	zoom,		NULL }, \
 	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL }, \
 	{ MODKEY|ShiftMask,		XK_c,		killclient,	NULL }, \
+	{ MODKEY,			XK_Escape,		viewprevtag,		NULL }, \
 	{ MODKEY,			XK_0,		view,		NULL }, \
 	{ MODKEY,			XK_1,		view,		tags[0] }, \
 	{ MODKEY,			XK_2,		view,		tags[1] }, \
diff -up dwm-4.4/dwm.h dwm-4.4-prevtags/dwm.h
--- dwm-4.4/dwm.h	2007-08-23 18:11:41.000000000 +0200
+++ dwm-4.4-prevtags/dwm.h	2007-08-23 23:30:34.000000000 +0200
@@ -81,7 +81,7 @@ extern unsigned int bh, blw, bpos;		/* b
 extern unsigned int ntags, numlockmask;		/* number of tags, numlock mask */
 extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
 extern Atom wmatom[WMLast], netatom[NetLast];
-extern Bool selscreen, *seltags;		/* seltags is array of Bool */
+extern Bool selscreen, *seltags, *prevtags;		/* seltags is array of Bool */
 extern Client *clients, *sel, *stack;		/* global client list and stack */
 extern Cursor cursor[CurLast];
 extern DC dc;					/* global draw context */
@@ -139,6 +139,7 @@ void toggletag(const char *arg);	/* togg
 void toggleview(const char *arg);	/* toggles the tag with arg's index (in)visible */
 void updatebarpos(void);		/* updates the bar position */
 void view(const char *arg);		/* views the tag with arg's index */
+void viewprevtag(const char *arg);	/* views previous selected tags */
 
 /* util.c */
 void *emallocz(unsigned int size);	/* allocates zero-initialized memory, exits on error */
diff -up dwm-4.4/main.c dwm-4.4-prevtags/main.c
--- dwm-4.4/main.c	2007-08-23 18:11:41.000000000 +0200
+++ dwm-4.4-prevtags/main.c	2007-08-23 23:40:09.000000000 +0200
@@ -21,7 +21,7 @@ unsigned int bh, ntags;
 unsigned int bpos = BARPOS;
 unsigned int numlockmask = 0;
 Atom wmatom[WMLast], netatom[NetLast];
-Bool *seltags;
+Bool *seltags, *prevtags;
 Bool selscreen = True;
 Client *clients = NULL;
 Client *sel = NULL;
@@ -58,6 +58,7 @@ cleanup(void) {
 	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
 	XSync(dpy, False);
 	free(seltags);
+	free(prevtags);
 }
 
 static unsigned long
@@ -196,7 +197,9 @@ setup(void) {
 	compileregs();
 	for(ntags = 0; tags[ntags]; ntags++);
 	seltags = emallocz(sizeof(Bool) * ntags);
+	prevtags = emallocz(sizeof(Bool) * ntags);
 	seltags[0] = True;
+	prevtags[0] = True;
 	/* style */
 	dc.norm[ColBorder] = initcolor(NORMBORDERCOLOR);
 	dc.norm[ColBG] = initcolor(NORMBGCOLOR);
diff -up dwm-4.4/screen.c dwm-4.4-prevtags/screen.c
--- dwm-4.4/screen.c	2007-08-23 18:11:41.000000000 +0200
+++ dwm-4.4-prevtags/screen.c	2007-08-23 23:30:57.000000000 +0200
@@ -367,10 +367,25 @@ void
 view(const char *arg) {
 	unsigned int i;
 
-	for(i = 0; i < ntags; i++)
+	for(i = 0; i < ntags; i++) {
+		prevtags[i] = seltags[i];
 		seltags[i] = arg == NULL;
+	}
 	i = idxoftag(arg);
 	if(i >= 0 && i < ntags)
 		seltags[i] = True;
 	arrange();
 }
+
+void
+viewprevtag(const char *arg) {
+	unsigned int i;
+	Bool t;
+
+	for(i = 0; i < ntags; i++) {
+		t = seltags[i];
+		seltags[i] = prevtags[i];
+		prevtags[i] = t;
+	}
+	arrange();
+}

Reply via email to