summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2019-09-05 22:58:16 +0200
committerbakkeby <[email protected]>2019-09-05 22:58:16 +0200
commit591caea975327d912b0650dd7cbbf66329c40585 (patch)
treedd898b1273288220bb769805dd61feab3e2e8492
parentcba0991170279af11684066526e4e70abec20438 (diff)
downloaddwm-flexipatch-591caea975327d912b0650dd7cbbf66329c40585.tar.gz
dwm-flexipatch-591caea975327d912b0650dd7cbbf66329c40585.zip
Added pertag patch
-rw-r--r--README.md8
-rw-r--r--dwm.c117
-rw-r--r--patch/include.c4
-rw-r--r--patch/pertag.c11
-rw-r--r--patches.h19
5 files changed, 150 insertions, 9 deletions
diff --git a/README.md b/README.md
index 64b6df3..8af4f53 100644
--- a/README.md
+++ b/README.md
@@ -11,13 +11,15 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
-2019-09-05 - Systray patch added
-2019-09-05 - Alpha patch added
+2019-09-05 - Alpha, systray and pertag patches added
### Patches included:
- [alpha](https://dwm.suckless.org/patches/alpha/)
- adds transparency for the status bar
+ - [pertag](https://dwm.suckless.org/patches/pertag/)
+ - adds nmaster, mfact, layouts and more per tag rather than per monitor
+
- [systray](https://dwm.suckless.org/patches/systray/)
- - adds system tray in the status bar \ No newline at end of file
+ - adds system tray in the status bar
diff --git a/dwm.c b/dwm.c
index 7c46ca7..228f14d 100644
--- a/dwm.c
+++ b/dwm.c
@@ -118,6 +118,9 @@ typedef struct {
void (*arrange)(Monitor *);
} Layout;
+#if PERTAG_PATCH
+typedef struct Pertag Pertag;
+#endif // PERTAG_PATCH
struct Monitor {
char ltsymbol[16];
float mfact;
@@ -137,6 +140,9 @@ struct Monitor {
Monitor *next;
Window barwin;
const Layout *lt[2];
+ #if PERTAG_PATCH
+ Pertag *pertag;
+ #endif // PERTAG_PATCH
};
typedef struct {
@@ -713,6 +719,9 @@ Monitor *
createmon(void)
{
Monitor *m;
+ #if PERTAG_PATCH
+ int i;
+ #endif // PERTAG_PATCH
m = ecalloc(1, sizeof(Monitor));
m->tagset[0] = m->tagset[1] = 1;
@@ -723,6 +732,31 @@ createmon(void)
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+ #if PERTAG_PATCH
+ if (!(m->pertag = (Pertag *)calloc(1, sizeof(Pertag))))
+ die("fatal: could not malloc() %u bytes\n", sizeof(Pertag));
+ m->pertag->curtag = m->pertag->prevtag = 1;
+ for (i=0; i <= LENGTH(tags); i++) {
+ /* init nmaster */
+ m->pertag->nmasters[i] = m->nmaster;
+
+ /* init mfacts */
+ m->pertag->mfacts[i] = m->mfact;
+
+ /* init layouts */
+ m->pertag->ltidxs[i][0] = m->lt[0];
+ m->pertag->ltidxs[i][1] = m->lt[1];
+ m->pertag->sellts[i] = m->sellt;
+
+ #if PERTAGBAR_PATCH
+ /* init showbar */
+ m->pertag->showbars[i] = m->showbar;
+
+ /* swap focus and zoomswap*/
+ m->pertag->prevzooms[i] = NULL;
+ #endif // PERTAGBAR_PATCH
+ }
+ #endif // PERTAG_PATCH
return m;
}
@@ -1108,7 +1142,11 @@ grabkeys(void)
void
incnmaster(const Arg *arg)
{
+ #if PERTAG_PATCH
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
+ #else
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
+ #endif // PERTAG_PATCH
arrange(selmon);
}
@@ -1705,10 +1743,21 @@ setfullscreen(Client *c, int fullscreen)
void
setlayout(const Arg *arg)
{
- if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+ if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) {
+ #if PERTAG_PATCH
+ selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
+ #else
selmon->sellt ^= 1;
+ #endif // PERTAG_PATCH
+ }
if (arg && arg->v)
+ #if PERTAG_PATCH
+ selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
+ #else
selmon->lt[selmon->sellt] = (Layout *)arg->v;
+ #endif // PERTAG_PATCH
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if (selmon->sel)
arrange(selmon);
@@ -1727,7 +1776,11 @@ setmfact(const Arg *arg)
f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
if (f < 0.1 || f > 0.9)
return;
+ #if PERTAG_PATCH
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
+ #else
selmon->mfact = f;
+ #endif // PERTAG_PATCH
arrange(selmon);
}
@@ -1929,7 +1982,11 @@ tile(Monitor *m)
void
togglebar(const Arg *arg)
{
+ #if PERTAG_PATCH && PERTAGBAR_PATCH
+ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
+ #else
selmon->showbar = !selmon->showbar;
+ #endif // PERTAG_PATCH
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
#if SYSTRAY_PATCH
@@ -1981,9 +2038,36 @@ void
toggleview(const Arg *arg)
{
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
+ #if PERTAG_PATCH
+ int i;
+ #endif // PERTAG_PATCH
if (newtagset) {
selmon->tagset[selmon->seltags] = newtagset;
+
+ #if PERTAG_PATCH
+ if (newtagset == ~0) {
+ selmon->pertag->prevtag = selmon->pertag->curtag;
+ selmon->pertag->curtag = 0;
+ }
+ /* test if the user did not select the same tag */
+ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
+ selmon->pertag->prevtag = selmon->pertag->curtag;
+ for (i=0; !(newtagset & 1 << i); i++) ;
+ selmon->pertag->curtag = i + 1;
+ }
+
+ /* apply settings for this view */
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
+ #if PERTAGBAR_PATCH
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
+ togglebar(NULL);
+ #endif // PERTAGBAR_PATCH
+ #endif // PERTAG_PATCH
focus(NULL);
arrange(selmon);
}
@@ -2312,11 +2396,42 @@ updatewmhints(Client *c)
void
view(const Arg *arg)
{
+ #if PERTAG_PATCH
+ int i;
+ unsigned int tmptag;
+ #endif // PERTAG_PATCH
+
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
+ #if PERTAG_PATCH
+ if (arg->ui & TAGMASK) {
+ selmon->pertag->prevtag = selmon->pertag->curtag;
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ if (arg->ui == ~0)
+ selmon->pertag->curtag = 0;
+ else {
+ for (i=0; !(arg->ui & 1 << i); i++) ;
+ selmon->pertag->curtag = i + 1;
+ }
+ } else {
+ tmptag = selmon->pertag->prevtag;
+ selmon->pertag->prevtag = selmon->pertag->curtag;
+ selmon->pertag->curtag = tmptag;
+ }
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
+ #if PERTAGBAR_PATCH
+ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
+ togglebar(NULL);
+ #endif // PERTAGBAR_PATCH
+ #else
if (arg->ui & TAGMASK)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ #endif // PERTAG_PATCH
focus(NULL);
arrange(selmon);
}
diff --git a/patch/include.c b/patch/include.c
index 67bbf91..811fadd 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -2,6 +2,10 @@
#include "alpha.c"
#endif
+#if PERTAG_PATCH
+#include "pertag.c"
+#endif
+
#if SYSTRAY_PATCH
#include "systray.c"
#endif
diff --git a/patch/pertag.c b/patch/pertag.c
new file mode 100644
index 0000000..818c7ab
--- /dev/null
+++ b/patch/pertag.c
@@ -0,0 +1,11 @@
+struct Pertag {
+ unsigned int curtag, prevtag; /* current and previous tag */
+ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
+ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
+ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
+ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
+ #if PERTAGBAR_PATCH
+ Bool showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
+ #endif // PERTAGBAR_PATCH
+ Client *prevzooms[LENGTH(tags) + 1]; /* store zoom information */
+}; \ No newline at end of file
diff --git a/patches.h b/patches.h
index d998b53..8fe09ec 100644
--- a/patches.h
+++ b/patches.h
@@ -7,14 +7,23 @@
* relevant descriptions.
*/
-/*
- * The alpha patch adds transparency for the status bar.
+/* The alpha patch adds transparency for the status bar.
* https://dwm.suckless.org/patches/alpha/
*/
#define ALPHA_PATCH 0
-/*
- * The systray patch adds systray for the status bar.
+/* The systray patch adds systray for the status bar.
* https://dwm.suckless.org/patches/systray/
*/
-#define SYSTRAY_PATCH 0 \ No newline at end of file
+#define SYSTRAY_PATCH 0
+
+/* The pertag patch adds nmaster, mfacts and layouts per tag rather
+ * than per monitor (default).
+ * https://dwm.suckless.org/patches/pertag/
+ */
+#define PERTAG_PATCH 0
+
+/* 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 \ No newline at end of file