sites

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

dwm-movestack-5.8.2.diff (2581B)


      1 diff -r 050d521d66d8 config.def.h
      2 --- a/config.def.h	Tue Aug 24 13:13:20 2010 +0100
      3 +++ b/config.def.h	Sun Sep 05 18:43:07 2010 +0200
      4 @@ -48,6 +48,7 @@
      5  static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
      6  static const char *termcmd[]  = { "uxterm", NULL };
      7  
      8 +#include "movestack.c"
      9  static Key keys[] = {
     10  	/* modifier                     key        function        argument */
     11  	{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
     12 @@ -57,6 +58,8 @@
     13  	{ MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
     14  	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
     15  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
     16 +	{ MODKEY|ShiftMask,             XK_j,      movestack,      {.i = +1 } },
     17 +	{ MODKEY|ShiftMask,             XK_k,      movestack,      {.i = -1 } },
     18  	{ MODKEY,                       XK_Return, zoom,           {0} },
     19  	{ MODKEY,                       XK_Tab,    view,           {0} },
     20  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     21 diff -r 050d521d66d8 movestack.c
     22 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     23 +++ b/movestack.c	Sun Sep 05 18:43:07 2010 +0200
     24 @@ -0,0 +1,49 @@
     25 +void
     26 +movestack(const Arg *arg) {
     27 +	Client *c = NULL, *p = NULL, *pc = NULL, *i;
     28 +
     29 +	if(arg->i > 0) {
     30 +		/* find the client after selmon->sel */
     31 +		for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
     32 +		if(!c)
     33 +			for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
     34 +
     35 +	}
     36 +	else {
     37 +		/* find the client before selmon->sel */
     38 +		for(i = selmon->clients; i != selmon->sel; i = i->next)
     39 +			if(ISVISIBLE(i) && !i->isfloating)
     40 +				c = i;
     41 +		if(!c)
     42 +			for(; i; i = i->next)
     43 +				if(ISVISIBLE(i) && !i->isfloating)
     44 +					c = i;
     45 +	}
     46 +	/* find the client before selmon->sel and c */
     47 +	for(i = selmon->clients; i && (!p || !pc); i = i->next) {
     48 +		if(i->next == selmon->sel)
     49 +			p = i;
     50 +		if(i->next == c)
     51 +			pc = i;
     52 +	}
     53 +
     54 +	/* swap c and selmon->sel selmon->clients in the selmon->clients list */
     55 +	if(c && c != selmon->sel) {
     56 +		Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
     57 +		selmon->sel->next = c->next==selmon->sel?c:c->next;
     58 +		c->next = temp;
     59 +
     60 +		if(p && p != c)
     61 +			p->next = c;
     62 +		if(pc && pc != selmon->sel)
     63 +			pc->next = selmon->sel;
     64 +
     65 +		if(selmon->sel == selmon->clients)
     66 +			selmon->clients = c;
     67 +		else if(c == selmon->clients)
     68 +			selmon->clients = selmon->sel;
     69 +
     70 +		arrange(selmon);
     71 +	}
     72 +}
     73 +