attachbelow patch

This commit is contained in:
Sravan Balaji
2020-11-23 20:56:51 -05:00
parent 1dc6430ff6
commit 1950543da6
5 changed files with 281 additions and 42 deletions

37
dwm.c
View File

@@ -150,6 +150,8 @@ static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
static void aspectresize(const Arg *arg);
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);
@@ -441,6 +443,26 @@ 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)
@@ -1109,7 +1131,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);
@@ -1530,7 +1555,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);
@@ -2074,7 +2102,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)