dwm-attachabove-6.0.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-attachabove-6.0.diff (1632B)
---
1 diff --git a/dwm.c b/dwm.c
2 index 1d78655..a9e0ea4 100644
3 --- a/dwm.c
4 +++ b/dwm.c
5 @@ -160,6 +160,7 @@ static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool inter
6 static void arrange(Monitor *m);
7 static void arrangemon(Monitor *m);
8 static void attach(Client *c);
9 +static void attachabove(Client *c);
10 static void attachstack(Client *c);
11 static void buttonpress(XEvent *e);
12 static void checkotherwm(void);
13 @@ -418,6 +419,19 @@ attach(Client *c) {
14 }
15
16 void
17 +attachabove(Client *c) {
18 + if(c->mon->sel == NULL || c->mon->sel == c->mon->clients || c->mon->sel->isfloating) {
19 + attach(c);
20 + return;
21 + }
22 +
23 + Client *at;
24 + for(at = c->mon->clients; at->next != c->mon->sel; at = at->next);
25 + c->next = at->next;
26 + at->next = c;
27 +}
28 +
29 +void
30 attachstack(Client *c) {
31 c->snext = c->mon->stack;
32 c->mon->stack = c;
33 @@ -1155,7 +1169,7 @@ manage(Window w, XWindowAttributes *wa) {
34 c->isfloating = c->oldstate = trans != None || c->isfixed;
35 if(c->isfloating)
36 XRaiseWindow(dpy, c->win);
37 - attach(c);
38 + attachabove(c);
39 attachstack(c);
40 XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
41 setclientstate(c, NormalState);
42 @@ -1480,7 +1494,7 @@ sendmon(Client *c, Monitor *m) {
43 detachstack(c);
44 c->mon = m;
45 c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
46 - attach(c);
47 + attachabove(c);
48 attachstack(c);
49 focus(NULL);
50 arrange(NULL);
51 @@ -1900,7 +1914,7 @@ updategeom(void) {
52 m->clients = c->next;
53 detachstack(c);
54 c->mon = mons;
55 - attach(c);
56 + attachabove(c);
57 attachstack(c);
58 }
59 if(m == selmon)