aboutsummaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2022-08-25 16:27:36 +0200
committerJoe <bousset.rudy@gmail.com>2022-08-25 16:27:36 +0200
commitf6f49263ed27aa8a289ca636d5e2e79eb17f731f (patch)
tree7a1f642fe7584cb3dd6222457c2c7330ff6b77de /dwm.c
parentstairs (diff)
downloaddwm-f6f49263ed27aa8a289ca636d5e2e79eb17f731f.tar.gz
dwm-f6f49263ed27aa8a289ca636d5e2e79eb17f731f.tar.bz2
dwm-f6f49263ed27aa8a289ca636d5e2e79eb17f731f.tar.xz
dwm-f6f49263ed27aa8a289ca636d5e2e79eb17f731f.tar.zst
dwm-f6f49263ed27aa8a289ca636d5e2e79eb17f731f.zip
up
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/dwm.c b/dwm.c
index 5867298..876e35f 100644
--- a/dwm.c
+++ b/dwm.c
@@ -174,6 +174,7 @@ static void drawbar(Monitor *m);
static void drawbars(void);
static void drawtaggrid(Monitor *m, int *x_pos, unsigned int occ);
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);
@@ -256,6 +257,7 @@ static void bstackhoriz(Monitor *m);
static void stairs(Monitor *m);
/* variables */
+static Client *prevzoom = NULL;
static const char broken[] = "broken";
static char stext[256];
static int screen;
@@ -921,6 +923,16 @@ expose(XEvent *e)
drawbar(m);
}
+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)
{
@@ -2488,14 +2500,38 @@ void
zoom(const Arg *arg)
{
Client *c = selmon->sel;
+ Client *at = NULL, *cold, *cprevious = NULL;
if (!selmon->lt[selmon->sellt]->arrange
|| (selmon->sel && selmon->sel->isfloating))
return;
- if (c == nexttiled(selmon->clients))
- if (!c || !(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);
}
int