X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=client.c;h=040dd15fc9d0419d9baf1ef3563701bafda95947;hb=caa7ab536224b0bf4dcd2790a51ead6b7a6cf119;hp=64da34374a1ec0f7b41472b1b1f3f704f570f7fe;hpb=b8bccb4ac5222a01ecd6a5f82997ea2ee3b84b8b;p=dwm.git diff --git a/client.c b/client.c index 64da343..040dd15 100644 --- a/client.c +++ b/client.c @@ -152,6 +152,14 @@ focus(Client *c) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); } +void +focustopvisible(void) { + Client *c; + + for(c = stack; c && !isvisible(c); c = c->snext); + focus(c); +} + void killclient(const char *arg) { XEvent ev; @@ -297,6 +305,8 @@ togglefloating(const char *arg) { if(!sel || lt->arrange == floating) return; sel->isfloating = !sel->isfloating; + if(sel->isfloating && sel->isfixed) + resize(sel, sel->x, sel->y, sel->minw, sel->minh, True); lt->arrange(); } @@ -365,9 +375,8 @@ updatetitle(Client *c) { XGetWMName(dpy, c->win, &name); if(!name.nitems) return; - if(name.encoding == XA_STRING) { + if(name.encoding == XA_STRING) strncpy(c->name, (char *)name.value, sizeof c->name - 1); - } else { if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) @@ -382,7 +391,6 @@ updatetitle(Client *c) { void unmanage(Client *c) { - Client *nc; XWindowChanges wc; wc.border_width = c->oldborder; @@ -392,10 +400,8 @@ unmanage(Client *c) { XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */ detach(c); detachstack(c); - if(sel == c) { - for(nc = stack; nc && !isvisible(nc); nc = nc->snext); - focus(nc); - } + if(sel == c) + focustopvisible(); XUngrabButton(dpy, AnyButton, AnyModifier, c->win); setclientstate(c, WithdrawnState); free(c->tags);