You are not logged in.
Pages: 1
I am reading dwm.c and there is one thing that I cannot understand.
struct Monitor {
...
unsigned int seltags;
unsigned int tagset[2];
...
};
which means that I can access an element of the tagset array with tagset[0] or tagset[1], right? But everywhere in the code, it is accessed with something like:
m->tagset[m->seltags]
As I understand it, seltags is not restricted to 0 or 1. What am I not understanding?
By the way, what is the meaning of this tagset array?
Offline
The only values that seltags will ever take are 0 and 1. tagset is only used to save the last tagset so you could switch between current and last tagset with Alt-Tab.
Offline
Ok. I got it. I was confused. Thank you.
I thought seltags was a bit array representing the tags themselves. It is actually just a 0 or a 1 and the bit arrays are in the tagset array.
Last edited by Gradient (2013-11-04 10:34:17)
Offline
tagset represents the tags that are selected. There are two tagsets, the currently selected tags and the previously selected tags, seltags just saves the array index of the selected tagset. Here is an example: If you start dwm you'll have the following values:
tagset[0] = 1;
tagset[1] = 1;
seltags = 0;
If you select tag 4 and 5 using Control-Shift-4 and Control-Shift-5 respectively you'll have the following values:
tagset[0] = 49
tagset[1] = 1;
seltags = 0;
If you now select tag 2 using Alt-2 dwm will switch the tagset by setting seltags to 1 and update tagset[seltags], you'll get the following values:
tagset[0] = 49;
tagset[1] = 2;
seltags = 1;
You can know switch between tagset[0] (tags 1, 4, 5) and tagset[1] (tag 2) with Alt-Tab.
Offline
Thank you!
I figured it out and edited my previous post, but you had already seen it. Your explanation is much better.
Last edited by Gradient (2013-11-04 10:44:16)
Offline
Pages: 1