aboutsummaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-05-23 15:58:32 -0700
committerFuwn <[email protected]>2024-05-23 15:58:32 -0700
commit1f1cc8257b8a6fe2b9bfcb34d05f146c9254d486 (patch)
tree9c3bac15f3b6e0d49b7f9fa29be3698ec768cb97 /dwm.c
parentfeat(dwm.c): dd attachaside patch (diff)
downloadseiwm-1f1cc8257b8a6fe2b9bfcb34d05f146c9254d486.tar.xz
seiwm-1f1cc8257b8a6fe2b9bfcb34d05f146c9254d486.zip
feat(dwm.c): add zoomswap patch
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/dwm.c b/dwm.c
index 19a4b1b..77d6be5 100644
--- a/dwm.c
+++ b/dwm.c
@@ -245,6 +245,7 @@ static void drawbar(Monitor *m);
static void drawbars(void);
static void enternotify(XEvent *e);
static void expose(XEvent *e);
+static Client *findbefore(Client *c);
static void focus(Client *c);
static void focusin(XEvent *e);
static void focusmon(const Arg *arg);
@@ -349,6 +350,7 @@ static pid_t winpid(Window w);
/* variables */
static Systray *systray = NULL;
+static Client *prevzoom = NULL;
static const char broken[] = "broken";
static char stext[256];
static char rawstext[256];
@@ -1096,6 +1098,16 @@ expose(XEvent *e)
}
}
+Client *
+findbefore(Client *c)
+{
+ Client *tmp;
+ if (c == selmon->clients)
+ return NULL;
+ for (tmp = selmon->clients; tmp && tmp->next != c; tmp = tmp->next);
+ return tmp;
+}
+
void
focus(Client *c)
{
@@ -3006,12 +3018,37 @@ void
zoom(const Arg *arg)
{
Client *c = selmon->sel;
+ Client *at = NULL, *cold, *cprevious = NULL;
if (!selmon->lt[selmon->sellt]->arrange || !c || c->isfloating)
return;
- if (c == nexttiled(selmon->clients) && !(c = nexttiled(c->next)))
- return;
- pop(c);
+ if (c == nexttiled(selmon->clients)) {
+ at = findbefore(prevzoom);
+ if (at)
+ cprevious = nexttiled(at->next);
+ if (!cprevious || cprevious != prevzoom) {
+ prevzoom = NULL;
+ if (!c || !(c = nexttiled(c->next)))
+ return;
+ } else
+ c = cprevious;
+ }
+ cold = nexttiled(selmon->clients);
+ if (c != cold && !at)
+ at = findbefore(c);
+ detach(c);
+ attach(c);
+ /* swap windows instead of pushing the previous one down */
+ if (c != cold && at) {
+ prevzoom = cold;
+ if (cold && at != cold) {
+ detach(cold);
+ cold->next = at->next;
+ at->next = cold;
+ }
+ }
+ focus(c);
+ arrange(c->mon);
}
void