X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=cf3a686ca3cc377fd79aa99cc14bc2426ef8cb13;hb=f3e672efd8d3efb05f7e7dc48fd87f3929c18932;hp=03d158f16648b40cdfd64f6aa9ce15b8a6451dc1;hpb=22399a3bc05406a89f6ad717800b4d9ba41f6e0a;p=dwm.git diff --git a/client.c b/client.c index 03d158f..cf3a686 100644 --- a/client.c +++ b/client.c @@ -153,6 +153,14 @@ focus(Client *c) { } void +focustopvisible(void) { + Client *c; + + for(c = stack; c && !isvisible(c); c = c->snext); + focus(c); +} + +void killclient(const char *arg) { XEvent ev; @@ -366,21 +374,21 @@ updatetitle(Client *c) { if(!name.nitems) return; if(name.encoding == XA_STRING) - strncpy(c->name, (char *)name.value, sizeof c->name); + strncpy(c->name, (char *)name.value, sizeof c->name - 1); else { if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { - strncpy(c->name, *list, sizeof c->name); + strncpy(c->name, *list, sizeof c->name - 1); XFreeStringList(list); } } + c->name[sizeof c->name - 1] = '\0'; XFree(name.value); } void unmanage(Client *c) { - Client *nc; XWindowChanges wc; wc.border_width = c->oldborder; @@ -390,10 +398,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);