X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=14edf7c3ac71b4aefac8f1bcba6c436320ca2afa;hb=442334641e4124d8c32387287d431a83761ff916;hp=971098918efa6e23d74f411f4b3af79b674db6cd;hpb=895902b57adbfe26f982a3eb4e2ee8f3aa4dd408;p=dwm.git diff --git a/client.c b/client.c index 9710989..14edf7c 100644 --- a/client.c +++ b/client.c @@ -24,7 +24,7 @@ resizetitle(Client *c) c->tw = c->w + 2; c->tx = c->x + c->w - c->tw + 2; c->ty = c->y; - if(c->tags[tsel]) + if(isvisible(c)) XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); else XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th); @@ -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,12 +257,13 @@ 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(c->tags[tsel]) + 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); }