Xinqi Bao's Git
   1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> 
   2  * See LICENSE file for license details. 
  10 nexttiled(Client 
*c
) { 
  11         for(; c 
&& (c
->isfloat 
|| !isvisible(c
)); c 
= c
->next
); 
  16 togglemax(Client 
*c
) { 
  22         if((c
->ismax 
= !c
->ismax
)) { 
  27                 resize(c
, wax
, way
, waw 
- 2 * BORDERPX
, wah 
- 2 * BORDERPX
, True
); 
  30                 resize(c
, c
->rx
, c
->ry
, c
->rw
, c
->rh
, True
); 
  31         while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
)); 
  36 void (*arrange
)(void) = DEFMODE
; 
  41                 c
->prev
->next 
= c
->next
; 
  43                 c
->next
->prev 
= c
->prev
; 
  46         c
->next 
= c
->prev 
= NULL
; 
  53         for(c 
= clients
; c
; c 
= c
->next
) { 
  56                                 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
); 
  58                         resize(c
, c
->x
, c
->y
, c
->w
, c
->h
, True
); 
  62                         XMoveWindow(dpy
, c
->win
, c
->x 
+ 2 * sw
, c
->y
); 
  65         if(!sel 
|| !isvisible(sel
)) { 
  66                 for(c 
= stack
; c 
&& !isvisible(c
); c 
= c
->snext
); 
  74         unsigned int i
, n
, nx
, ny
, nw
, nh
, mw
, mh
, tw
, th
; 
  77         for(n 
= 0, c 
= nexttiled(clients
); c
; c 
= nexttiled(c
->next
)) 
  80         mh 
= (n 
> nmaster
) ? wah 
/ nmaster 
: wah 
/ (n 
> 0 ? n 
: 1); 
  81         mw 
= (n 
> nmaster
) ? (waw 
* master
) / 1000 : waw
; 
  82         th 
= (n 
> nmaster
) ? wah 
/ (n 
- nmaster
) : 0; 
  85         for(i 
= 0, c 
= clients
; c
; c 
= c
->next
) 
  88                                 XMoveWindow(dpy
, c
->win
, c
->x
, c
->y
); 
  97                                 nw 
= mw 
- 2 * BORDERPX
; 
  98                                 nh 
= mh 
- 2 * BORDERPX
; 
 100                         else {  /* tile window */ 
 102                                 nw 
= tw 
- 2 * BORDERPX
; 
 103                                 if(th 
> 2 * BORDERPX
) { 
 104                                         ny 
+= (i 
- nmaster
) * th
; 
 105                                         nh 
= th 
- 2 * BORDERPX
; 
 107                                 else /* fallback if th <= 2 * BORDERPX */ 
 108                                         nh 
= wah 
- 2 * BORDERPX
; 
 110                         resize(c
, nx
, ny
, nw
, nh
, False
); 
 115                         XMoveWindow(dpy
, c
->win
, c
->x 
+ 2 * sw
, c
->y
); 
 117         if(!sel 
|| !isvisible(sel
)) { 
 118                 for(c 
= stack
; c 
&& !isvisible(c
); c 
= c
->snext
); 
 125 focusnext(Arg 
*arg
) { 
 130         for(c 
= sel
->next
; c 
&& !isvisible(c
); c 
= c
->next
); 
 132                 for(c 
= clients
; c 
&& !isvisible(c
); c 
= c
->next
); 
 140 focusprev(Arg 
*arg
) { 
 145         for(c 
= sel
->prev
; c 
&& !isvisible(c
); c 
= c
->prev
); 
 147                 for(c 
= clients
; c 
&& c
->next
; c 
= c
->next
); 
 148                 for(; c 
&& !isvisible(c
); c 
= c
->prev
); 
 157 incnmaster(Arg 
*arg
) { 
 158         if((arrange 
== dofloat
) || (nmaster 
+ arg
->i 
< 1) 
 159         || (wah 
/ (nmaster 
+ arg
->i
) <= 2 * BORDERPX
)) 
 169 isvisible(Client 
*c
) { 
 172         for(i 
= 0; i 
< ntags
; i
++) 
 173                 if(c
->tags
[i
] && seltag
[i
]) 
 179 resizemaster(Arg 
*arg
) { 
 180         if(arrange 
!= dotile
) 
 185                 if(waw 
* (master 
+ arg
->i
) / 1000 >= waw 
- 2 * BORDERPX
 
 186                 || waw 
* (master 
+ arg
->i
) / 1000 <= 2 * BORDERPX
) 
 201         if(sel
->isfloat 
|| arrange 
== dofloat
) 
 202                 XRaiseWindow(dpy
, sel
->win
); 
 203         if(arrange 
!= dofloat
) { 
 205                         XLowerWindow(dpy
, sel
->win
); 
 206                 for(c 
= nexttiled(clients
); c
; c 
= nexttiled(c
->next
)) { 
 209                         XLowerWindow(dpy
, c
->win
); 
 213         while(XCheckMaskEvent(dpy
, EnterWindowMask
, &ev
)); 
 217 togglefloat(Arg 
*arg
) { 
 218         if(!sel 
|| arrange 
== dofloat
) 
 220         sel
->isfloat 
= !sel
->isfloat
; 
 225 togglemode(Arg 
*arg
) { 
 226         arrange 
= (arrange 
== dofloat
) ? dotile 
: dofloat
; 
 234 toggleview(Arg 
*arg
) { 
 237         seltag
[arg
->i
] = !seltag
[arg
->i
]; 
 238         for(i 
= 0; i 
< ntags 
&& !seltag
[i
]; i
++); 
 240                 seltag
[arg
->i
] = True
; /* cannot toggle last view */ 
 248         for(i 
= 0; i 
< ntags
; i
++) 
 249                 seltag
[i
] = (arg
->i 
== -1) ? True 
: False
; 
 250         if(arg
->i 
>= 0 && arg
->i 
< ntags
) 
 251                 seltag
[arg
->i
] = True
; 
 262         if(sel
->isfloat 
|| (arrange 
== dofloat
)) { 
 266         for(n 
= 0, c 
= nexttiled(clients
); c
; c 
= nexttiled(c
->next
)) 
 269         if((c 
= sel
) == nexttiled(clients
)) 
 270                 if(!(c 
= nexttiled(c
->next
)))