X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=d5bc30eba90bf642b0318c2817608bbe14716087;hb=cff951c65086950eeef5723b65dc06cbe7cdfa19;hp=956b13f021c79c2ede8bba8fec983327b2034129;hpb=ca65478c8968434c78aacf4a102ccbbe4a66ad9e;p=dwm.git diff --git a/client.c b/client.c index 956b13f..d5bc30e 100644 --- a/client.c +++ b/client.c @@ -84,13 +84,11 @@ void focus(Client *c) { Client *old; - if(!issel) + if(!issel || (c && !isvisible(c))) return; if(!sel) sel = c; else if(sel != c) { - if(maximized) - togglemax(NULL); old = sel; sel = c; if(old) { @@ -281,6 +279,16 @@ resize(Client *c, Bool sizehints, Corner sticky) { if(sticky == BotLeft || sticky == BotRight) c->y = bottom - c->h; + /* offscreen appearance fixes */ + if(c->x + c->w < 0) + c->x = 0; + if(c->y + c->h < bh) + c->y = bh; + if(c->x > sw) + c->x = sw - c->w; + if(c->y > sh) + c->y = sh - c->h; + resizetitle(c); wc.x = c->x; wc.y = c->y; @@ -360,44 +368,10 @@ updatetitle(Client *c) { } void -togglemax(Arg *arg) { - int ox, oy, ow, oh; - Client *c; - XEvent ev; - - if(!sel) - return; - - if((maximized = !maximized)) { - ox = sel->x; - oy = sel->y; - ow = sel->w; - oh = sel->h; - sel->x = sx; - sel->y = sy + bh; - sel->w = sw - 2; - sel->h = sh - 2 - bh; - - restack(); - for(c = getnext(clients); c; c = getnext(c->next)) - if(c != sel) - ban(c); - resize(sel, arrange == dofloat, TopLeft); - - sel->x = ox; - sel->y = oy; - sel->w = ow; - sel->h = oh; - } - else - arrange(NULL); - while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); -} - -void unmanage(Client *c) { Client *nc; + /* The server grab construct avoids race conditions. */ XGrabServer(dpy); XSetErrorHandler(xerrordummy);