[wiki] [sites] [dwm][PATCH] added attachtop[new] and updated attachdirection to include it. || MLquest8

From: <git_AT_suckless.org>
Date: Thu, 18 Jun 2020 13:46:21 +0200

commit 8823fa16f675c1f0a0cef1e8a031d920cb273103
Author: MLquest8 <miskuzius_AT_gmail.com>
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
_AT_@ -1,29 +1,28 @@
-From 1963de23d237e2710372f4e69d005b3867f6cbe8 Mon Sep 17 00:00:00 2001
+From 58f3937e7d2ac5d711244f9b0826b8ba32584a48 Mon Sep 17 00:00:00 2001
 From: MLquest8 <miskuzius_AT_gmail.com>
-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
 _AT_@ -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
 _AT_@ -49,7 +49,8 @@
_AT_@ -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)
-_AT_@ -147,6 +148,10 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
+_AT_@ -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);
_AT_@ -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);
-_AT_@ -184,6 +189,7 @@ static void maprequest(XEvent *e);
+_AT_@ -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);
_AT_@ -55,7 +55,7 @@ index 9fd0286..4197429 100644
  static Client *nexttiled(Client *c);
  static void pop(Client *);
  static void propertynotify(XEvent *e);
-_AT_@ -407,6 +413,54 @@ attach(Client *c)
+_AT_@ -407,6 +414,83 @@ attach(Client *c)
          c->mon->clients = c;
  }
  
_AT_@ -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)
  {
-_AT_@ -1063,7 +1117,22 @@ manage(Window w, XWindowAttributes *wa)
+_AT_@ -1063,7 +1147,25 @@ manage(Window w, XWindowAttributes *wa)
                  c->isfloating = c->oldstate = trans != None || c->isfixed;
          if (c->isfloating)
                  XRaiseWindow(dpy, c->win);
_AT_@ -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);
-_AT_@ -1193,6 +1262,16 @@ movemouse(const Arg *arg)
+_AT_@ -1193,6 +1295,16 @@ movemouse(const Arg *arg)
          }
  }
  
_AT_@ -151,7 +183,7 @@ index 9fd0286..4197429 100644
  Client *
  nexttiled(Client *c)
  {
-_AT_@ -1418,7 +1497,22 @@ sendmon(Client *c, Monitor *m)
+_AT_@ -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 */
_AT_@ -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);
-_AT_@ -1900,7 +1994,22 @@ updategeom(void)
+_AT_@ -1900,7 +2030,25 @@ updategeom(void)
                                          m->clients = c->next;
                                          detachstack(c);
                                          c->mon = mons;
_AT_@ -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
_AT_@ -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
_AT_@ -0,0 +1,98 @@
+From 852763830e1d245e954bf8a220867c76148694e3 Mon Sep 17 00:00:00 2001
+From: MLquest8 <miskuzius_AT_gmail.com>
+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
+_AT_@ -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)
+_AT_@ -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);
+_AT_@ -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)
+ {
+_AT_@ -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);
+_AT_@ -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);
+_AT_@ -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
_AT_@ -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)
Received on Thu Jun 18 2020 - 13:46:21 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 18 2020 - 13:48:44 CEST