sites

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

dwm-zoomswap-6.0.diff (1578B)


      1 Author: Jan Christoph Ebersbach <jceb@e-jc.de>
      2 URL: http://dwm.suckless.org/patches/zoomswap
      3 This patch swaps the current window with the previous master when zooming.
      4 
      5 diff -r ec4baab78314 dwm.c
      6 --- a/dwm.c	Mon Dec 19 15:38:30 2011 +0100
      7 +++ b/dwm.c	Fri Apr 06 08:23:45 2012 +0200
      8 @@ -253,6 +253,7 @@
      9  static void zoom(const Arg *arg);
     10  
     11  /* variables */
     12 +static Client *prevzoom = NULL;
     13  static const char broken[] = "broken";
     14  static char stext[256];
     15  static int screen;
     16 @@ -2116,14 +2117,36 @@
     17  void
     18  zoom(const Arg *arg) {
     19  	Client *c = selmon->sel;
     20 +	Client *at, *tmp;
     21  
     22  	if(!selmon->lt[selmon->sellt]->arrange
     23  	|| (selmon->sel && selmon->sel->isfloating))
     24  		return;
     25 -	if(c == nexttiled(selmon->clients))
     26 -		if(!c || !(c = nexttiled(c->next)))
     27 -			return;
     28 +	if(c == nexttiled(selmon->clients)) {
     29 +		for(tmp = selmon->clients; tmp && tmp != prevzoom; tmp = tmp->next) ;
     30 +		if(tmp != prevzoom)
     31 +			prevzoom = NULL;
     32 +		if(!c || !(c = nexttiled(prevzoom))) {
     33 +			c = selmon->sel;
     34 +			if(!c || !(c = nexttiled(c->next)))
     35 +				return;
     36 +		}
     37 +	}
     38 +	for(at = selmon->clients; at && at->next && at != c && at->next != c; at = nexttiled(at->next)) ;
     39  	pop(c);
     40 +	/* swap windows instead of pushing the previous one down */
     41 +	if(at && at != c) {
     42 +		/* store c's next neighbor - this window needs to be moved away */
     43 +		tmp = prevzoom = c->next;
     44 +		if(c->next != at) {
     45 +			/* detach c's neighbor from the list of windows */
     46 +			c->next = tmp->next;
     47 +			/* attach tmp after c's previous neighbor */
     48 +			tmp->next = at->next;
     49 +			at->next = tmp;
     50 +			arrange(c->mon);
     51 +		}
     52 +	}
     53  }
     54  
     55  int