X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=a6e4fc04debc727c811ab3fe20427ffa15a71e6f;hp=f8467d6116d9ed3202324093d4c697dfd0fe8915;hb=749901f7f7bee4b62424701d6088dde4caa64c51;hpb=491b0978baa9a688aec49ab8b365df7a8be2537b diff --git a/dwm.c b/dwm.c index f8467d6..a6e4fc0 100644 --- a/dwm.c +++ b/dwm.c @@ -145,6 +145,7 @@ static void applyrules(Client *c); static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact); static void arrange(Monitor *m); static void arrangemon(Monitor *m); +static void attach_as_master(Client *c); static void attach(Client *c); static void attachstack(Client *c); static void buttonpress(XEvent *e); @@ -410,13 +411,17 @@ arrangemon(Monitor *m) { } void +attach_as_master(Client *c) { + c->next = c->mon->clients; + c->mon->clients = c; +} +void attach(Client *c) { if (c->mon->sel) { c->next = c->mon->sel->next; c->mon->sel->next = c; } else { - c->next = c->mon->clients; - c->mon->clients = c; + attach_as_master(c); } } @@ -547,6 +552,7 @@ clientmessage(XEvent *e) { || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); } else if(cme->message_type == netatom[NetActiveWindow]) { + return; if(!ISVISIBLE(c)) { c->mon->seltags ^= 1; c->mon->tagset[c->mon->seltags] = c->tags; @@ -695,9 +701,10 @@ detachstack(Client *c) { // WARNING if you detach() before detachstack() this will select last visible window for(i = nextvisible(c->mon->clients); i && i != c; i = nextvisible(i->next)) next_sel = i; - // failing that, find first visible window + // failing that, find first visible window (besides c) if (!next_sel) - for(i = nextvisible(c->mon->clients); i && i != c; i = nextvisible(i->next)) + for(i = nextvisible(c->mon->clients); i && i == c; i = nextvisible(i->next)); + if (i != c) next_sel = i; c->mon->sel = next_sel; } @@ -1236,7 +1243,7 @@ nextvisible(Client *c) { void pop(Client *c) { detach(c); - attach(c); + attach_as_master(c); focus(c); arrange(c->mon); } @@ -1628,6 +1635,17 @@ sigchld(int unused) { void spawn(const Arg *arg) { + int tag = 0, i; + if(arg->v == termcmd) { + for(i = 0; i < 32; ++i) { + if(selmon->tagset[selmon->seltags] & (1 << i)) { + tag = i; + break; + } + } + _SWM_WS[8] = swm_tags[tag][0]; + _SWM_WS[9] = swm_tags[tag][1]; + } if(arg->v == dmenucmd) dmenumon[0] = '0' + selmon->num; if(fork() == 0) {