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) {
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;
resizetitle(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);