commit 8823fa16f675c1f0a0cef1e8a031d920cb273103
Author: MLquest8 <[email protected]>
Date:   Thu Jun 18 15:44:32 2020 +0400

    [dwm][PATCH] added attachtop[new] and updated attachdirection to include
    it.

diff --git 
a/dwm.suckless.org/patches/attachdirection/dwm-attachdirection-6.2.diff 
b/dwm.suckless.org/patches/attachdirection/dwm-attachdirection-6.2.diff
index fa868ce7..609f6448 100644
--- a/dwm.suckless.org/patches/attachdirection/dwm-attachdirection-6.2.diff
+++ b/dwm.suckless.org/patches/attachdirection/dwm-attachdirection-6.2.diff
@@ -1,29 +1,28 @@
-From 1963de23d237e2710372f4e69d005b3867f6cbe8 Mon Sep 17 00:00:00 2001
+From 58f3937e7d2ac5d711244f9b0826b8ba32584a48 Mon Sep 17 00:00:00 2001
 From: MLquest8 <[email protected]>
-Date: Sat, 13 Jun 2020 21:44:55 +0400
-Subject: [PATCH] attachdirection is a merge of attachabove, attachaside,
- attachbelow, and attachbottom patches with a config setting to easily switch
- between them.
+Date: Thu, 18 Jun 2020 15:14:56 +0400
+Subject: [PATCH] attachdirection updated. Added attachtop option(5) that
+ attaches the newest client below the last master/on top of the stack.
 
 ---
  config.def.h |   1 +
- dwm.c        | 117 +++++++++++++++++++++++++++++++++++++++++++++++++--
- 2 files changed, 114 insertions(+), 4 deletions(-)
+ dwm.c        | 156 +++++++++++++++++++++++++++++++++++++++++++++++++--
+ 2 files changed, 153 insertions(+), 4 deletions(-)
 
 diff --git a/config.def.h b/config.def.h
-index 1c0b587..61c8c6c 100644
+index 1c0b587..d7c089b 100644
 --- a/config.def.h
 +++ b/config.def.h
 @@ -35,6 +35,7 @@ static const Rule rules[] = {
  static const float mfact     = 0.55; /* factor of master area size 
[0.05..0.95] */
  static const int nmaster     = 1;    /* number of clients in master area */
  static const int resizehints = 1;    /* 1 means respect size hints in tiled 
resizals */
-+static const int attachdirection = 0;    /* 0 default, 1 above, 2 aside, 3 
below, 4 bottom */
++static const int attachdirection = 0;    /* 0 default, 1 above, 2 aside, 3 
below, 4 bottom, 5 top */
  
  static const Layout layouts[] = {
        /* symbol     arrange function */
 diff --git a/dwm.c b/dwm.c
-index 9fd0286..4197429 100644
+index 9fd0286..e128c31 100644
 --- a/dwm.c
 +++ b/dwm.c
 @@ -49,7 +49,8 @@
@@ -36,7 +35,7 @@ index 9fd0286..4197429 100644
  #define LENGTH(X)               (sizeof X / sizeof X[0])
  #define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
  #define WIDTH(X)                ((X)->w + 2 * (X)->bw)
-@@ -147,6 +148,10 @@ static int applysizehints(Client *c, int *x, int *y, int 
*w, int *h, int interac
+@@ -147,6 +148,11 @@ static int applysizehints(Client *c, int *x, int *y, int 
*w, int *h, int interac
  static void arrange(Monitor *m);
  static void arrangemon(Monitor *m);
  static void attach(Client *c);
@@ -44,10 +43,11 @@ index 9fd0286..4197429 100644
 +static void attachaside(Client *c);
 +static void attachbelow(Client *c);
 +static void attachbottom(Client *c);
++static void attachtop(Client *c);
  static void attachstack(Client *c);
  static void buttonpress(XEvent *e);
  static void checkotherwm(void);
-@@ -184,6 +189,7 @@ static void maprequest(XEvent *e);
+@@ -184,6 +190,7 @@ static void maprequest(XEvent *e);
  static void monocle(Monitor *m);
  static void motionnotify(XEvent *e);
  static void movemouse(const Arg *arg);
@@ -55,7 +55,7 @@ index 9fd0286..4197429 100644
  static Client *nexttiled(Client *c);
  static void pop(Client *);
  static void propertynotify(XEvent *e);
-@@ -407,6 +413,54 @@ attach(Client *c)
+@@ -407,6 +414,83 @@ attach(Client *c)
        c->mon->clients = c;
  }
  
@@ -106,11 +106,40 @@ index 9fd0286..4197429 100644
 +      else
 +              c->mon->clients = c;
 +}
++
++void
++attachtop(Client *c)
++{
++      int n;
++      Monitor *m = selmon;
++      Client *below;
++
++      if (m->nmaster == 0){
++              for (below = c->mon->clients; below && below->next; below = 
below->next);
++              c->next = NULL;
++              if (below)
++                      below->next = c;
++              else
++                      c->mon->clients = c;
++      }
++      else {
++              for (n = 1, below = c->mon->clients;
++                      below && below->next && (below->isfloating || 
!ISVISIBLEONTAG(below, c->tags) || n != m->nmaster);
++                      n = below->isfloating || !ISVISIBLEONTAG(below, 
c->tags) ? n + 0 : n + 1, below = below->next);
++              c->next = NULL;
++              if (below) {
++                      c->next = below->next;
++                      below->next = c;
++              }
++              else
++                      c->mon->clients = c;
++      }
++}
 +
  void
  attachstack(Client *c)
  {
-@@ -1063,7 +1117,22 @@ manage(Window w, XWindowAttributes *wa)
+@@ -1063,7 +1147,25 @@ manage(Window w, XWindowAttributes *wa)
                c->isfloating = c->oldstate = trans != None || c->isfixed;
        if (c->isfloating)
                XRaiseWindow(dpy, c->win);
@@ -128,13 +157,16 @@ index 9fd0286..4197429 100644
 +              case 4:
 +                      attachbottom(c);
 +                      break;
++              case 5:
++                      attachtop(c);
++                      break;
 +              default:
 +                      attach(c);
 +      }
        attachstack(c);
        XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, 
PropModeAppend,
                (unsigned char *) &(c->win), 1);
-@@ -1193,6 +1262,16 @@ movemouse(const Arg *arg)
+@@ -1193,6 +1295,16 @@ movemouse(const Arg *arg)
        }
  }
  
@@ -151,7 +183,7 @@ index 9fd0286..4197429 100644
  Client *
  nexttiled(Client *c)
  {
-@@ -1418,7 +1497,22 @@ sendmon(Client *c, Monitor *m)
+@@ -1418,7 +1530,25 @@ sendmon(Client *c, Monitor *m)
        detachstack(c);
        c->mon = m;
        c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
@@ -169,13 +201,16 @@ index 9fd0286..4197429 100644
 +              case 4:
 +                      attachbottom(c);
 +                      break;
++              case 5:
++                      attachtop(c);
++                      break;
 +              default:
 +                      attach(c);
 +      }
        attachstack(c);
        focus(NULL);
        arrange(NULL);
-@@ -1900,7 +1994,22 @@ updategeom(void)
+@@ -1900,7 +2030,25 @@ updategeom(void)
                                        m->clients = c->next;
                                        detachstack(c);
                                        c->mon = mons;
@@ -193,6 +228,9 @@ index 9fd0286..4197429 100644
 +                                      case 4:
 +                                              attachbottom(c);
 +                                              break;
++                                      case 5:
++                                              attachtop(c);
++                                              break;
 +                                      default:
 +                                              attach(c);
 +                                      }
diff --git a/dwm.suckless.org/patches/attachdirection/index.md 
b/dwm.suckless.org/patches/attachdirection/index.md
index 44d9ad7c..00d45f98 100644
--- a/dwm.suckless.org/patches/attachdirection/index.md
+++ b/dwm.suckless.org/patches/attachdirection/index.md
@@ -3,15 +3,14 @@ attachdirection
 
 Description
 -----------
-Attachdirection is a merge of 1)[attachabove](../attachabove/), 
2)[attachaside](../attachaside/), 3)[attachbelow](../attachbelow/), and 
4)[attachbottom](../attachbottom)
+Attachdirection is a merge of 1)[attachabove](../attachabove/), 
2)[attachaside](../attachaside/), 3)[attachbelow](../attachbelow/), 
4)[attachbottom](../attachbottom/) and 5)[attachtop](../attachtop/)
 
 To switch between the behaviors change the value of `attachdirection` in 
config.  
 For default behavior leave it at `0`.  
 
-
 Download
 --------
-* [dwm-attachdirection-6.2.diff](dwm-attachdirection-6.2.diff) (13/06/2020)
+* [dwm-attachdirection-6.2.diff](dwm-attachdirection-6.2.diff) (18/06/2020)
 
 Authors
 -------
diff --git a/dwm.suckless.org/patches/attachtop/dwm-attachtop-6.2.diff 
b/dwm.suckless.org/patches/attachtop/dwm-attachtop-6.2.diff
new file mode 100644
index 00000000..5900c52e
--- /dev/null
+++ b/dwm.suckless.org/patches/attachtop/dwm-attachtop-6.2.diff
@@ -0,0 +1,98 @@
+From 852763830e1d245e954bf8a220867c76148694e3 Mon Sep 17 00:00:00 2001
+From: MLquest8 <[email protected]>
+Date: Thu, 18 Jun 2020 15:34:18 +0400
+Subject: [PATCH] attachtop. Attaches new client below the last master/on top
+ of the stack. In case of nmaster = 1 behaves like attachaside.
+
+---
+ dwm.c | 39 +++++++++++++++++++++++++++++++++++----
+ 1 file changed, 35 insertions(+), 4 deletions(-)
+
+diff --git a/dwm.c b/dwm.c
+index 9fd0286..4d0152f 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -49,7 +49,8 @@
+ #define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask) & 
(ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
+ #define INTERSECT(x,y,w,h,m)    (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - 
MAX((x),(m)->wx)) \
+                                * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - 
MAX((y),(m)->wy)))
+-#define ISVISIBLE(C)            ((C->tags & C->mon->tagset[C->mon->seltags]))
++#define ISVISIBLEONTAG(C, T)    ((C->tags & T))
++#define ISVISIBLE(C)            ISVISIBLEONTAG(C, 
C->mon->tagset[C->mon->seltags])
+ #define LENGTH(X)               (sizeof X / sizeof X[0])
+ #define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
+ #define WIDTH(X)                ((X)->w + 2 * (X)->bw)
+@@ -147,6 +148,7 @@ static int applysizehints(Client *c, int *x, int *y, int 
*w, int *h, int interac
+ static void arrange(Monitor *m);
+ static void arrangemon(Monitor *m);
+ static void attach(Client *c);
++static void attachtop(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+@@ -407,6 +409,35 @@ attach(Client *c)
+       c->mon->clients = c;
+ }
+ 
++void
++attachtop(Client *c)
++{
++      int n;
++      Monitor *m = selmon;
++      Client *below;
++
++      if (m->nmaster == 0){
++              for (below = c->mon->clients; below && below->next; below = 
below->next);
++              c->next = NULL;
++              if (below)
++                      below->next = c;
++              else
++                      c->mon->clients = c;
++      }
++      else {
++              for (n = 1, below = c->mon->clients;
++                      below && below->next && (below->isfloating || 
!ISVISIBLEONTAG(below, c->tags) || n != m->nmaster);
++                      n = below->isfloating || !ISVISIBLEONTAG(below, 
c->tags) ? n + 0 : n + 1, below = below->next);
++              c->next = NULL;
++              if (below) {
++                      c->next = below->next;
++                      below->next = c;
++              }
++              else
++                      c->mon->clients = c;
++      }
++}
++
+ void
+ attachstack(Client *c)
+ {
+@@ -1063,7 +1094,7 @@ manage(Window w, XWindowAttributes *wa)
+               c->isfloating = c->oldstate = trans != None || c->isfixed;
+       if (c->isfloating)
+               XRaiseWindow(dpy, c->win);
+-      attach(c);
++      attachtop(c);
+       attachstack(c);
+       XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, 
PropModeAppend,
+               (unsigned char *) &(c->win), 1);
+@@ -1418,7 +1449,7 @@ sendmon(Client *c, Monitor *m)
+       detachstack(c);
+       c->mon = m;
+       c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+-      attach(c);
++      attachtop(c);
+       attachstack(c);
+       focus(NULL);
+       arrange(NULL);
+@@ -1900,7 +1931,7 @@ updategeom(void)
+                                       m->clients = c->next;
+                                       detachstack(c);
+                                       c->mon = mons;
+-                                      attach(c);
++                                      attachtop(c);
+                                       attachstack(c);
+                               }
+                               if (m == selmon)
+-- 
+2.26.2
+
diff --git a/dwm.suckless.org/patches/attachtop/index.md 
b/dwm.suckless.org/patches/attachtop/index.md
new file mode 100644
index 00000000..8443b53d
--- /dev/null
+++ b/dwm.suckless.org/patches/attachtop/index.md
@@ -0,0 +1,20 @@
+attachtop
+=========
+
+Description
+-----------
+New client attaches below the last master/on top of the stack.
+
+Behavior feels very intuitive as it doesn't disrupt existing masters
+no matter the amount of them, it only pushes the clients in stack
+down. In case of `nmaster = 1` feels like [attachaside](../attachaside/)
+
+Is included in [attachdirection](../attachdirection/)
+
+Download
+--------
+* [dwm-attachtop-6.2.diff](dwm-attachtop-6.2.diff) (18/06/2020)
+
+Authors
+-------
+* MLquest8 (miskuzius at gmail.com)


Reply via email to