commit 7472c762312dba963e241b1a655ba08fa9583025
parent 834c04935bf8218e31dadd2ff49b19a2cd26373d
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Thu, 13 Aug 2020 22:58:28 -0500
Added attachbelow
Diffstat:
4 files changed, 247 insertions(+), 1 deletion(-)
diff --git a/README b/README
@@ -42,7 +42,7 @@ patches!
(1). https://dwm.suckless.org/patches/
- CURRENT PROGRESS: 16/172 patches supported
+ CURRENT PROGRESS: 17/172 patches supported
1/172 patches unsupported
USUPPORTED PATCHES:
diff --git a/patches/attachbelow/USAGE b/patches/attachbelow/USAGE
@@ -0,0 +1,65 @@
+attachbelow - Attach new windows below the current active one in the stack
+Source: https://dwm.suckless.org/patches/attachbelow/dwm-attachbelow-6.2.diff
+Original Author: Jonathan Hodgson - git@jonathanh.co.uk
+
+Description from source:
+ """
+ Make new clients attach below the selected client, instead of always becoming the new master.
+ Inspired heavily from the atttachabove patch.
+ """
+
+== 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 attachbelow = 1;
+
+(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.
+
+###################################################################################################
+###################################################################################################
+
+attachbelow-toggleable - Toggleable version of attachbelow
+Source: https://dwm.suckless.org/patches/attachbelow/dwm-attachbelow-toggleable-6.2.diff
+Original Author: Jonathan Hodgson - git@jonathanh.co.uk
+
+Description from source:
+ """
+ A new version of the patch also allows this behaviour to be toggled. I have this bound to mod+tab,
+ over-riding the default behaviour of mod+tab. This change is not included in the patch.
+
+ Example Configuration
+
+ Add the following to your keys array to bind mod+tab to toggle attach below.
+
+ { MODKEY, XK_Tab, toggleAttachBelow, {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 int attachbelow = 1;
+
+ Notice that it is not constant!
+(3). Run 'emerge dwm'
+
+== YOU PROBABLY SHOULD ==
+(1). Add a key binding to your savedconfig file to toggle attachbelow on and off. For example:
+
+ { MODKEY, XK_Tab, toggleAttachBelow, {0} },
+
+== PATCH MODIFICATIONS ==
+(1). Contorted the original 4-part patch into a single diff consisting of the two non-config.h changed files.
+
+== INCOMPATIBILITIES ==
+No known specific incompatibilities.
diff --git a/patches/attachbelow/attachbelow-toggleable.patch b/patches/attachbelow/attachbelow-toggleable.patch
@@ -0,0 +1,97 @@
+diff --git a/dwm.c b/dwm.c
+index 4465af1..bd715a2 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -147,6 +147,8 @@ 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 attachBelow(Client *c);
++static void toggleAttachBelow();
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+@@ -405,6 +406,27 @@ attach(Client *c)
+ c->next = c->mon->clients;
+ c->mon->clients = c;
+ }
++void
++attachBelow(Client *c)
++{
++ //If there is nothing on the monitor or the selected client is floating, attach as normal
++ if(c->mon->sel == NULL || c->mon->sel == c || c->mon->sel->isfloating) {
++ attach(c);
++ return;
++ }
++
++ //Set the new client's next property to the same as the currently selected clients next
++ c->next = c->mon->sel->next;
++ //Set the currently selected clients next property to the new client
++ c->mon->sel->next = c;
++
++}
++
++void toggleAttachBelow()
++{
++ attachbelow = !attachbelow;
++}
++
+
+ void
+ attachstack(Client *c)
+@@ -1062,7 +1078,10 @@ manage(Window w, XWindowAttributes *wa)
+ c->isfloating = c->oldstate = trans != None || c->isfixed;
+ if (c->isfloating)
+ XRaiseWindow(dpy, c->win);
+- attach(c);
++ if( attachbelow )
++ attachBelow(c);
++ else
++ attach(c);
+ attachstack(c);
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
+ (unsigned char *) &(c->win), 1);
+@@ -1417,7 +1436,10 @@ sendmon(Client *c, Monitor *m)
+ detachstack(c);
+ c->mon = m;
+ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+- attach(c);
++ if( attachbelow )
++ attachBelow(c);
++ else
++ attach(c);
+ attachstack(c);
+ focus(NULL);
+ arrange(NULL);
+@@ -1897,7 +1919,10 @@ updategeom(void)
+ m->clients = c->next;
+ detachstack(c);
+ c->mon = mons;
+- attach(c);
++ if( attachbelow )
++ attachBelow(c);
++ else
++ attach(c);
+ attachstack(c);
+ }
+ if (m == selmon)
+diff --git a/dwm.1 b/dwm.1
+index 13b3729..fb6e76c 100644
+--- a/dwm.1
++++ b/dwm.1
+@@ -29,6 +29,9 @@ color. The tags of the focused window are indicated with a filled square in the
+ top left corner. The tags which are applied to one or more windows are
+ indicated with an empty square in the top left corner.
+ .P
++The attach below patch makes newly spawned windows attach after the currently
++selected window
++.P
+ dwm draws a small border around windows to indicate the focus state.
+ .SH OPTIONS
+ .TP
+--
+2.21.0
+
+--
+2.21.0
+
diff --git a/patches/attachbelow/attachbelow.patch b/patches/attachbelow/attachbelow.patch
@@ -0,0 +1,84 @@
+diff --git a/dwm.1 b/dwm.1
+index 13b3729..fb6e76c 100644
+--- a/dwm.1
++++ b/dwm.1
+@@ -29,6 +29,9 @@ color. The tags of the focused window are indicated with a filled square in the
+ top left corner. The tags which are applied to one or more windows are
+ indicated with an empty square in the top left corner.
+ .P
++The attach below patch makes newly spawned windows attach after the currently
++selected window
++.P
+ dwm draws a small border around windows to indicate the focus state.
+ .SH OPTIONS
+ .TP
+diff --git a/dwm.c b/dwm.c
+index 4465af1..bd715a2 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -147,6 +147,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 attachBelow(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+@@ -405,6 +406,21 @@ attach(Client *c)
+ c->next = c->mon->clients;
+ c->mon->clients = c;
+ }
++void
++attachBelow(Client *c)
++{
++ //If there is nothing on the monitor or the selected client is floating, attach as normal
++ if(c->mon->sel == NULL || c->mon->sel == c || c->mon->sel->isfloating) {
++ attach(c);
++ return;
++ }
++
++ //Set the new client's next property to the same as the currently selected clients next
++ c->next = c->mon->sel->next;
++ //Set the currently selected clients next property to the new client
++ c->mon->sel->next = c;
++
++}
+
+ void
+ attachstack(Client *c)
+@@ -1062,7 +1078,10 @@ manage(Window w, XWindowAttributes *wa)
+ c->isfloating = c->oldstate = trans != None || c->isfixed;
+ if (c->isfloating)
+ XRaiseWindow(dpy, c->win);
+- attach(c);
++ if( attachbelow )
++ attachBelow(c);
++ else
++ attach(c);
+ attachstack(c);
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
+ (unsigned char *) &(c->win), 1);
+@@ -1417,7 +1436,10 @@ sendmon(Client *c, Monitor *m)
+ detachstack(c);
+ c->mon = m;
+ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+- attach(c);
++ if( attachbelow )
++ attachBelow(c);
++ else
++ attach(c);
+ attachstack(c);
+ focus(NULL);
+ arrange(NULL);
+@@ -1897,7 +1919,10 @@ updategeom(void)
+ m->clients = c->next;
+ detachstack(c);
+ c->mon = mons;
+- attach(c);
++ if( attachbelow )
++ attachBelow(c);
++ else
++ attach(c);
+ attachstack(c);
+ }
+ if (m == selmon)