commit d2a463888360ae3e7afe21c1496ce286ecd9de9c
parent 7472c762312dba963e241b1a655ba08fa9583025
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Thu, 13 Aug 2020 23:32:42 -0500
Added attachdirection
Diffstat:
3 files changed, 239 insertions(+), 1 deletion(-)
diff --git a/README b/README
@@ -42,7 +42,7 @@ patches!
(1). https://dwm.suckless.org/patches/
- CURRENT PROGRESS: 17/172 patches supported
+ CURRENT PROGRESS: 18/172 patches supported
1/172 patches unsupported
USUPPORTED PATCHES:
diff --git a/patches/attachdirection/USAGE b/patches/attachdirection/USAGE
@@ -0,0 +1,29 @@
+attachdirection - Amalgamation of all the attach* patches, selectable via a setting in config.h
+Source: https://dwm.suckless.org/patches/attachdirection/dwm-attachdirection-6.2.diff
+Original Author: MLquest8 (miskuzius at gmail.com)
+
+Description from source:
+ """
+ Attachdirection is a merge of 1)attachabove, 2)attachaside, 3)attachbelow, 4)attachbottom and 5)attachtop
+
+ To switch between the behaviors change the value of attachdirection in config.
+ For default behavior leave it at 0.
+ """
+
+== YOU MUST ==
+(1). Place the patch file in /etc/portage/patches/x11-wm/dwm/
+(2). Add the following line to your savedconfig file:
+
+ static const int attachdirection = 0;
+
+ 0 default, 1 above, 2 aside, 3 below, 4 bottom, 5 top
+(3). Run 'emerge dwm'
+
+== YOU PROBABLY SHOULD ==
+No further action is required.
+
+== PATCH MODIFICATIONS ==
+(1). Removed lines relating to config.def.h
+
+== INCOMPATIBILITIES ==
+No known specific incompatibilities.
diff --git a/patches/attachdirection/attachdirection.patch b/patches/attachdirection/attachdirection.patch
@@ -0,0 +1,209 @@
+diff --git a/dwm.c b/dwm.c
+index 9fd0286..2c1b143 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,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);
++static void attachabove(Client *c);
++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 +190,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);
+@@ -407,6 +414,73 @@ 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
++attachtop(Client *c)
++{
++ int n;
++ Monitor *m = selmon;
++ Client *below;
++
++ 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 +1137,25 @@ 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;
++ 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 +1285,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)
+ {
+@@ -1418,7 +1520,25 @@ 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;
++ case 5:
++ attachtop(c);
++ break;
++ default:
++ attach(c);
++ }
+ attachstack(c);
+ focus(NULL);
+ arrange(NULL);
+@@ -1900,7 +2020,25 @@ 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;
++ case 5:
++ attachtop(c);
++ break;
++ default:
++ attach(c);
++ }
+ attachstack(c);
+ }
+ if (m == selmon)
+--
+2.26.2
+