Adding zoomswap patch (pertag compatible)

This commit is contained in:
bakkeby 2019-09-05 23:19:23 +02:00
parent 591caea975
commit e681ab5dd9
8 changed files with 94 additions and 4 deletions

View File

@ -11,7 +11,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2019-09-05 - Alpha, systray and pertag patches added
2019-09-05 - Alpha, systray, pertag and zoomswap patches added
### Patches included:
@ -23,3 +23,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [systray](https://dwm.suckless.org/patches/systray/)
- adds system tray in the status bar
- [zoomswap](https://dwm.suckless.org/patches/zoomswap/)
- allows a master and a stack window to swap places rather than every window on the screen changing position

58
dwm.c
View File

@ -197,7 +197,9 @@ static void monocle(Monitor *m);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c);
#if !ZOOMSWAP_PATCH
static void pop(Client *);
#endif // !ZOOMSWAP_PATCH
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
@ -1391,6 +1393,7 @@ nexttiled(Client *c)
return c;
}
#if !ZOOMSWAP_PATCH
void
pop(Client *c)
{
@ -1399,6 +1402,7 @@ pop(Client *c)
focus(c);
arrange(c->mon);
}
#endif // !ZOOMSWAP_PATCH
void
propertynotify(XEvent *e)
@ -2506,14 +2510,66 @@ void
zoom(const Arg *arg)
{
Client *c = selmon->sel;
#if ZOOMSWAP_PATCH
Client *at = NULL, *cold, *cprevious = NULL, *p;
#endif // ZOOMSWAP_PATCH
if (!selmon->lt[selmon->sellt]->arrange
|| (selmon->sel && selmon->sel->isfloating))
|| (selmon->sel && selmon->sel->isfloating)
#if ZOOMSWAP_PATCH
|| !c
#endif // ZOOMSWAP_PATCH
)
return;
#if ZOOMSWAP_PATCH
if (c == nexttiled(selmon->clients)) {
#if PERTAG_PATCH
p = selmon->pertag->prevzooms[selmon->pertag->curtag];
#else
p = prevzoom;
#endif // PERTAG_PATCH
at = prevtiled(p);
if (at)
cprevious = nexttiled(at->next);
if (!cprevious || cprevious != p) {
#if PERTAG_PATCH
selmon->pertag->prevzooms[selmon->pertag->curtag] = NULL;
#else
prevzoom = NULL;
#endif // PERTAG_PATCH
if (!c || !(c = nexttiled(c->next)))
return;
} else
c = cprevious;
}
cold = nexttiled(selmon->clients);
if (c != cold && !at)
at = prevtiled(c);
detach(c);
attach(c);
/* swap windows instead of pushing the previous one down */
if (c != cold && at) {
#if PERTAG_PATCH
selmon->pertag->prevzooms[selmon->pertag->curtag] = cold;
#else
prevzoom = cold;
#endif // PERTAG_PATCH
if (cold && at != cold) {
detach(cold);
cold->next = at->next;
at->next = cold;
}
}
focus(c);
arrange(c->mon);
#else
if (c == nexttiled(selmon->clients))
if (!c || !(c = nexttiled(c->next)))
return;
pop(c);
#endif // ZOOMSWAP_PATCH
}
int

View File

@ -9,3 +9,7 @@
#if SYSTRAY_PATCH
#include "systray.c"
#endif
#if ZOOMSWAP_PATCH
#include "zoomswap.c"
#endif // ZOOMSWAP_PATCH

View File

@ -4,4 +4,8 @@
#if SYSTRAY_PATCH
#include "systray.h"
#endif
#endif
#if ZOOMSWAP_PATCH
#include "zoomswap.h"
#endif // ZOOMSWAP_PATCH

View File

@ -7,5 +7,7 @@ struct Pertag {
#if PERTAGBAR_PATCH
Bool showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
#endif // PERTAGBAR_PATCH
#if ZOOMSWAP_PATCH
Client *prevzooms[LENGTH(tags) + 1]; /* store zoom information */
#endif // ZOOMSWAP_PATCH
};

13
patch/zoomswap.c Normal file
View File

@ -0,0 +1,13 @@
#if !PERTAG_PATCH
static Client *prevzoom = NULL;
#endif // PERTAG_PATCH
Client *
prevtiled(Client *c) {
Client *p;
if (!c || c == c->mon->clients)
return NULL;
for (p = c->mon->clients; p && p->next != c; p = p->next);
return p;
}

1
patch/zoomswap.h Normal file
View File

@ -0,0 +1 @@
static Client *prevtiled(Client *c);

View File

@ -26,4 +26,10 @@
/* This controls whether or not to also store bar position on a per
* tag basis, or leave it as one bar per monitor.
*/
#define PERTAGBAR_PATCH 0
#define PERTAGBAR_PATCH 0
/* The zoomswap patch allows a master and a stack window to swap places
* rather than every window on the screen changing position.
* https://dwm.suckless.org/patches/zoomswap/
*/
#define ZOOMSWAP_PATCH 0