commit de01bb61fae13e0756f550844498f28270cef862
parent e79df96f6b9e95ccc9b1b8aaf3be73c4d988ad85
Author: AndrewLockVI <andrew@laack.co>
Date: Mon, 17 Feb 2025 09:59:14 -0600
Added in attach below
Diffstat:
| M | dwm.c | | | 24 | ++++++++++++++++++++---- |
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/dwm.c b/dwm.c
@@ -149,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 attachBelow(Client *c);
static void attachstack(Client *c);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
@@ -413,6 +414,21 @@ attach(Client *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
@@ -1072,7 +1088,7 @@ manage(Window w, XWindowAttributes *wa)
c->isfloating = c->oldstate = trans != None || c->isfixed;
if (c->isfloating)
XRaiseWindow(dpy, c->win);
- attach(c);
+ attachBelow(c);
attachstack(c);
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
(unsigned char *) &(c->win), 1);
@@ -1211,7 +1227,7 @@ void
pop(Client *c)
{
detach(c);
- attach(c);
+ attachBelow(c);
focus(c);
arrange(c->mon);
}
@@ -1422,7 +1438,7 @@ sendmon(Client *c, Monitor *m)
detachstack(c);
c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
- attach(c);
+ attachBelow(c);
attachstack(c);
focus(NULL);
arrange(NULL);
@@ -1936,7 +1952,7 @@ updategeom(void)
m->clients = c->next;
detachstack(c);
c->mon = mons;
- attach(c);
+ attachBelow(c);
attachstack(c);
}
if (m == selmon)