X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=client.c;h=6a231b90e5b4bfb49d5abad1ae4119103568f485;hb=666fae97e67810089ffbddd019d655bc4f9f7838;hp=971098918efa6e23d74f411f4b3af79b674db6cd;hpb=895902b57adbfe26f982a3eb4e2ee8f3aa4dd408;p=dwm.git diff --git a/client.c b/client.c index 9710989..6a231b9 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); @@ -52,15 +52,12 @@ focus(Client *c) if (!issel) return; Client *old = sel; - XEvent ev; 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 @@ -77,8 +74,8 @@ focusnext(Arg *arg) if(!(c = getnext(sel->next))) c = getnext(clients); if(c) { - higher(c); focus(c); + restack(); } } @@ -98,8 +95,8 @@ focusprev(Arg *arg) c = getprev(c); } if(c) { - higher(c); focus(c); + restack(); } } @@ -180,13 +177,6 @@ gravitate(Client *c, Bool invert) c->y += dy; } -void -higher(Client *c) -{ - XRaiseWindow(dpy, c->win); - XRaiseWindow(dpy, c->title); -} - void killclient(Arg *arg) { @@ -271,12 +261,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 +401,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 +437,9 @@ unmanage(Client *c) XSync(dpy, False); XSetErrorHandler(xerror); XUngrabServer(dpy); - arrange(NULL); if(sel) focus(sel); + arrange(NULL); } void @@ -474,6 +465,6 @@ zoom(Arg *arg) clients->prev = sel; sel->next = clients; clients = sel; - arrange(NULL); focus(sel); + arrange(NULL); }