[wiki] [sites] [dwm][pertag] Update against current git HEAD || Ivan Tham

From: <git_AT_suckless.org>
Date: Sat, 31 Oct 2015 08:19:57 +0100

commit 8e4a57cf1ff49b4e308aed104254d7c75105e5f1
Author: Ivan Tham <pickfire_AT_riseup.net>
Date: Sat Oct 31 15:19:53 2015 +0800

    [dwm][pertag] Update against current git HEAD

diff --git a/dwm.suckless.org/patches/dwm-6.1-pertag.diff b/dwm.suckless.org/patches/dwm-6.1-pertag.diff
index bb14ea9..8812a48 100644
--- a/dwm.suckless.org/patches/dwm-6.1-pertag.diff
+++ b/dwm.suckless.org/patches/dwm-6.1-pertag.diff
_AT_@ -1,15 +1,8 @@
-Author: Jan Christoph Ebersbach <jceb_AT_e-jc.de>
-URL: http://dwm.suckless.org/patches/pertag
-This patch keeps layout, mwfact, barpos and nmaster per tag.
-
-Contributors:
-- Carlos Pita, thanks for debugging NetActiveWindow issues and sending a patch
-
-Index: dwm/dwm.c
-===================================================================
---- dwm/dwm.c.orig 2014-02-09 15:24:18.232117136 +0100
-+++ dwm/dwm.c 2014-02-09 15:24:18.224117135 +0100
-_AT_@ -110,6 +110,7 @@
+diff --git a/dwm.c b/dwm.c
+index 96b43f7..cc16ba1 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -111,6 +111,7 @@ typedef struct {
          void (*arrange)(Monitor *);
  } Layout;
  
_AT_@ -17,7 +10,7 @@ Index: dwm/dwm.c
  struct Monitor {
          char ltsymbol[16];
          float mfact;
-_AT_@ -129,6 +130,7 @@
+_AT_@ -130,6 +131,7 @@ struct Monitor {
          Monitor *next;
          Window barwin;
          const Layout *lt[2];
_AT_@ -25,7 +18,7 @@ Index: dwm/dwm.c
  };
  
  typedef struct {
-_AT_@ -270,6 +272,16 @@
+_AT_@ -270,6 +272,16 @@ static Window root;
  /* configuration, allows nested code to access above variables */
  #include "config.h"
  
_AT_@ -42,7 +35,7 @@ Index: dwm/dwm.c
  /* compile-time check if all tags fit into an unsigned int bit array. */
  struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
  
-_AT_@ -518,6 +530,7 @@
+_AT_@ -516,6 +528,7 @@ void
  clientmessage(XEvent *e) {
          XClientMessageEvent *cme = &e->xclient;
          Client *c = wintoclient(cme->window);
_AT_@ -50,7 +43,7 @@ Index: dwm/dwm.c
  
          if(!c)
                  return;
-_AT_@ -530,6 +543,8 @@
+_AT_@ -528,6 +541,8 @@ clientmessage(XEvent *e) {
                  if(!ISVISIBLE(c)) {
                          c->mon->seltags ^= 1;
                          c->mon->tagset[c->mon->seltags] = c->tags;
_AT_@ -59,15 +52,15 @@ Index: dwm/dwm.c
                  }
                  pop(c);
          }
-_AT_@ -631,6 +646,7 @@
+_AT_@ -629,6 +644,7 @@ configurerequest(XEvent *e) {
  Monitor *
  createmon(void) {
          Monitor *m;
 + int i;
  
- if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
- die("fatal: could not malloc() %u bytes
", sizeof(Monitor));
-_AT_@ -642,6 +658,27 @@
+ m = ecalloc(1, sizeof(Monitor));
+ m->tagset[0] = m->tagset[1] = 1;
+_AT_@ -639,6 +655,27 @@ createmon(void) {
          m->lt[0] = &layouts[0];
          m->lt[1] = &layouts[1 % LENGTH(layouts)];
          strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
_AT_@ -95,7 +88,7 @@ Index: dwm/dwm.c
          return m;
  }
  
-_AT_@ -958,7 +995,7 @@
+_AT_@ -957,7 +994,7 @@ grabkeys(void) {
  
  void
  incnmaster(const Arg *arg) {
_AT_@ -104,7 +97,7 @@ Index: dwm/dwm.c
          arrange(selmon);
  }
  
-_AT_@ -1462,10 +1499,13 @@
+_AT_@ -1469,10 +1506,13 @@ setfullscreen(Client *c, Bool fullscreen) {
  
  void
  setlayout(const Arg *arg) {
_AT_@ -121,7 +114,7 @@ Index: dwm/dwm.c
          strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
          if(selmon->sel)
                  arrange(selmon);
-_AT_@ -1483,7 +1523,7 @@
+_AT_@ -1490,7 +1530,7 @@ 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;
_AT_@ -130,7 +123,7 @@ Index: dwm/dwm.c
          arrange(selmon);
  }
  
-_AT_@ -1627,7 +1667,7 @@
+_AT_@ -1635,7 +1675,7 @@ tile(Monitor *m) {
  
  void
  togglebar(const Arg *arg) {
_AT_@ -139,7 +132,7 @@ Index: dwm/dwm.c
          updatebarpos(selmon);
          XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
          arrange(selmon);
-_AT_@ -1663,9 +1703,29 @@
+_AT_@ -1671,9 +1711,29 @@ toggletag(const Arg *arg) {
  void
  toggleview(const Arg *arg) {
          unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
_AT_@ -169,7 +162,7 @@ Index: dwm/dwm.c
                  focus(NULL);
                  arrange(selmon);
          }
-_AT_@ -1960,11 +2020,33 @@
+_AT_@ -1967,11 +2027,33 @@ updatewmhints(Client *c) {
  
  void
  view(const Arg *arg) {
diff --git a/dwm.suckless.org/patches/dwm-6.1-pertag_without_bar.diff b/dwm.suckless.org/patches/dwm-6.1-pertag_without_bar.diff
new file mode 100644
index 0000000..17a2069
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-6.1-pertag_without_bar.diff
_AT_@ -0,0 +1,161 @@
+diff --git a/dwm.c b/dwm.c
+index 96b43f7..5e11a07 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -111,6 +111,7 @@ typedef struct {
+ void (*arrange)(Monitor *);
+ } Layout;
+
++typedef struct Pertag Pertag;
+ struct Monitor {
+ char ltsymbol[16];
+ float mfact;
+_AT_@ -130,6 +131,7 @@ struct Monitor {
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
++ Pertag *pertag;
+ };
+
+ typedef struct {
+_AT_@ -270,6 +272,14 @@ static Window root;
+ /* configuration, allows nested code to access above variables */
+ #include "config.h"
+
++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 */
++};
++
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+_AT_@ -629,6 +639,7 @@ configurerequest(XEvent *e) {
+ Monitor *
+ createmon(void) {
+ Monitor *m;
++ int i;
+
+ m = ecalloc(1, sizeof(Monitor));
+ m->tagset[0] = m->tagset[1] = 1;
+_AT_@ -639,6 +650,21 @@ createmon(void) {
+ m->lt[0] = &layouts[0];
+ m->lt[1] = &layouts[1 % LENGTH(layouts)];
+ strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
++ if(!(m->pertag = (Pertag *)calloc(1, sizeof(Pertag))))
++ die("fatal: could not malloc() %u bytes
", 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;
++ }
+ return m;
+ }
+
+_AT_@ -957,7 +983,7 @@ grabkeys(void) {
+
+ void
+ incnmaster(const Arg *arg) {
+- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
+ arrange(selmon);
+ }
+
+_AT_@ -1469,10 +1495,13 @@ setfullscreen(Client *c, Bool fullscreen) {
+
+ void
+ setlayout(const Arg *arg) {
+- if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
+- selmon->sellt ^= 1;
++ 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];
++ }
+ if(arg && arg->v)
+- selmon->lt[selmon->sellt] = (Layout *)arg->v;
++ selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
+ strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
+ if(selmon->sel)
+ arrange(selmon);
+_AT_@ -1490,7 +1519,7 @@ 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;
+- selmon->mfact = f;
++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
+ arrange(selmon);
+ }
+
+_AT_@ -1671,9 +1700,27 @@ toggletag(const Arg *arg) {
+ void
+ toggleview(const Arg *arg) {
+ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);
++ int i;
+
+ if(newtagset) {
++ 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;
++ }
+ selmon->tagset[selmon->seltags] = newtagset;
++
++ /* 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];
+ focus(NULL);
+ arrange(selmon);
+ }
+_AT_@ -1967,11 +2014,31 @@ updatewmhints(Client *c) {
+
+ void
+ view(const Arg *arg) {
++ int i;
++ unsigned int tmptag;
++
+ if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
+ return;
+ selmon->seltags ^= 1; /* toggle sel tagset */
+- if(arg->ui & TAGMASK)
++ 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];
+ focus(NULL);
+ arrange(selmon);
+ }
diff --git a/dwm.suckless.org/patches/pertag.md b/dwm.suckless.org/patches/pertag.md
index 3258831..6e78a3f 100644
--- a/dwm.suckless.org/patches/pertag.md
+++ b/dwm.suckless.org/patches/pertag.md
_AT_@ -11,12 +11,10 @@ Download
 Patches against different versions of dwm are available at
 [dwm-clean-patches](https://github.com/jceb/dwm-clean-patches).
 
- * [dwm-6.1-pertag.diff](dwm-6.1-pertag.diff) (6630b) (20140209)
+ * [dwm-6.1-pertag.diff](dwm-6.1-pertag.diff) (6630b) (20151031)
  * [dwm-10e232f9ace7-pertag.diff](dwm-10e232f9ace7-pertag.diff) (5955b) (20120406)
- * [dwm-6.0-pertag_without_bar.diff](dwm-6.0-pertag_without_bar.diff) (5578b) (20140530)
  * [dwm-6.0-pertag.diff](dwm-6.0-pertag.diff) (5955b) (20120406)
  * [dwm-r1578-pertag.diff][9] (nmaster included in mainline)
- * [dwm-5.8.2-pertag\_without\_bar.diff][8]
  * [dwm-5.8.2-pertag.diff][7]
  * [dwm-5.7.2-pertag.diff][6]
  * [dwm-pertag-5.6.1.diff][5]
_AT_@ -24,6 +22,11 @@ Patches against different versions of dwm are available at
  * [dwm-5.2-pertag.diff][3]
  * [dwm-5.1-pertag.diff][2]
 
+ * Using pertag with the same barpos
+ * [dwm-6.1-pertag_without_bar.diff](dwm-6.1-pertag_without_bar.diff) (5578b) (20151031)
+ * [dwm-6.0-pertag_without_bar.diff](dwm-6.0-pertag_without_bar.diff) (5578b) (20140530)
+ * [dwm-5.8.2-pertag\_without\_bar.diff][8]
+
 Authors
 -------
  * Jan Christoph Ebersbach - <jceb_AT_e-jc.de>
_AT_@ -32,6 +35,7 @@ Authors
  * Updated by Sidney Amani - `<seed at uffs dot org>`
  * Updated by William Light - `<wrl at illest dot net>`
  * Updated by termac - `<terror.macbeth.I at gmail dot com>`
+ * Updated by Ivan Tham - `pickfire at riseup dot net`
 
 [1]: historical/taglayouts
 [2]: http://v4hn.de/patches/dwm-5.1-pertag.diff
Received on Sat Oct 31 2015 - 08:19:57 CET

This archive was generated by hypermail 2.3.0 : Sat Oct 31 2015 - 08:24:12 CET