view.c
changeset 573 797e27162b43
parent 565 fe766305eed1
child 584 37281ebc1b5b
equal deleted inserted replaced
572:427708bf5f36 573:797e27162b43
     4 #include "dwm.h"
     4 #include "dwm.h"
     5 
     5 
     6 /* static */
     6 /* static */
     7 
     7 
     8 static Client *
     8 static Client *
     9 minclient(void) {
       
    10 	Client *c, *min;
       
    11 
       
    12 	if((clients && clients->isfloat) || arrange == dofloat)
       
    13 		return clients; /* don't touch floating order */
       
    14 	for(min = c = clients; c; c = c->next)
       
    15 		if(c->weight < min->weight)
       
    16 			min = c;
       
    17 	return min;
       
    18 }
       
    19 
       
    20 static Client *
       
    21 nexttiled(Client *c) {
     9 nexttiled(Client *c) {
    22 	for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
    10 	for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
    23 	return c;
    11 	return c;
    24 }
       
    25 
       
    26 static void
       
    27 reorder(void) {
       
    28 	Client *c, *newclients, *tail;
       
    29 
       
    30 	newclients = tail = NULL;
       
    31 	while((c = minclient())) {
       
    32 		detach(c);
       
    33 		if(tail) {
       
    34 			c->prev = tail;
       
    35 			tail->next = c;
       
    36 			tail = c;
       
    37 		}
       
    38 		else
       
    39 			tail = newclients = c;
       
    40 	}
       
    41 	clients = newclients;
       
    42 }
    12 }
    43 
    13 
    44 static void
    14 static void
    45 togglemax(Client *c) {
    15 togglemax(Client *c) {
    46 	XEvent ev;
    16 	XEvent ev;
   245 
   215 
   246 	seltag[arg->i] = !seltag[arg->i];
   216 	seltag[arg->i] = !seltag[arg->i];
   247 	for(i = 0; i < ntags && !seltag[i]; i++);
   217 	for(i = 0; i < ntags && !seltag[i]; i++);
   248 	if(i == ntags)
   218 	if(i == ntags)
   249 		seltag[arg->i] = True; /* cannot toggle last view */
   219 		seltag[arg->i] = True; /* cannot toggle last view */
   250 	reorder();
       
   251 	arrange();
   220 	arrange();
   252 }
   221 }
   253 
   222 
   254 void
   223 void
   255 view(Arg *arg) {
   224 view(Arg *arg) {
   256 	unsigned int i;
   225 	unsigned int i;
   257 
   226 
   258 	for(i = 0; i < ntags; i++)
   227 	for(i = 0; i < ntags; i++)
   259 		seltag[i] = False;
   228 		seltag[i] = False;
   260 	seltag[arg->i] = True;
   229 	seltag[arg->i] = True;
   261 	reorder();
       
   262 	arrange();
   230 	arrange();
   263 }
   231 }
   264 
   232 
   265 void
   233 void
   266 viewall(Arg *arg) {
   234 viewall(Arg *arg) {
   267 	unsigned int i;
   235 	unsigned int i;
   268 
   236 
   269 	for(i = 0; i < ntags; i++)
   237 	for(i = 0; i < ntags; i++)
   270 		seltag[i] = True;
   238 		seltag[i] = True;
   271 	reorder();
       
   272 	arrange();
   239 	arrange();
   273 }
   240 }
   274 
   241 
   275 void
   242 void
   276 zoom(Arg *arg) {
   243 zoom(Arg *arg) {