| dwm-zoomswap-20160731-56a31dc.diff - sites - public wiki contents of suckless.o… | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| dwm-zoomswap-20160731-56a31dc.diff (2457B) | |
| --- | |
| 1 Author: Jan Christoph Ebersbach <[email protected]> | |
| 2 URL: http://dwm.suckless.org/patches/zoomswap | |
| 3 This patch swaps the current window with the previous master when zoomin… | |
| 4 | |
| 5 Index: dwm/dwm.c | |
| 6 =================================================================== | |
| 7 --- dwm/dwm.c.orig | |
| 8 +++ dwm/dwm.c | |
| 9 @@ -236,6 +236,7 @@ static int xerrorstart(Display *dpy, XEr | |
| 10 static void zoom(const Arg *arg); | |
| 11 | |
| 12 /* variables */ | |
| 13 +static Client *prevzoom = NULL; | |
| 14 static const char broken[] = "broken"; | |
| 15 static char stext[256]; | |
| 16 static int screen; | |
| 17 @@ -2109,14 +2110,38 @@ void | |
| 18 zoom(const Arg *arg) | |
| 19 { | |
| 20 Client *c = selmon->sel; | |
| 21 + Client *at = NULL, *cold, *cprevious = NULL; | |
| 22 | |
| 23 if (!selmon->lt[selmon->sellt]->arrange | |
| 24 || (selmon->sel && selmon->sel->isfloating)) | |
| 25 return; | |
| 26 - if (c == nexttiled(selmon->clients)) | |
| 27 - if (!c || !(c = nexttiled(c->next))) | |
| 28 - return; | |
| 29 - pop(c); | |
| 30 + if (c == nexttiled(selmon->clients)) { | |
| 31 + at = findbefore(prevzoom); | |
| 32 + if (at) | |
| 33 + cprevious = nexttiled(at->next); | |
| 34 + if (!cprevious || cprevious != prevzoom) { | |
| 35 + prevzoom = NULL; | |
| 36 + if(!c || !(c = nexttiled(c->next))) | |
| 37 + return; | |
| 38 + } else | |
| 39 + c = cprevious; | |
| 40 + } | |
| 41 + cold = nexttiled(selmon->clients); | |
| 42 + if (c != cold && !at) | |
| 43 + at = findbefore(c); | |
| 44 + detach(c); | |
| 45 + attach(c); | |
| 46 + /* swap windows instead of pushing the previous one down */ | |
| 47 + if (c != cold && at) { | |
| 48 + prevzoom = cold; | |
| 49 + if(cold && at != cold) { | |
| 50 + detach(cold); | |
| 51 + cold->next = at->next; | |
| 52 + at->next = cold; | |
| 53 + } | |
| 54 + } | |
| 55 + focus(c); | |
| 56 + arrange(c->mon); | |
| 57 } | |
| 58 | |
| 59 int | |
| 60 Index: dwm/zoomswap.c | |
| 61 =================================================================== | |
| 62 --- /dev/null | |
| 63 +++ dwm/zoomswap.c | |
| 64 @@ -0,0 +1,10 @@ | |
| 65 +static Client * findbefore(Client *c); | |
| 66 + | |
| 67 +Client * | |
| 68 +findbefore(Client *c) { | |
| 69 + Client *tmp; | |
| 70 + if(c == selmon->clients) | |
| 71 + return NULL; | |
| 72 + for(tmp = selmon->clients; tmp && tmp->next != c; tmp = tmp->ne… | |
| 73 + return tmp; | |
| 74 +} | |
| 75 Index: dwm/config.def.h | |
| 76 =================================================================== | |
| 77 --- dwm/config.def.h.orig | |
| 78 +++ dwm/config.def.h | |
| 79 @@ -59,6 +59,7 @@ static char dmenumon[2] = "0"; /* compon | |
| 80 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", d… | |
| 81 static const char *termcmd[] = { "st", NULL }; | |
| 82 | |
| 83 +#include "zoomswap.c" | |
| 84 static Key keys[] = { | |
| 85 /* modifier key function argu… | |
| 86 { MODKEY, XK_p, spawn, {.v … |