dwm-zoomswap-6.2.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-zoomswap-6.2.diff (2378B) | |
--- | |
1 From 3867ef5a68e15a4faff377ddbc8371853de4a800 Mon Sep 17 00:00:00 2001 | |
2 From: aleks <[email protected]> | |
3 Date: Sat, 19 Oct 2019 00:56:21 +0200 | |
4 Subject: [PATCH] Put master to exact position of zoomed client | |
5 | |
6 The default behaviour when zooming a client is to put the previous | |
7 master on top of the client-stack. This patch puts the master to the | |
8 exact position of the zoomed client in the stack. | |
9 --- | |
10 dwm.c | 44 ++++++++++++++++++++++++++++++++++++++++---- | |
11 1 file changed, 40 insertions(+), 4 deletions(-) | |
12 | |
13 diff --git a/dwm.c b/dwm.c | |
14 index 4465af1..1719b36 100644 | |
15 --- a/dwm.c | |
16 +++ b/dwm.c | |
17 @@ -165,6 +165,7 @@ static void drawbar(Monitor *m); | |
18 static void drawbars(void); | |
19 static void enternotify(XEvent *e); | |
20 static void expose(XEvent *e); | |
21 +static Client *findbefore(Client *c); | |
22 static void focus(Client *c); | |
23 static void focusin(XEvent *e); | |
24 static void focusmon(const Arg *arg); | |
25 @@ -235,6 +236,7 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee… | |
26 static void zoom(const Arg *arg); | |
27 | |
28 /* variables */ | |
29 +static Client *prevzoom = NULL; | |
30 static const char broken[] = "broken"; | |
31 static char stext[256]; | |
32 static int screen; | |
33 @@ -780,6 +782,16 @@ expose(XEvent *e) | |
34 drawbar(m); | |
35 } | |
36 | |
37 +Client * | |
38 +findbefore(Client *c) | |
39 +{ | |
40 + Client *tmp; | |
41 + if (c == selmon->clients) | |
42 + return NULL; | |
43 + for (tmp = selmon->clients; tmp && tmp->next != c; tmp = tmp->n… | |
44 + return tmp; | |
45 +} | |
46 + | |
47 void | |
48 focus(Client *c) | |
49 { | |
50 @@ -2114,14 +2126,38 @@ void | |
51 zoom(const Arg *arg) | |
52 { | |
53 Client *c = selmon->sel; | |
54 + Client *at = NULL, *cold, *cprevious = NULL; | |
55 | |
56 if (!selmon->lt[selmon->sellt]->arrange | |
57 || (selmon->sel && selmon->sel->isfloating)) | |
58 return; | |
59 - if (c == nexttiled(selmon->clients)) | |
60 - if (!c || !(c = nexttiled(c->next))) | |
61 - return; | |
62 - pop(c); | |
63 + if (c == nexttiled(selmon->clients)) { | |
64 + at = findbefore(prevzoom); | |
65 + if (at) | |
66 + cprevious = nexttiled(at->next); | |
67 + if (!cprevious || cprevious != prevzoom) { | |
68 + prevzoom = NULL; | |
69 + if (!c || !(c = nexttiled(c->next))) | |
70 + return; | |
71 + } else | |
72 + c = cprevious; | |
73 + } | |
74 + cold = nexttiled(selmon->clients); | |
75 + if (c != cold && !at) | |
76 + at = findbefore(c); | |
77 + detach(c); | |
78 + attach(c); | |
79 + /* swap windows instead of pushing the previous one down */ | |
80 + if (c != cold && at) { | |
81 + prevzoom = cold; | |
82 + if (cold && at != cold) { | |
83 + detach(cold); | |
84 + cold->next = at->next; | |
85 + at->next = cold; | |
86 + } | |
87 + } | |
88 + focus(c); | |
89 + arrange(c->mon); | |
90 } | |
91 | |
92 int | |
93 -- | |
94 2.23.0 | |
95 |