Merge branch 'patch-attachaside' into custom-dwm

This commit is contained in:
lhark 2016-11-14 20:06:26 -05:00
commit 3ad1273539

32
dwm.c
View file

@ -49,7 +49,8 @@
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) #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)) \ #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))) * 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 LENGTH(X) (sizeof X / sizeof X[0])
#define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
#define WIDTH(X) ((X)->w + 2 * (X)->bw) #define WIDTH(X) ((X)->w + 2 * (X)->bw)
@ -172,6 +173,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
static void arrange(Monitor *m); static void arrange(Monitor *m);
static void arrangemon(Monitor *m); static void arrangemon(Monitor *m);
static void attach(Client *c); static void attach(Client *c);
static void attachaside(Client *c);
static void attachstack(Client *c); static void attachstack(Client *c);
static void buttonpress(XEvent *e); static void buttonpress(XEvent *e);
static void checkotherwm(void); static void checkotherwm(void);
@ -210,6 +212,7 @@ static void maprequest(XEvent *e);
static void monocle(Monitor *m); static void monocle(Monitor *m);
static void motionnotify(XEvent *e); static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg); static void movemouse(const Arg *arg);
static Client *nexttagged(Client *c);
static Client *nexttiled(Client *c); static Client *nexttiled(Client *c);
static void pop(Client *); static void pop(Client *);
static void propertynotify(XEvent *e); static void propertynotify(XEvent *e);
@ -458,6 +461,17 @@ attach(Client *c)
c->mon->clients = c; c->mon->clients = c;
} }
void
attachaside(Client *c) {
Client *at = nexttagged(c);
if(!at) {
attach(c);
return;
}
c->next = at->next;
at->next = c;
}
void void
attachstack(Client *c) attachstack(Client *c)
{ {
@ -1218,7 +1232,7 @@ manage(Window w, XWindowAttributes *wa)
c->isfloating = c->oldstate = trans != None || c->isfixed; c->isfloating = c->oldstate = trans != None || c->isfixed;
if (c->isfloating) if (c->isfloating)
XRaiseWindow(dpy, c->win); XRaiseWindow(dpy, c->win);
attach(c); attachaside(c);
attachstack(c); attachstack(c);
XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
(unsigned char *) &(c->win), 1); (unsigned char *) &(c->win), 1);
@ -1366,6 +1380,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 * Client *
nexttiled(Client *c) nexttiled(Client *c)
{ {
@ -1636,7 +1660,7 @@ sendmon(Client *c, Monitor *m)
detachstack(c); detachstack(c);
c->mon = m; c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
attach(c); attachaside(c);
attachstack(c); attachstack(c);
focus(NULL); focus(NULL);
arrange(NULL); arrange(NULL);
@ -2163,7 +2187,7 @@ updategeom(void)
m->clients = c->next; m->clients = c->next;
detachstack(c); detachstack(c);
c->mon = mons; c->mon = mons;
attach(c); attachaside(c);
attachstack(c); attachstack(c);
} }
if (m == selmon) if (m == selmon)