X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=fa486448432fd69eb1bc9547a16c739d23cf0652;hb=0aaa9a21f334a5c75b7efce2712384f57bd370cd;hp=1e3216e4c55a16e14ecbf86b577ee49c8e04c607;hpb=adaa28a6e600f636f5e86244ccef69e98419ba1a;p=dwm.git diff --git a/client.c b/client.c index 1e3216e..fa48644 100644 --- a/client.c +++ b/client.c @@ -49,13 +49,12 @@ focus(Client *c) Client *old = sel; XEvent ev; - XFlush(dpy); sel = c; if(old && old != c) drawtitle(old); drawtitle(c); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); - XFlush(dpy); + XSync(dpy, False); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } @@ -67,8 +66,8 @@ focusnext(Arg *arg) if(!sel) return; - if(!(c = getnext(sel->next))) - c = getnext(clients); + if(!(c = getnext(sel->next, tsel))) + c = getnext(clients, tsel); if(c) { higher(c); c->revert = sel; @@ -178,7 +177,7 @@ killclient(Arg *arg) if(!sel) return; if(sel->proto & WM_PROTOCOL_DELWIN) - sendevent(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]); + sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]); else XKillClient(dpy, sel->win); } @@ -193,7 +192,7 @@ lower(Client *c) void manage(Window w, XWindowAttributes *wa) { - Client *c, **l; + Client *c; XSetWindowAttributes twa; Window trans; @@ -224,10 +223,11 @@ manage(Window w, XWindowAttributes *wa) settitle(c); settags(c); - for(l = &clients; *l; l = &(*l)->next); - c->next = *l; /* *l == nil */ - *l = c; + c->next = clients; + clients = c; + XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask, + GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, @@ -235,8 +235,8 @@ manage(Window w, XWindowAttributes *wa) XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, GrabModeAsync, GrabModeSync, None, None); - if(!c->dofloat) - c->dofloat = trans + if(!c->isfloat) + c->isfloat = trans || ((c->maxw == c->minw) && (c->maxh == c->minh)); arrange(NULL); @@ -250,6 +250,7 @@ manage(Window w, XWindowAttributes *wa) ban(c); XMapRaised(dpy, c->win); XMapRaised(dpy, c->title); + XSync(dpy, False); } } @@ -267,6 +268,18 @@ maximize(Arg *arg) } void +pop(Client *c) +{ + Client **l; + for(l = &clients; *l && *l != c; l = &(*l)->next); + *l = c->next; + + c->next = clients; /* pop */ + clients = c; + arrange(NULL); +} + +void resize(Client *c, Bool inc) { XConfigureEvent e; @@ -303,7 +316,7 @@ resize(Client *c, Bool inc) e.above = None; e.override_redirect = False; XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e); - XFlush(dpy); + XSync(dpy, False); } void @@ -353,7 +366,7 @@ settitle(Client *c) name.nitems = 0; c->name[0] = 0; - XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]); + XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]); if(!name.nitems) XGetWMName(dpy, c->win, &name); if(!name.nitems) @@ -393,7 +406,7 @@ unmanage(Client *c) free(c); - XFlush(dpy); + XSync(dpy, False); XSetErrorHandler(xerror); XUngrabServer(dpy); arrange(NULL); @@ -404,21 +417,16 @@ unmanage(Client *c) void zoom(Arg *arg) { - Client **l, *c; + Client *c; if(!sel) return; - if(sel == getnext(clients) && sel->next) { - if((c = getnext(sel->next))) + if(sel == getnext(clients, tsel) && sel->next) { + if((c = getnext(sel->next, tsel))) sel = c; } - for(l = &clients; *l && *l != sel; l = &(*l)->next); - *l = sel->next; - - sel->next = clients; /* pop */ - clients = sel; - arrange(NULL); + pop(sel); focus(sel); }