commit 8e4a57cf1ff49b4e308aed104254d7c75105e5f1
Author: Ivan Tham <[email protected]>
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
@@ -1,15 +1,8 @@
-Author: Jan Christoph Ebersbach <[email protected]>
-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
-@@ -110,6 +110,7 @@
+diff --git a/dwm.c b/dwm.c
+index 96b43f7..cc16ba1 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -111,6 +111,7 @@ typedef struct {
        void (*arrange)(Monitor *);
  } Layout;
  
@@ -17,7 +10,7 @@ Index: dwm/dwm.c
  struct Monitor {
        char ltsymbol[16];
        float mfact;
-@@ -129,6 +130,7 @@
+@@ -130,6 +131,7 @@ struct Monitor {
        Monitor *next;
        Window barwin;
        const Layout *lt[2];
@@ -25,7 +18,7 @@ Index: dwm/dwm.c
  };
  
  typedef struct {
-@@ -270,6 +272,16 @@
+@@ -270,6 +272,16 @@ static Window root;
  /* configuration, allows nested code to access above variables */
  #include "config.h"
  
@@ -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]; };
  
-@@ -518,6 +530,7 @@
+@@ -516,6 +528,7 @@ void
  clientmessage(XEvent *e) {
        XClientMessageEvent *cme = &e->xclient;
        Client *c = wintoclient(cme->window);
@@ -50,7 +43,7 @@ Index: dwm/dwm.c
  
        if(!c)
                return;
-@@ -530,6 +543,8 @@
+@@ -528,6 +541,8 @@ clientmessage(XEvent *e) {
                if(!ISVISIBLE(c)) {
                        c->mon->seltags ^= 1;
                        c->mon->tagset[c->mon->seltags] = c->tags;
@@ -59,15 +52,15 @@ Index: dwm/dwm.c
                }
                pop(c);
        }
-@@ -631,6 +646,7 @@
+@@ -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));
-@@ -642,6 +658,27 @@
+       m = ecalloc(1, sizeof(Monitor));
+       m->tagset[0] = m->tagset[1] = 1;
+@@ -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);
@@ -95,7 +88,7 @@ Index: dwm/dwm.c
        return m;
  }
  
-@@ -958,7 +995,7 @@
+@@ -957,7 +994,7 @@ grabkeys(void) {
  
  void
  incnmaster(const Arg *arg) {
@@ -104,7 +97,7 @@ Index: dwm/dwm.c
        arrange(selmon);
  }
  
-@@ -1462,10 +1499,13 @@
+@@ -1469,10 +1506,13 @@ setfullscreen(Client *c, Bool fullscreen) {
  
  void
  setlayout(const Arg *arg) {
@@ -121,7 +114,7 @@ Index: dwm/dwm.c
        strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof 
selmon->ltsymbol);
        if(selmon->sel)
                arrange(selmon);
-@@ -1483,7 +1523,7 @@
+@@ -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;
@@ -130,7 +123,7 @@ Index: dwm/dwm.c
        arrange(selmon);
  }
  
-@@ -1627,7 +1667,7 @@
+@@ -1635,7 +1675,7 @@ tile(Monitor *m) {
  
  void
  togglebar(const Arg *arg) {
@@ -139,7 +132,7 @@ Index: dwm/dwm.c
        updatebarpos(selmon);
        XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, 
selmon->ww, bh);
        arrange(selmon);
-@@ -1663,9 +1703,29 @@
+@@ -1671,9 +1711,29 @@ toggletag(const Arg *arg) {
  void
  toggleview(const Arg *arg) {
        unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & 
TAGMASK);
@@ -169,7 +162,7 @@ Index: dwm/dwm.c
                focus(NULL);
                arrange(selmon);
        }
-@@ -1960,11 +2020,33 @@
+@@ -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
@@ -0,0 +1,161 @@
+diff --git a/dwm.c b/dwm.c
+index 96b43f7..5e11a07 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -111,6 +111,7 @@ typedef struct {
+       void (*arrange)(Monitor *);
+ } Layout;
+ 
++typedef struct Pertag Pertag;
+ struct Monitor {
+       char ltsymbol[16];
+       float mfact;
+@@ -130,6 +131,7 @@ struct Monitor {
+       Monitor *next;
+       Window barwin;
+       const Layout *lt[2];
++      Pertag *pertag;
+ };
+ 
+ typedef struct {
+@@ -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]; };
+ 
+@@ -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;
+@@ -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;
+ }
+ 
+@@ -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);
+ }
+ 
+@@ -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);
+@@ -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);
+ }
+ 
+@@ -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);
+       }
+@@ -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
@@ -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]
@@ -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 - <[email protected]>
@@ -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


Reply via email to