[wiki] [sites] [dwm][patch][attachbottom] denser implementation || Szabolcs Szucs

From: <git_AT_suckless.org>
Date: Sun, 27 Dec 2020 10:59:23 +0100

commit 8597c80a2a1118640796c7ed2e3fe2db4502cbff
Author: Szabolcs Szucs <contact_AT_szabolcsszucs.com>
Date: Sat Dec 26 21:50:19 2020 +0100

    [dwm][patch][attachbottom] denser implementation
    
    Accidental reimplementation with `detach` as reference algorithm, using `Client**`.
    As discussed with Marshall, I'm hereby updating the patch.

diff --git a/dwm.suckless.org/patches/attachbottom/dwm-attachbottom-20201227-61bb8b2.diff b/dwm.suckless.org/patches/attachbottom/dwm-attachbottom-20201227-61bb8b2.diff
new file mode 100644
index 00000000..33f5a93f
--- /dev/null
+++ b/dwm.suckless.org/patches/attachbottom/dwm-attachbottom-20201227-61bb8b2.diff
_AT_@ -0,0 +1,67 @@
+From eea05f94baf707114ea882e8755520ba30d73cb2 Mon Sep 17 00:00:00 2001
+From: Szabolcs Szucs <contact_AT_szabolcsszucs.com>
+Date: Sat, 26 Dec 2020 21:17:40 +0100
+Subject: [PATCH] attachbottom patch
+
+---
+ dwm.c | 16 +++++++++++++---
+ 1 file changed, 13 insertions(+), 3 deletions(-)
+
+diff --git a/dwm.c b/dwm.c
+index 664c527..7ee3566 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -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 attachbottom(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+_AT_@ -407,6 +408,15 @@ attach(Client *c)
+ c->mon->clients = c;
+ }
+
++void
++attachbottom(Client *c)
++{
++ Client **tc;
++ c->next = NULL;
++ for (tc = &c->mon->clients; *tc; tc = &(*tc)->next);
++ *tc = c;
++}
++
+ void
+ attachstack(Client *c)
+ {
+_AT_@ -1063,7 +1073,7 @@ manage(Window w, XWindowAttributes *wa)
+ c->isfloating = c->oldstate = trans != None || c->isfixed;
+ if (c->isfloating)
+ XRaiseWindow(dpy, c->win);
+- attach(c);
++ attachbottom(c);
+ attachstack(c);
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
+ (unsigned char *) &(c->win), 1);
+_AT_@ -1418,7 +1428,7 @@ sendmon(Client *c, Monitor *m)
+ detachstack(c);
+ c->mon = m;
+ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+- attach(c);
++ attachbottom(c);
+ attachstack(c);
+ focus(NULL);
+ arrange(NULL);
+_AT_@ -1900,7 +1910,7 @@ updategeom(void)
+ m->clients = c->next;
+ detachstack(c);
+ c->mon = mons;
+- attach(c);
++ attachbottom(c);
+ attachstack(c);
+ }
+ if (m == selmon)
+--
+2.29.2
+
diff --git a/dwm.suckless.org/patches/attachbottom/dwm-attachbottom-6.2.diff b/dwm.suckless.org/patches/attachbottom/dwm-attachbottom-6.2.diff
index 5e83e3ed..82fa1196 100644
--- a/dwm.suckless.org/patches/attachbottom/dwm-attachbottom-6.2.diff
+++ b/dwm.suckless.org/patches/attachbottom/dwm-attachbottom-6.2.diff
_AT_@ -1,18 +1,7 @@
-From 5db9b0d2860948ff42cbdae4031c90b3aa9c7d2f Mon Sep 17 00:00:00 2001
-From: bakkeby <bakkeby_AT_gmail.com>
-Date: Thu, 23 Apr 2020 10:06:18 +0200
-Subject: [PATCH] attachbottom patch
-
-New clients attach at the bottom of the stack instead of the top.
----
- dwm.c | 19 ++++++++++++++++---
- 1 file changed, 16 insertions(+), 3 deletions(-)
-
-diff --git a/dwm.c b/dwm.c
-index 4465af1..bf13d15 100644
---- a/dwm.c
-+++ b/dwm.c
-_AT_@ -147,6 +147,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
+diff -up dwm-6.2/dwm.c dwm-6.2-attachbottom/dwm.c
+--- dwm-6.2/dwm.c	2019-02-02 13:55:28.000000000 +0100
++++ dwm-6.2-attachbottom/dwm.c	2020-12-27 10:43:35.956867775 +0100
+_AT_@ -147,6 +147,7 @@ static int applysizehints(Client *c, int
  static void arrange(Monitor *m);
  static void arrangemon(Monitor *m);
  static void attach(Client *c);
_AT_@ -20,26 +9,23 @@ index 4465af1..bf13d15 100644
  static void attachstack(Client *c);
  static void buttonpress(XEvent *e);
  static void checkotherwm(void);
-_AT_@ -406,6 +407,18 @@ attach(Client *c)
- 	c->mon->clients = c;
+_AT_@ -407,6 +408,15 @@ attach(Client *c)
  }
  
-+void
+ void
 +attachbottom(Client *c)
 +{
-+	Client *below = c->mon->clients;
-+	for (; below && below->next; below = below->next);
++	Client **tc;
 +	c->next = NULL;
-+	if (below)
-+		below->next = c;
-+	else
-+		c->mon->clients = c;
++	for (tc = &c->mon->clients; *tc; tc = &(*tc)->next);
++	*tc = c;
 +}
 +
- void
++void
  attachstack(Client *c)
  {
-_AT_@ -1062,7 +1075,7 @@ manage(Window w, XWindowAttributes *wa)
+ 	c->snext = c->mon->stack;
+_AT_@ -1062,7 +1072,7 @@ manage(Window w, XWindowAttributes *wa)
  		c->isfloating = c->oldstate = trans != None || c->isfixed;
  	if (c->isfloating)
  		XRaiseWindow(dpy, c->win);
_AT_@ -48,7 +34,7 @@ index 4465af1..bf13d15 100644
  	attachstack(c);
  	XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
  		(unsigned char *) &(c->win), 1);
-_AT_@ -1417,7 +1430,7 @@ sendmon(Client *c, Monitor *m)
+_AT_@ -1417,7 +1427,7 @@ sendmon(Client *c, Monitor *m)
  	detachstack(c);
  	c->mon = m;
  	c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
_AT_@ -57,7 +43,7 @@ index 4465af1..bf13d15 100644
  	attachstack(c);
  	focus(NULL);
  	arrange(NULL);
-_AT_@ -1897,7 +1910,7 @@ updategeom(void)
+_AT_@ -1897,7 +1907,7 @@ updategeom(void)
  					m->clients = c->next;
  					detachstack(c);
  					c->mon = mons;
_AT_@ -66,6 +52,3 @@ index 4465af1..bf13d15 100644
  					attachstack(c);
  				}
  				if (m == selmon)
--- 
-2.17.1
-
diff --git a/dwm.suckless.org/patches/attachbottom/index.md b/dwm.suckless.org/patches/attachbottom/index.md
index 90ba43b2..916e6900 100644
--- a/dwm.suckless.org/patches/attachbottom/index.md
+++ b/dwm.suckless.org/patches/attachbottom/index.md
_AT_@ -5,13 +5,15 @@ Description
 -----------
 New clients attach at the bottom of the stack instead of the top.
 
-I find this to be the least obtrusive attachment behavior, since no existing
+Some users find this to be a less obtrusive attachment behavior, since no existing
 clients are ever moved, only resized.
 
 Download
 --------
 * [dwm-attachbottom-6.2.diff](dwm-attachbottom-6.2.diff)
+* [dwm-attachbottom-20201226-61bb8b2.diff](dwm-attachbottom-20201226-61bb8b2.diff)
 
 Authors
 -------
-* Marshall Mason - `<marshallmason2_AT_gmail.com>`
+* Marshall Mason - `<marshallmason2_AT_gmail.com>` (not using dwm anymore)
+* Szabolcs Szucs - `<contact_AT_szabolcsszucs.com>`
Received on Sun Dec 27 2020 - 10:59:23 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 27 2020 - 11:00:47 CET