From c0e319b5c3dd65afd0108a0edbc640808ae73d11 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sat, 23 Oct 2021 18:29:37 +0200 Subject: [PATCH] Attachtop patch --- src/dwm.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/dwm.c b/src/dwm.c index df9d9d0..b5ca23f 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -51,7 +51,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)->mx+(m)->mw) - MAX((x),(m)->mx)) \ * MAX(0, MIN((y)+(h),(m)->my+(m)->mh) - MAX((y),(m)->my))) -#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) @@ -171,6 +172,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 attachtop(Client *c); static void attachstack(Client *c); static void buttonpress(XEvent *e); static void checkotherwm(void); @@ -466,6 +468,25 @@ attach(Client *c) c->mon->clients = c; } +void +attachtop(Client *c) +{ + int n; + Monitor *m = selmon; + Client *below; + + for (n = 1, below = c->mon->clients; + below && below->next && (below->isfloating || !ISVISIBLEONTAG(below, c->tags) || n != m->nmaster); + n = below->isfloating || !ISVISIBLEONTAG(below, c->tags) ? n + 0 : n + 1, below = below->next); + c->next = NULL; + if (below) { + c->next = below->next; + below->next = c; + } + else + c->mon->clients = c; +} + void attachstack(Client *c) { @@ -1218,7 +1239,7 @@ manage(Window w, XWindowAttributes *wa) c->isfloating = c->oldstate = trans != None || c->isfixed; if (c->isfloating) XRaiseWindow(dpy, c->win); - attach(c); + attachtop(c); attachstack(c); XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, (unsigned char *) &(c->win), 1); @@ -1892,7 +1913,7 @@ sendmon(Client *c, Monitor *m) detachstack(c); c->mon = m; c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ - attach(c); + attachtop(c); attachstack(c); focus(NULL); arrange(NULL); @@ -2419,6 +2440,7 @@ updatebars(void) .background_pixmap = ParentRelative, .event_mask = ButtonPressMask|ExposureMask }; + XClassHint ch = {"dwm", "dwm"}; for (m = mons; m; m = m->next) { if (m->barwin) @@ -2509,7 +2531,7 @@ updategeom(void) m->clients = c->next; detachstack(c); c->mon = mons; - attach(c); + attachtop(c); attachstack(c); } if (m == selmon)