[wiki] [sites] dwm attachaside patch: fix everything || FRIGN

From: <git_AT_suckless.org>
Date: Mon, 18 Jul 2016 07:14:49 +0200

commit 7a46ac96e2e41757df88d019fa4676b64cb83e2c
Author: FRIGN <dev_AT_frign.de>
Date: Mon Jul 18 07:13:38 2016 +0200

    dwm attachaside patch: fix everything
    
    Okay, so, there were the following problems with this patch:
            1) it was too much of a bloody diary
            2) it linked to broken versions
            3) the 6.1 "fix" didn't even apply to version 6.1.
            4) there was no git version
    
    Everything has been fixed now.

diff --git a/dwm.suckless.org/patches/attachaside.md b/dwm.suckless.org/patches/attachaside.md
index 611d065..508df90 100644
--- a/dwm.suckless.org/patches/attachaside.md
+++ b/dwm.suckless.org/patches/attachaside.md
_AT_@ -3,9 +3,10 @@ attachaside
 
 Description
 -----------
-`attachaside` makes the new client get attached and focused in the stacking
+
+Make new clients get attached and focused in the stacking
 area instead of always becoming the new master. It's basically an
-[attachabove](attachabove) mod.
+[attachabove](attachabove) modification.
 
         Original behaviour :
         +-----------------+-------+
_AT_@ -44,23 +45,12 @@ area instead of always becoming the new master. It's basically an
 Download
 --------
 
-### Version updated to work with tags
-
-The original version of attachaside does does not attach to the stack when
-windows are spawned on a tag that is not currently focused. This version is
-improved to also attach to the stack on unfocused tags.
-
-* [dwm-6.1-attachaside-tagfix.diff](dwm-6.1-attachaside-tagfix.diff) (2.9K) (20150729)
-
-### Original
-
-* [dwm-attachaside-6.0.diff](dwm-attachaside-6.0.diff) (1,6K) (20140412)
-* [dwm-5.7.2-attachaside.diff](historical/dwm-5.7.2-attachaside.diff) (1.1K) (20091215)
-* [dwm-5.6.1-attachaside.diff](historical/dwm-5.6.1-attachaside.diff) (1.1K) (20090915)
+* [dwm-attachaside-6.1.diff](dwm-attachaside-6.1.diff)
+* [dwm-attachaside-20160718-56a31dc.diff](dwm-attachaside-20160718-56a31dc.diff)
 
 Authors
 -------
-* Jerome Andrieux - `<jerome at gcu dot info>`
-* Version updated to work with tags by [Chris Down](https://chrisdown.name)
- (cdown) <chris_AT_chrisdown.name>
-* Update to 6.0 by Vladimir Seleznev - `<me at wladmis dot org>`
+
+* Jerome Andrieux - <jerome_AT_gcu.info>
+* Chris Down - <chris_AT_chrisdown.name> (6.1 port and fixes)
+* Laslo Hunhold - <dev_AT_frign.de> (git port)
diff --git a/dwm.suckless.org/patches/dwm-attachaside-20160718-56a31dc.diff b/dwm.suckless.org/patches/dwm-attachaside-20160718-56a31dc.diff
new file mode 100644
index 0000000..b8471af
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-attachaside-20160718-56a31dc.diff
_AT_@ -0,0 +1,92 @@
+diff --git a/dwm.c b/dwm.c
+index b2bc9bd..58a86fa 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_@ -148,6 +149,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 attachaside(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+_AT_@ -185,6 +187,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_@ -408,6 +411,17 @@ attach(Client *c)
+ }
+
+ void
++attachaside(Client *c) {
++ Client *at = nexttagged(c);
++ if(!at) {
++ attach(c);
++ return;
++ }
++ c->next = at->next;
++ at->next = c;
++}
++
++void
+ attachstack(Client *c)
+ {
+ c->snext = c->mon->stack;
+_AT_@ -1079,7 +1093,7 @@ manage(Window w, XWindowAttributes *wa)
+ c->isfloating = c->oldstate = trans != None || c->isfixed;
+ if (c->isfloating)
+ XRaiseWindow(dpy, c->win);
+- attach(c);
++ attachaside(c);
+ attachstack(c);
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
+ (unsigned char *) &(c->win), 1);
+_AT_@ -1213,6 +1227,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)
+ {
+ for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
+_AT_@ -1437,7 +1461,7 @@ sendmon(Client *c, Monitor *m)
+ detachstack(c);
+ c->mon = m;
+ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+- attach(c);
++ attachaside(c);
+ attachstack(c);
+ focus(NULL);
+ arrange(NULL);
+_AT_@ -1890,7 +1914,7 @@ updategeom(void)
+ m->clients = c->next;
+ detachstack(c);
+ c->mon = mons;
+- attach(c);
++ attachaside(c);
+ attachstack(c);
+ }
+ if (m == selmon)
diff --git a/dwm.suckless.org/patches/dwm-attachaside-6.0.diff b/dwm.suckless.org/patches/dwm-attachaside-6.0.diff
deleted file mode 100644
index 352d5ec..0000000
--- a/dwm.suckless.org/patches/dwm-attachaside-6.0.diff
+++ /dev/null
_AT_@ -1,57 +0,0 @@
-diff --git a/dwm.c b/dwm.c
-index 1bbb4b3..b2aa1c8 100644
---- a/dwm.c
-+++ b/dwm.c
-_AT_@ -146,6 +146,7 @@ static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool inter
- static void arrange(Monitor *m);
- static void arrangemon(Monitor *m);
- static void attach(Client *c);
-+static void attachaside(Client *c);
- static void attachstack(Client *c);
- static void buttonpress(XEvent *e);
- static void checkotherwm(void);
-_AT_@ -401,6 +402,17 @@ attach(Client *c) {
- }
-
- void
-+attachaside(Client *c) {
-+ Client *at = nexttiled(c->mon->clients);
-+ if(c->mon->sel == NULL || c->mon->sel->isfloating || !at) {
-+ attach(c);
-+ return;
-+ }
-+ c->next = at->next;
-+ at->next = c;
-+}
-+
-+void
- attachstack(Client *c) {
- c->snext = c->mon->stack;
- c->mon->stack = c;
-_AT_@ -1051,7 +1063,7 @@ manage(Window w, XWindowAttributes *wa) {
- c->isfloating = c->oldstate = trans != None || c->isfixed;
- if(c->isfloating)
- XRaiseWindow(dpy, c->win);
-- attach(c);
-+ attachaside(c);
- attachstack(c);
- XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
- (unsigned char *) &(c->win), 1);
-_AT_@ -1383,7 +1395,7 @@ sendmon(Client *c, Monitor *m) {
- detachstack(c);
- c->mon = m;
- c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
-- attach(c);
-+ attachaside(c);
- attachstack(c);
- focus(NULL);
- arrange(NULL);
-_AT_@ -1818,7 +1830,7 @@ updategeom(void) {
- m->clients = c->next;
- detachstack(c);
- c->mon = mons;
-- attach(c);
-+ attachaside(c);
- attachstack(c);
- }
- if(m == selmon)
diff --git a/dwm.suckless.org/patches/dwm-attachaside-6.1.diff b/dwm.suckless.org/patches/dwm-attachaside-6.1.diff
new file mode 100644
index 0000000..176cdb0
--- /dev/null
+++ b/dwm.suckless.org/patches/dwm-attachaside-6.1.diff
_AT_@ -0,0 +1,92 @@
+diff --git a/dwm.c b/dwm.c
+index 0362114..be7e7a6 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 attachaside(Client *c);
+ static void attachstack(Client *c);
+ static void buttonpress(XEvent *e);
+ static void checkotherwm(void);
+_AT_@ -184,6 +186,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_@ -406,6 +409,17 @@ attach(Client *c)
+ }
+
+ void
++attachaside(Client *c) {
++ Client *at = nexttagged(c);
++ if(!at) {
++ attach(c);
++ return;
++ }
++ c->next = at->next;
++ at->next = c;
++}
++
++void
+ attachstack(Client *c)
+ {
+ c->snext = c->mon->stack;
+_AT_@ -1076,7 +1090,7 @@ manage(Window w, XWindowAttributes *wa)
+ c->isfloating = c->oldstate = trans != None || c->isfixed;
+ if (c->isfloating)
+ XRaiseWindow(dpy, c->win);
+- attach(c);
++ attachaside(c);
+ attachstack(c);
+ XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
+ (unsigned char *) &(c->win), 1);
+_AT_@ -1210,6 +1224,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)
+ {
+ for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next);
+_AT_@ -1434,7 +1458,7 @@ sendmon(Client *c, Monitor *m)
+ detachstack(c);
+ c->mon = m;
+ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
+- attach(c);
++ attachaside(c);
+ attachstack(c);
+ focus(NULL);
+ arrange(NULL);
+_AT_@ -1891,7 +1915,7 @@ updategeom(void)
+ m->clients = c->next;
+ detachstack(c);
+ c->mon = mons;
+- attach(c);
++ attachaside(c);
+ attachstack(c);
+ }
+ if (m == selmon)
diff --git a/dwm.suckless.org/patches/historical/dwm-5.6.1-attachaside.diff b/dwm.suckless.org/patches/historical/dwm-5.6.1-attachaside.diff
deleted file mode 100644
index 52ea58f..0000000
--- a/dwm.suckless.org/patches/historical/dwm-5.6.1-attachaside.diff
+++ /dev/null
_AT_@ -1,38 +0,0 @@
-diff -r 9f79d36bd5e0 dwm.c
---- a/dwm.c Tue Sep 08 13:33:58 2009 +0100
-+++ b/dwm.c Tue Sep 15 14:19:26 2009 +0200
-_AT_@ -153,6 +153,7 @@
- static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
- static void arrange(void);
- static void attach(Client *c);
-+static void attachaside(Client *c);
- static void attachstack(Client *c);
- static void buttonpress(XEvent *e);
- static void checkotherwm(void);
-_AT_@ -397,6 +398,17 @@
- }
-
- void
-+attachaside(Client *c) {
-+ Client *at = nexttiled(c->mon->clients);;
-+ if(c->mon->sel == NULL || c->mon->sel->isfloating || !at) {
-+ attach(c);
-+ return;
-+ }
-+ c->next = at->next;
-+ at->next = c;
-+}
-+
-+void
- attachstack(Client *c) {
- c->snext = c->mon->stack;
- c->mon->stack = c;
-_AT_@ -1105,7 +1117,7 @@
- c->isfloating = trans != None || c->isfixed;
- if(c->isfloating)
- XRaiseWindow(dpy, c->win);
-- attach(c);
-+ attachaside(c);
- attachstack(c);
- XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
- XMapWindow(dpy, c->win);
diff --git a/dwm.suckless.org/patches/historical/dwm-5.7.2-attachaside.diff b/dwm.suckless.org/patches/historical/dwm-5.7.2-attachaside.diff
deleted file mode 100644
index 52ea58f..0000000
--- a/dwm.suckless.org/patches/historical/dwm-5.7.2-attachaside.diff
+++ /dev/null
_AT_@ -1,38 +0,0 @@
-diff -r 9f79d36bd5e0 dwm.c
---- a/dwm.c Tue Sep 08 13:33:58 2009 +0100
-+++ b/dwm.c Tue Sep 15 14:19:26 2009 +0200
-_AT_@ -153,6 +153,7 @@
- static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
- static void arrange(void);
- static void attach(Client *c);
-+static void attachaside(Client *c);
- static void attachstack(Client *c);
- static void buttonpress(XEvent *e);
- static void checkotherwm(void);
-_AT_@ -397,6 +398,17 @@
- }
-
- void
-+attachaside(Client *c) {
-+ Client *at = nexttiled(c->mon->clients);;
-+ if(c->mon->sel == NULL || c->mon->sel->isfloating || !at) {
-+ attach(c);
-+ return;
-+ }
-+ c->next = at->next;
-+ at->next = c;
-+}
-+
-+void
- attachstack(Client *c) {
- c->snext = c->mon->stack;
- c->mon->stack = c;
-_AT_@ -1105,7 +1117,7 @@
- c->isfloating = trans != None || c->isfixed;
- if(c->isfloating)
- XRaiseWindow(dpy, c->win);
-- attach(c);
-+ attachaside(c);
- attachstack(c);
- XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
- XMapWindow(dpy, c->win);
Received on Mon Jul 18 2016 - 07:14:49 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 18 2016 - 07:24:17 CEST