view.c
changeset 380 4bf79305d675
parent 378 83576f5f0a90
child 381 b00cc483d13b
equal deleted inserted replaced
379:fc279cd6c7be 380:4bf79305d675
     2  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     2  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     3  * See LICENSE file for license details.
     3  * See LICENSE file for license details.
     4  */
     4  */
     5 #include "dwm.h"
     5 #include "dwm.h"
     6 
     6 
       
     7 /* static */
       
     8 
       
     9 static Client *
       
    10 getslot(Client *c)
       
    11 {
       
    12 	unsigned int i, tic;
       
    13 	Client *p;
       
    14 
       
    15 	for(tic = 0; tic < ntags && !c->tags[tic]; tic++);
       
    16 	for(p = clients; p; p = p->next) {
       
    17 		for(i = 0; i < ntags && !p->tags[i]; i++);
       
    18 		if(tic < i)
       
    19 			return p;
       
    20 	}
       
    21 	return p;
       
    22 }
       
    23 
       
    24 static Client *
       
    25 tail()
       
    26 {
       
    27 	Client *c;
       
    28 	for(c = clients; c && c->next; c = c->next);
       
    29 	return c;
       
    30 }
       
    31 
     7 /* extern */
    32 /* extern */
     8 
    33 
     9 void (*arrange)(Arg *) = DEFMODE;
    34 void (*arrange)(Arg *) = DEFMODE;
    10 
    35 
    11 void
    36 void
    12 attach(Client *c)
    37 attach(Client *c)
    13 {
    38 {
    14 	Client *first = getnext(clients);
    39 	Client *p;
    15 
    40 
    16 	if(!first) {
    41 	if(!clients) {
    17 		if(clients) {
    42 		clients = c;
    18 			for(first = clients; first->next; first = first->next);
    43 		return;
    19 			first->next = c;
    44 	}
    20 			c->prev = first;
    45 	if(!(p = getnext(clients)) && !(p = getslot(c))) {
    21 		}
    46 		p = tail();
    22 		else
    47 		c->prev = p;
    23 			clients = c;
    48 		p->next = c;
    24 	}
    49 		return;
    25 	else if(first == clients) {
    50 	}
       
    51 
       
    52 	if(p == clients) {
    26 		c->next = clients;
    53 		c->next = clients;
    27 		clients->prev = c;
    54 		clients->prev = c;
    28 		clients = c;
    55 		clients = c;
    29 	}
    56 	}
    30 	else {
    57 	else {
    31 		first->prev->next = c;
    58 		p->prev->next = c;
    32 		c->prev = first->prev;
    59 		c->prev = p->prev;
    33 		first->prev = c;
    60 		p->prev = c;
    34 		c->next = first;
    61 		c->next = p;
    35 	}
    62 	}
    36 }
    63 }
    37 
    64 
    38 void
    65 void
    39 detach(Client *c)
    66 detach(Client *c)