summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--README.md1
-rw-r--r--dwm.c180
3 files changed, 188 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..6d67fd2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,7 @@
+.config
+.config.old
+*.o
+dwm
+*.sh
+mconf
+kconf2h/kconf2h \ No newline at end of file
diff --git a/README.md b/README.md
index 0b183a2..29f4674 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ pango
systemtray
### branch 6.1/master ###
+pertag
## Menuconfig ##
All patches can be turned off/on with menuconfig. Configuration
diff --git a/dwm.c b/dwm.c
index 0362114..b9aa28b 100644
--- a/dwm.c
+++ b/dwm.c
@@ -41,6 +41,8 @@
#endif /* XINERAMA */
#include <X11/Xft/Xft.h>
+#include "kconfig.h"
+
#include "drw.h"
#include "util.h"
@@ -111,6 +113,11 @@ typedef struct {
void (*arrange)(Monitor *);
} Layout;
+/* PERTAG */
+#ifdef CONFIG_DWM_PERTAG
+typedef struct Pertag Pertag;
+#endif
+
struct Monitor {
char ltsymbol[16];
float mfact;
@@ -130,6 +137,11 @@ struct Monitor {
Monitor *next;
Window barwin;
const Layout *lt[2];
+
+/* PERTAG */
+#ifdef CONFIG_DWM_PERTAG
+ Pertag *pertag;
+#endif
};
typedef struct {
@@ -270,6 +282,20 @@ static Window root;
/* configuration, allows nested code to access above variables */
#include "config.h"
+/* PERTAG */
+#ifdef CONFIG_DWM_PERTAG
+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 */
+ Bool showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
+ Client *prevzooms[LENGTH(tags) + 1]; /* store zoom information */
+};
+#endif
+
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -527,6 +553,11 @@ clientmessage(XEvent *e)
XClientMessageEvent *cme = &e->xclient;
Client *c = wintoclient(cme->window);
+/* PERTAG */
+#ifdef CONFIG_DWM_PERTAG
+ int i;
+#endif
+
if (!c)
return;
if (cme->message_type == netatom[NetWMState]) {
@@ -537,7 +568,14 @@ clientmessage(XEvent *e)
if (!ISVISIBLE(c)) {
c->mon->seltags ^= 1;
c->mon->tagset[c->mon->seltags] = c->tags;
+/******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ for(i=0; !(c->tags & 1 << i); i++);
+ view(&(Arg){.ui = 1 << i});
+#endif
+/******************************************************************************/
}
+
pop(c);
}
}
@@ -641,6 +679,12 @@ createmon(void)
{
Monitor *m;
+/******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ int i;
+#endif
+/******************************************************************************/
+
m = ecalloc(1, sizeof(Monitor));
m->tagset[0] = m->tagset[1] = 1;
m->mfact = mfact;
@@ -650,6 +694,31 @@ createmon(void)
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
+/******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ 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;
+
+ /* init showbar */
+ m->pertag->showbars[i] = m->showbar;
+
+ /* swap focus and zoomswap*/
+ m->pertag->prevzooms[i] = NULL;
+ }
+#endif
+/******************************************************************************/
return m;
}
@@ -981,10 +1050,17 @@ grabkeys(void)
void
incnmaster(const Arg *arg)
{
+/******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
+#else
+/******************************************************************************/
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
+#endif
arrange(selmon);
}
+
#ifdef XINERAMA
static int
isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info)
@@ -1517,10 +1593,29 @@ setfullscreen(Client *c, int fullscreen)
void
setlayout(const Arg *arg)
{
+
+/******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) {
+ selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
+ }
+#else
+/******************************************************************************/
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
selmon->sellt ^= 1;
if (arg && arg->v)
+#endif
+
+/******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ 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
+
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
if (selmon->sel)
arrange(selmon);
@@ -1539,7 +1634,13 @@ 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;
+#ifdef CONFIG_DWM_PERTAG
+/******************************************************************************/
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
+#else
+/******************************************************************************/
selmon->mfact = f;
+#endif
arrange(selmon);
}
@@ -1692,7 +1793,14 @@ tile(Monitor *m)
void
togglebar(const Arg *arg)
{
+/*******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
+#else
+/*******************************************************************************/
selmon->showbar = !selmon->showbar;
+#endif
+
updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
arrange(selmon);
@@ -1731,9 +1839,45 @@ void
toggleview(const Arg *arg)
{
unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
+/*******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ int i;
+#endif
+/*******************************************************************************/
if (newtagset) {
+
+/*******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ 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;
+ }
+#endif
+/*******************************************************************************/
+
selmon->tagset[selmon->seltags] = newtagset;
+
+/*******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+
+ /* 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 (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
+ togglebar(NULL);
+#endif
+/*******************************************************************************/
+
focus(NULL);
arrange(selmon);
}
@@ -2031,11 +2175,47 @@ updatewmhints(Client *c)
void
view(const Arg *arg)
{
+
+/******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ int i;
+ unsigned int tmptag;
+#endif
+/******************************************************************************/
+
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
+
+/******************************************************************************/
+#ifdef CONFIG_DWM_PERTAG
+ 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 (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
+ togglebar(NULL);
+#else
+/******************************************************************************/
if (arg->ui & TAGMASK)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+#endif
+
focus(NULL);
arrange(selmon);
}