dwm

suckless dynamic window manager
git clone https://git.beauhilton.com/dwm.git
Log | Files | Refs | README | LICENSE

shiftview.c (849B)


      1 /** Function to shift the current view to the left/right
      2  *
      3  * @param: "arg->i" stores the number of tags to shift right (positive value)
      4  *          or left (negative value)
      5  */
      6 void
      7 shiftview(const Arg *arg)
      8 {
      9 	Arg a;
     10 	Client *c;
     11 	unsigned visible = 0;
     12 	int i = arg->i;
     13 	int count = 0;
     14 	int nextseltags, curseltags = selmon->tagset[selmon->seltags];
     15 
     16 	do {
     17 		if(i > 0) // left circular shift
     18 			nextseltags = (curseltags << i) | (curseltags >> (LENGTH(tags) - i));
     19 
     20 		else // right circular shift
     21 			nextseltags = curseltags >> (- i) | (curseltags << (LENGTH(tags) + i));
     22 
     23                 // Check if tag is visible
     24 		for (c = selmon->clients; c && !visible; c = c->next)
     25 			if (nextseltags & c->tags) {
     26 				visible = 1;
     27 				break;
     28 			}
     29 		i += arg->i;
     30 	} while (!visible && ++count < 10);
     31 
     32 	if (count < 10) {
     33 		a.i = nextseltags;
     34 		view(&a);
     35 	}
     36 }