sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-push-6.1.diff (1402B)


      1 URL: http://dwm.suckless.org/patches/push
      2 pushup and pushdown provide a way to move clients inside the clients list.
      3 
      4 Index: dwm/push.c
      5 ===================================================================
      6 --- /dev/null	1970-01-01 00:00:00.000000000 +0000
      7 +++ dwm/push.c	2014-02-09 15:24:21.652117230 +0100
      8 @@ -0,0 +1,58 @@
      9 +static Client *
     10 +prevtiled(Client *c) {
     11 +	Client *p, *r;
     12 +
     13 +	for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
     14 +		if(!p->isfloating && ISVISIBLE(p))
     15 +			r = p;
     16 +	return r;
     17 +}
     18 +
     19 +static void
     20 +pushup(const Arg *arg) {
     21 +	Client *sel = selmon->sel;
     22 +	Client *c;
     23 +
     24 +	if(!sel || sel->isfloating)
     25 +		return;
     26 +	if((c = prevtiled(sel))) {
     27 +		/* attach before c */
     28 +		detach(sel);
     29 +		sel->next = c;
     30 +		if(selmon->clients == c)
     31 +			selmon->clients = sel;
     32 +		else {
     33 +			for(c = selmon->clients; c->next != sel->next; c = c->next);
     34 +			c->next = sel;
     35 +		}
     36 +	} else {
     37 +		/* move to the end */
     38 +		for(c = sel; c->next; c = c->next);
     39 +		detach(sel);
     40 +		sel->next = NULL;
     41 +		c->next = sel;
     42 +	}
     43 +	focus(sel);
     44 +	arrange(selmon);
     45 +}
     46 +
     47 +static void
     48 +pushdown(const Arg *arg) {
     49 +	Client *sel = selmon->sel;
     50 +	Client *c;
     51 +
     52 +	if(!sel || sel->isfloating)
     53 +		return;
     54 +	if((c = nexttiled(sel->next))) {
     55 +		/* attach after c */
     56 +		detach(sel);
     57 +		sel->next = c->next;
     58 +		c->next = sel;
     59 +	} else {
     60 +		/* move to the front */
     61 +		detach(sel);
     62 +		attach(sel);
     63 +	}
     64 +	focus(sel);
     65 +	arrange(selmon);
     66 +}