[dwm] patch: don't update prevtags if nothing changed

2008-01-30 Thread David Edmondson
MODKEY-Tab is very nice for bouncing between tags, but sometimes I
re-select the current tag using MODKEY-n (where n is 1-9). Now
both seltags and prevtags contain the same set, meaning that
MODKEY-Tab does nothing useful.

This patch modifies the view() function so that it doesn't change
prevtags unless the new set of tags is different from the old.

I'm a new dwm user, so it's entirely possible that I've missed
something in the zen of it all - feedback appreciated.

dme.
# HG changeset patch
# User David Edmondson [EMAIL PROTECTED]
# Date 1201697367 0
# Node ID 5d3dd7a910209317156aef400c7875c71a1ffcbf
# Parent  5cfd3c602edec1519568ebc7f8e443006c239b3b
When switching viewed tags, don't update prevtags unless something
actually changed.

diff --git a/dwm.c b/dwm.c
--- a/dwm.c
+++ b/dwm.c
@@ -1930,14 +1930,19 @@ void
 void
 view(const char *arg) {
 	unsigned int i;
+	Bool tmp[LENGTH(tags)];
 
 	Monitor *m = monitors[monitorat(-1, -1)];
 
-	memcpy(m-prevtags, m-seltags, sizeof initags);
 	for(i = 0; i  LENGTH(tags); i++)
-		m-seltags[i] = (NULL == arg);
-	m-seltags[idxoftag(arg)] = True;
-	arrange();
+		tmp[i] = (NULL == arg);
+	tmp[idxoftag(arg)] = True;
+
+	if (memcmp(m-seltags, tmp, sizeof initags) != 0) {
+		memcpy(m-prevtags, m-seltags, sizeof initags);
+		memcpy(m-seltags, tmp, sizeof initags);
+		arrange();
+	}
 }
 
 void

dme.
-- 
David Edmondson, http://dme.org


Re: [dwm] patch: don't update prevtags if nothing changed

2008-01-30 Thread Anselm R. Garbe
Will be included in 4.8

--Anselm

On Wed, Jan 30, 2008 at 04:11:49PM +0100, pancake wrote:
 I'm with this patch! :)
 
 I send a proposal for this few months ago.. i'll try't at night
 
 Thanks
 
 --pancake
 
 On Wed, Jan 30, 2008 at 01:03:33PM +, David Edmondson wrote:
  MODKEY-Tab is very nice for bouncing between tags, but sometimes I
  re-select the current tag using MODKEY-n (where n is 1-9). Now
  both seltags and prevtags contain the same set, meaning that
  MODKEY-Tab does nothing useful.
  
  This patch modifies the view() function so that it doesn't change
  prevtags unless the new set of tags is different from the old.
  
  I'm a new dwm user, so it's entirely possible that I've missed
  something in the zen of it all - feedback appreciated.
  
  dme.
 
 
  
  dme.
  -- 
  David Edmondson, http://dme.org
 
 

-- 
 Anselm R. Garbe  http://www.suckless.org/  GPG key: 0D73F361



Re: [dwm] patch: don't update prevtags if nothing changed

2008-01-30 Thread pancake
I'm with this patch! :)

I send a proposal for this few months ago.. i'll try't at night

Thanks

--pancake

On Wed, Jan 30, 2008 at 01:03:33PM +, David Edmondson wrote:
 MODKEY-Tab is very nice for bouncing between tags, but sometimes I
 re-select the current tag using MODKEY-n (where n is 1-9). Now
 both seltags and prevtags contain the same set, meaning that
 MODKEY-Tab does nothing useful.
 
 This patch modifies the view() function so that it doesn't change
 prevtags unless the new set of tags is different from the old.
 
 I'm a new dwm user, so it's entirely possible that I've missed
 something in the zen of it all - feedback appreciated.
 
 dme.


 
 dme.
 -- 
 David Edmondson, http://dme.org