X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=2a981fc8e90b54847018150959669e2aa47b48e3;hb=5b44976a2d8bdd1397727663ce019374d6b2730a;hp=e0ab719752cb5b4a990569959c75938c5b2f7b5a;hpb=9cd686c93a80b4095d4ee0960bef320ccd9ea02c;p=dwm.git diff --git a/client.c b/client.c index e0ab719..2a981fc 100644 --- a/client.c +++ b/client.c @@ -28,17 +28,19 @@ next(Client *c) void zoom(Arg *arg) { - Client **l, *old; + Client **l; - if(!(old = sel)) + if(!sel) return; + if(sel == next(clients)) + sel = next(sel->next); + for(l = &clients; *l && *l != sel; l = &(*l)->next); *l = sel->next; - old->next = clients; /* pop */ - clients = old; - sel = old; + sel->next = clients; /* pop */ + clients = sel; arrange(NULL); focus(sel); } @@ -54,7 +56,6 @@ max(Arg *arg) sel->h = sh - 2 * sel->border - bh; craise(sel); resize(sel, False); - discard_events(EnterWindowMask); } void @@ -117,7 +118,6 @@ floating(Arg *arg) focus(sel); } } - discard_events(EnterWindowMask); } void @@ -168,13 +168,12 @@ tiling(Arg *arg) else ban_client(c); } - if(sel && !sel->tags[tsel]) { + if(!sel || (sel && !sel->tags[tsel])) { if((sel = next(clients))) { craise(sel); focus(sel); } } - discard_events(EnterWindowMask); } void @@ -320,14 +319,16 @@ void focus(Client *c) { Client *old = sel; + XEvent ev; + XFlush(dpy); sel = c; if(old && old != c) draw_client(old); draw_client(c); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); XFlush(dpy); - discard_events(EnterWindowMask); + while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } static void @@ -404,8 +405,6 @@ manage(Window w, XWindowAttributes *wa) c->next = *l; /* *l == nil */ *l = c; - XMapRaised(dpy, c->win); - XMapRaised(dpy, c->title); XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, @@ -418,10 +417,17 @@ manage(Window w, XWindowAttributes *wa) || ((c->maxw == c->minw) && (c->maxh == c->minh)); arrange(NULL); - if(c->tags[tsel]) + /* mapping the window now prevents flicker */ + if(c->tags[tsel]) { + XMapRaised(dpy, c->win); + XMapRaised(dpy, c->title); focus(c); - else + } + else { ban_client(c); + XMapRaised(dpy, c->win); + XMapRaised(dpy, c->title); + } } void