Re: [dwm] Yet another simplification, this time sel/prevtags

From: Premysl Hruby <dfenze_AT_gmail.com>
Date: Sun, 20 Apr 2008 22:24:32 +0200

On (20/04/08 21:49), yy wrote:
> To: dynamic window manager <dwm_AT_suckless.org>
> From: yy <yiyu.jgl_AT_gmail.com>
> Subject: Re: [dwm] Yet another simplification, this time sel/prevtags
> Reply-To: dynamic window manager <dwm_AT_suckless.org>
> List-Id: dynamic window manager <dwm.suckless.org>
>
> I like this change, good work Premysl! But once you are using the
> array, you don't need seltags any more. The attached patch saves 2 or
> 3 loc. It also includes the functionality of my patch to see prevtags,
> but if you do the XOR inside memcpy you can save another line of code.
> I have also changed a little your notation (because I don't like
> underscores in variable names), but maybe you can think of better
> names.
> I think I will like dwm 5.0...
>
>

Hi

- if(memcmp(seltags, tmp, TAGSZ) != 0) {
- seltags = viewtags[viewtags_set ^= 1]; /* toggle tagset */
- memcpy(seltags, tmp, TAGSZ);
- arrange();
- }
+ seltags ^= 1; /* toggle sel tagset */
+ if(memcmp(tagset[seltags ^ 1], tmp, TAGSZ) != 0)
+ memcpy(tagset[seltags], tmp, TAGSZ);
+ arrange();

This doesn't do same thing, as seltags is always toggled, even if
current and new tagset are same. So this will broke that "change only if
differ" behaviour or I miss something? :)

If we will throw away this behaviour, things can be even more simpler.
We then can substitute whole view with:

void
view(const char *arg) {
        seltags ^= 1;
        memset(tagset[seltag], (NULL == arg), TAGSZ);
    tagset[seltag][idxoftag(arg)] = True;
    arrange();
}

(memset can be used, because tags are always only test if they are zero
or nonzero, so it doesn't matter that tagset[i][j] (because Bool is defined
as int) can be something like 0x01010101 on x86)

-Ph

-- 
Premysl "Anydot" Hruby, htto://www.redrum.cz
Received on Sun Apr 20 2008 - 22:24:33 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:34:47 UTC