It is already on the wiki:

  http://herbst.homeunix.org/~jceb/dwm/4.6/current/dwm-4.6-taglayouts.diff

I never had the need to use this patch. But for my eyes this patch needs
more work. it's using dynamic memory allocation for something that it is
already static and defined in config.h.

-unsigned int* ltidxs;
+unsigned int ltidxs[NTAGS];

so, no need to alloc/free, the patch will be cleaner and simpler...

...so...

While writing this..i decided to write the patch I had to move
one variable definition after the config.h include, now it saves
7 LOCs (adds 12 lines)

Tha patch is attached.

--pancake


On Fri, 26 Oct 2007 10:07:01 -0400
"Jeremy O'Brien" <[EMAIL PROTECTED]> wrote:

> I was just wondering how many people here use Jan's taglayouts patch.
> Personally, I won't upgrade to a new version of dwm unless that patch
> has been updated as well (or if I can update it myself). I find it
> indispensable. I guess what I'm getting at is if you guys think it
> should be included in the main dwm tree? (More of a question to Arg I
> think ;) )
> 
> -- 
> Jeremy O'Brien aka neutral_insomniac
> GPG key: 0xB1140FDB http://pohl.ececs.uc.edu/~jeremy/jeremy.asc
> Linux ambelina 2.6.22.9 #1 SMP PREEMPT i686 Intel(R) Pentium(R) M
> processor 1400MHz GenuineIntel GNU/Linux
> 


  --pancake
diff -r 2a3f59cc8d2f dwm.c
--- a/dwm.c	Wed Oct 24 20:34:08 2007 +0200
+++ b/dwm.c	Fri Oct 26 16:49:06 2007 +0200
@@ -198,6 +198,7 @@ int (*xerrorxlib)(Display *, XErrorEvent
 int (*xerrorxlib)(Display *, XErrorEvent *);
 unsigned int bh, bpos;
 unsigned int blw = 0;
+unsigned int csel = 0;
 unsigned int ltidx = 0; /* default */
 unsigned int nlayouts = 0;
 unsigned int nrules = 0;
@@ -235,6 +236,7 @@ Regs *regs = NULL;
 #define NTAGS (sizeof tags / sizeof tags[0])
 Bool seltags[NTAGS] = {[0] = True};
 Bool prevtags[NTAGS] = {[0] = True};
+unsigned int ltidxs[NTAGS];
 
 /* function implementations */
 void
@@ -277,7 +279,7 @@ arrange(void) {
 			unban(c);
 		else
 			ban(c);
-	layouts[ltidx].arrange();
+	layouts[ltidxs[csel]].arrange();
 	focus(NULL);
 	restack();
 }
@@ -549,7 +551,7 @@ drawbar(void) {
 		dc.x += dc.w;
 	}
 	dc.w = blw;
-	drawtext(layouts[ltidx].symbol, dc.norm);
+	drawtext(layouts[ltidxs[csel]].symbol, dc.norm);
 	x = dc.x + dc.w;
 	dc.w = textw(stext);
 	dc.x = sw - dc.w;
@@ -895,7 +897,7 @@ Bool
 Bool
 isarrange(void (*func)())
 {
-	return func == layouts[ltidx].arrange;
+	return func == layouts[ltidxs[csel]].arrange;
 }
 
 Bool
@@ -1378,8 +1380,8 @@ setlayout(const char *arg) {
 	unsigned int i;
 
 	if(!arg) {
-		if(++ltidx == nlayouts)
-			ltidx = 0;;
+		if(++ltidxs[csel] == nlayouts)
+			ltidxs[csel] = 0;
 	}
 	else {
 		for(i = 0; i < nlayouts; i++)
@@ -1387,7 +1389,7 @@ setlayout(const char *arg) {
 				break;
 		if(i == nlayouts)
 			return;
-		ltidx = i;
+		ltidxs[csel] = i;
 	}
 	if(sel)
 		arrange();
@@ -1479,6 +1481,8 @@ setup(void) {
 	dc.h = bh = dc.font.height + 2;
 
 	/* init layouts */
+	for(i = 0; i < NTAGS; i++)
+		ltidxs[i] = 0;
 	mwfact = MWFACT;
 	nlayouts = sizeof layouts / sizeof layouts[0];
 	for(blw = i = 0; i < nlayouts; i++) {
@@ -1673,8 +1677,12 @@ toggleview(const char *arg) {
 	i = idxoftag(arg);
 	seltags[i] = !seltags[i];
 	for(j = 0; j < NTAGS && !seltags[j]; j++);
-	if(j == NTAGS)
+	if(j == NTAGS) {
 		seltags[i] = True; /* at least one tag must be viewed */
+		j = i;
+	}
+	if (csel == i)
+		csel = j;
 	arrange();
 }
 
@@ -1842,12 +1850,17 @@ view(const char *arg) {
 	for(i = 0; i < NTAGS; i++)
 		seltags[i] = arg == NULL;
 	seltags[idxoftag(arg)] = True;
+	csel = idxoftag(arg);
 	arrange();
 }
 
 void
 viewprevtag(const char *arg) {
 	static Bool tmptags[sizeof tags / sizeof tags[0]];
+	int i = 0;
+
+	while(i<NTAGS && !prevtags[i]) i++;
+	csel = i;
 
 	memcpy(tmptags, seltags, sizeof seltags);
 	memcpy(seltags, prevtags, sizeof seltags);

Reply via email to