push.c
branchstil
changeset 1532 4a1df4ff7ca3
equal deleted inserted replaced
1531:606ac98e35df 1532:4a1df4ff7ca3
       
     1 static Client *
       
     2 prevtiled(Client *c) {
       
     3 	Client *p, *r;
       
     4 
       
     5 	for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
       
     6 		if(!p->isfloating && ISVISIBLE(p))
       
     7 			r = p;
       
     8 	return r;
       
     9 }
       
    10 
       
    11 static void
       
    12 pushup(const Arg *arg) {
       
    13 	Client *sel = selmon->sel;
       
    14 	Client *c;
       
    15 
       
    16 	if(!sel || sel->isfloating)
       
    17 		return;
       
    18 	if((c = prevtiled(sel))) {
       
    19 		/* attach before c */
       
    20 		detach(sel);
       
    21 		sel->next = c;
       
    22 		if(selmon->clients == c)
       
    23 			selmon->clients = sel;
       
    24 		else {
       
    25 			for(c = selmon->clients; c->next != sel->next; c = c->next);
       
    26 			c->next = sel;
       
    27 		}
       
    28 	} else {
       
    29 		/* move to the end */
       
    30 		for(c = sel; c->next; c = c->next);
       
    31 		detach(sel);
       
    32 		sel->next = NULL;
       
    33 		c->next = sel;
       
    34 	}
       
    35 	focus(sel);
       
    36 	arrange(selmon);
       
    37 }
       
    38 
       
    39 static void
       
    40 pushdown(const Arg *arg) {
       
    41 	Client *sel = selmon->sel;
       
    42 	Client *c;
       
    43 
       
    44 	if(!sel || sel->isfloating)
       
    45 		return;
       
    46 	if((c = nexttiled(sel->next))) {
       
    47 		/* attach after c */
       
    48 		detach(sel);
       
    49 		sel->next = c->next;
       
    50 		c->next = sel;
       
    51 	} else {
       
    52 		/* move to the front */
       
    53 		detach(sel);
       
    54 		attach(sel);
       
    55 	}
       
    56 	focus(sel);
       
    57 	arrange(selmon);
       
    58 }