X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=487cb0caebec3c952f344a9aeefd39bb88855e15;hb=6797ff84ae00d8039aa897d8b713ccdb771cd336;hp=e0ab719752cb5b4a990569959c75938c5b2f7b5a;hpb=9cd686c93a80b4095d4ee0960bef320ccd9ea02c;p=dwm.git diff --git a/client.c b/client.c index e0ab719..487cb0c 100644 --- a/client.c +++ b/client.c @@ -28,17 +28,21 @@ next(Client *c) void zoom(Arg *arg) { - Client **l, *old; + Client **l, *c; - if(!(old = sel)) + if(!sel) return; + if(sel == next(clients) && sel->next) { + if((c = next(sel->next))) + sel = c; + } + for(l = &clients; *l && *l != sel; l = &(*l)->next); *l = sel->next; - old->next = clients; /* pop */ - clients = old; - sel = old; + sel->next = clients; /* pop */ + clients = sel; arrange(NULL); focus(sel); } @@ -54,7 +58,6 @@ max(Arg *arg) sel->h = sh - 2 * sel->border - bh; craise(sel); resize(sel, False); - discard_events(EnterWindowMask); } void @@ -117,7 +120,6 @@ floating(Arg *arg) focus(sel); } } - discard_events(EnterWindowMask); } void @@ -168,13 +170,12 @@ tiling(Arg *arg) else ban_client(c); } - if(sel && !sel->tags[tsel]) { + if(!sel || (sel && !sel->tags[tsel])) { if((sel = next(clients))) { craise(sel); focus(sel); } } - discard_events(EnterWindowMask); } void @@ -320,14 +321,16 @@ void focus(Client *c) { Client *old = sel; + XEvent ev; + XFlush(dpy); sel = c; if(old && old != c) draw_client(old); draw_client(c); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); XFlush(dpy); - discard_events(EnterWindowMask); + while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } static void @@ -404,8 +407,6 @@ manage(Window w, XWindowAttributes *wa) c->next = *l; /* *l == nil */ *l = c; - XMapRaised(dpy, c->win); - XMapRaised(dpy, c->title); XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, @@ -418,10 +419,17 @@ manage(Window w, XWindowAttributes *wa) || ((c->maxw == c->minw) && (c->maxh == c->minh)); arrange(NULL); - if(c->tags[tsel]) + /* mapping the window now prevents flicker */ + if(c->tags[tsel]) { + XMapRaised(dpy, c->win); + XMapRaised(dpy, c->title); focus(c); - else + } + else { ban_client(c); + XMapRaised(dpy, c->win); + XMapRaised(dpy, c->title); + } } void @@ -491,6 +499,10 @@ resize(Client *c, Bool inc) if(c->inch) c->h -= (c->h - c->baseh) % c->inch; } + if(c->x > sw) /* might happen on restart */ + c->x = sw - c->w; + if(c->y > sh) + c->ty = c->y = sh - c->h; if(c->minw && c->w < c->minw) c->w = c->minw; if(c->minh && c->h < c->minh) @@ -592,12 +604,12 @@ draw_client(Client *c) if(c->tags[i]) { dc.x += dc.w; dc.w = textw(c->tags[i]) + dc.font.height; - drawtext(c->tags[i], True); + drawtext(c->tags[i], False, True); } } dc.x += dc.w; dc.w = textw(c->name) + dc.font.height; - drawtext(c->name, True); + drawtext(c->name, False, True); XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0); XFlush(dpy);