attachbelow patch
This commit is contained in:
37
dwm.c
37
dwm.c
@@ -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)
|
||||
|
Reference in New Issue
Block a user