X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=45f2d190c1082802b63c1bf212ba98cfd4590001;hb=64871a7045077bb2ec4cbcd62a74cabbe6b45096;hp=9a30526be709411c9fd7c870ee50920d11fbf2a2;hpb=30af19d4426ca32dc38318bbe87534cc44484998;p=dwm.git diff --git a/client.c b/client.c index 9a30526..45f2d19 100644 --- a/client.c +++ b/client.c @@ -46,6 +46,21 @@ grabbuttons(Client *c, Bool focused) { GrabModeAsync, GrabModeSync, None, None); } +static Bool +isprotodel(Client *c) { + int i, n; + Atom *protocols; + Bool ret = False; + + if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { + for(i = 0; !ret && i < n; i++) + if(protocols[i] == wmatom[WMDelete]) + ret = True; + XFree(protocols); + } + return ret; +} + static void setclientstate(Client *c, long state) { long data[] = {state, None}; @@ -135,6 +150,38 @@ focus(Client *c) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); } +void +focusnext(Arg *arg) { + Client *c; + + if(!sel) + return; + for(c = sel->next; c && !isvisible(c); c = c->next); + if(!c) + for(c = clients; c && !isvisible(c); c = c->next); + if(c) { + focus(c); + restack(); + } +} + +void +focusprev(Arg *arg) { + Client *c; + + if(!sel) + return; + for(c = sel->prev; c && !isvisible(c); c = c->prev); + if(!c) { + for(c = clients; c && c->next; c = c->next); + for(; c && !isvisible(c); c = c->prev); + } + if(c) { + focus(c); + restack(); + } +} + Client * getclient(Window w) { Client *c; @@ -145,21 +192,6 @@ getclient(Window w) { return NULL; } -Bool -isprotodel(Client *c) { - int i, n; - Atom *protocols; - Bool ret = False; - - if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { - for(i = 0; !ret && i < n; i++) - if(protocols[i] == wmatom[WMDelete]) - ret = True; - XFree(protocols); - } - return ret; -} - void killclient(Arg *arg) { if(!sel)