X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=14edf7c3ac71b4aefac8f1bcba6c436320ca2afa;hb=4ad20ffc2c23d29329bc7349985d889f2cb45612;hp=5be438e8b65e01462be644db375b11a29800582b;hpb=d7413ffd2d9a84fc3140b28b26f8cb6bb80164e4;p=dwm.git diff --git a/client.c b/client.c index 5be438e..14edf7c 100644 --- a/client.c +++ b/client.c @@ -49,18 +49,17 @@ ban(Client *c) void focus(Client *c) { - if (!issel) - return; Client *old = sel; - XEvent ev; + if (!issel) + return; + if(sel && sel->ismax) + togglemax(NULL); sel = c; if(old && old != c) drawtitle(old); drawtitle(c); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); - XSync(dpy, False); - while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } void @@ -71,14 +70,11 @@ focusnext(Arg *arg) if(!sel) return; - if(sel->ismax) - togglemax(NULL); - if(!(c = getnext(sel->next))) c = getnext(clients); if(c) { - higher(c); focus(c); + restack(); } } @@ -90,16 +86,13 @@ focusprev(Arg *arg) if(!sel) return; - if(sel->ismax) - togglemax(NULL); - if(!(c = getprev(sel->prev))) { for(c = clients; c && c->next; c = c->next); c = getprev(c); } if(c) { - higher(c); focus(c); + restack(); } } @@ -181,13 +174,6 @@ gravitate(Client *c, Bool invert) } void -higher(Client *c) -{ - XRaiseWindow(dpy, c->win); - XRaiseWindow(dpy, c->title); -} - -void killclient(Arg *arg) { if(!sel) @@ -271,11 +257,12 @@ manage(Window w, XWindowAttributes *wa) || (c->maxw && c->minw && c->maxw == c->minw && c->maxh == c->minh); settitle(c); - arrange(NULL); - /* mapping the window now prevents flicker */ - XMapRaised(dpy, c->win); - XMapRaised(dpy, c->title); + if(isvisible(c)) + sel = c; + arrange(NULL); + XMapWindow(dpy, c->win); + XMapWindow(dpy, c->title); if(isvisible(c)) focus(c); } @@ -410,7 +397,7 @@ togglemax(Arg *arg) sel->w = sw - 2; sel->h = sh - 2 - bh; - higher(sel); + restack(); resize(sel, arrange == dofloat, TopLeft); sel->x = ox; @@ -446,9 +433,9 @@ unmanage(Client *c) XSync(dpy, False); XSetErrorHandler(xerror); XUngrabServer(dpy); - arrange(NULL); if(sel) focus(sel); + arrange(NULL); } void @@ -474,6 +461,6 @@ zoom(Arg *arg) clients->prev = sel; sel->next = clients; clients = sel; - arrange(NULL); focus(sel); + arrange(NULL); }