[wiki] [sites] [dwm][PATCH] added attachdirection [new] || MLquest8

From: <git_AT_suckless.org>
Date: Sat, 13 Jun 2020 20:07:03 +0200

commit 0318dbb9a2c61ac0af6c2808842534cc47f58c87
Author: MLquest8 <miskuzius_AT_gmail.com>
Date: Sat Jun 13 22:04:11 2020 +0400

    [dwm][PATCH] added attachdirection [new]

diff --git a/dwm.suckless.org/patches/attachdirection/dwm-attachdirection-6.2.diff b/dwm.suckless.org/patches/attachdirection/dwm-attachdirection-6.2.diff
new file mode 100644
index 00000000..fa868ce7
--- /dev/null
+++ b/dwm.suckless.org/patches/attachdirection/dwm-attachdirection-6.2.diff
_AT_@ -0,0 +1,204 @@
+From 1963de23d237e2710372f4e69d005b3867f6cbe8 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.
+
+---
+ config.def.h | 1 +
+ dwm.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++--
+ 2 files changed, 114 insertions(+), 4 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..61c8c6c 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 Layout layouts[] = {
+ /* symbol arrange function */
+diff --git a/dwm.c b/dwm.c
+index 9fd0286..4197429 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,10 @@ 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 attachabove(Client *c);
++static void attachaside(Client *c);
++static void attachbelow(Client *c);
++static void attachbottom(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);
+ static void monocle(Monitor *m);
+ static void motionnotify(XEvent *e);
+ static void movemouse(const Arg *arg);
++static Client *nexttagged(Client *c);
+ static Client *nexttiled(Client *c);
+ static void pop(Client *);
+ static void propertynotify(XEvent *e);
+_AT_@ -407,6 +413,54 @@ attach(Client *c)
+ c->mon->clients = c;
+ }
+
++void
++attachabove(Client *c)
++{
++ if (c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) {
++ attach(c);
++ return;
++ }
++
++ Client *at;
++ for (at = c->mon->clients; at->next != c->mon->sel; at = at->next);
++ c->next = at->next;
++ at->next = c;
++}
++
++void
++attachaside(Client *c) {
++ Client *at = nexttagged(c);
++ if(!at) {
++ attach(c);
++ return;
++ }
++ c->next = at->next;
++ at->next = c;
++}
++
++void
++attachbelow(Client *c)
++{
++ if(c->mon->sel == NULL || c->mon->sel == c || c->mon->sel->isfloating) {
++ attach(c);
++ return;
++ }
++ c->next = c->mon->sel->next;
++ c->mon->sel->next = c;
++}
++
++void
++attachbottom(Client *c)
++{
++ Client *below = c->mon->clients;
++ for (; below && below->next; below = below->next);
++ c->next = NULL;
++ if (below)
++ below->next = c;
++ else
++ c->mon->clients = c;
++}
++
+ void
+ attachstack(Client *c)
+ {
+_AT_@ -1063,7 +1117,22 @@ manage(Window w, XWindowAttributes *wa)
+ c->isfloating = c->oldstate = trans != None || c->isfixed;
+ if (c->isfloating)
+ XRaiseWindow(dpy, c->win);
+- attach(c);
++ switch(attachdirection){
++ case 1:
++ attachabove(c);
++ break;
++ case 2:
++ attachaside(c);
++ break;
++ case 3:
++ attachbelow(c);
++ break;
++ case 4:
++ attachbottom(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)
+ }
+ }
+
++Client *
++nexttagged(Client *c) {
++ Client *walked = c->mon->clients;
++ for(;
++ walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags));
++ walked = walked->next
++ );
++ return walked;
++}
++
+ Client *
+ nexttiled(Client *c)
+ {
+_AT_@ -1418,7 +1497,22 @@ sendmon(Client *c, Monitor *m)
+ detachstack(c);
+ c->mon = m;
+ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+- attach(c);
++ switch(attachdirection){
++ case 1:
++ attachabove(c);
++ break;
++ case 2:
++ attachaside(c);
++ break;
++ case 3:
++ attachbelow(c);
++ break;
++ case 4:
++ attachbottom(c);
++ break;
++ default:
++ attach(c);
++ }
+ attachstack(c);
+ focus(NULL);
+ arrange(NULL);
+_AT_@ -1900,7 +1994,22 @@ updategeom(void)
+ m->clients = c->next;
+ detachstack(c);
+ c->mon = mons;
+- attach(c);
++ switch(attachdirection){
++ case 1:
++ attachabove(c);
++ break;
++ case 2:
++ attachaside(c);
++ break;
++ case 3:
++ attachbelow(c);
++ break;
++ case 4:
++ attachbottom(c);
++ break;
++ default:
++ attach(c);
++ }
+ attachstack(c);
+ }
+ if (m == selmon)
+--
+2.26.2
+
diff --git a/dwm.suckless.org/patches/attachdirection/index.md b/dwm.suckless.org/patches/attachdirection/index.md
new file mode 100644
index 00000000..44d9ad7c
--- /dev/null
+++ b/dwm.suckless.org/patches/attachdirection/index.md
_AT_@ -0,0 +1,18 @@
+attachdirection
+===============
+
+Description
+-----------
+Attachdirection is a merge of 1)[attachabove](../attachabove/), 2)[attachaside](../attachaside/), 3)[attachbelow](../attachbelow/), and 4)[attachbottom](../attachbottom)
+
+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)
+
+Authors
+-------
+* MLquest8 (miskuzius at gmail.com)
Received on Sat Jun 13 2020 - 20:07:03 CEST

This archive was generated by hypermail 2.3.0 : Sat Jun 13 2020 - 20:12:43 CEST