X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=layout.c;h=46e82c2ad834b943ecabd8b932a1a6b7b602522c;hb=a923298d3577dca0e69fd70edbef56c7822258e3;hp=4fb0be3ff7c0447d7c26f9ea1ac5c4c9c5b34de9;hpb=9e56e1ded6889335035c8ffbe2763d3d83978673;p=dwm.git diff --git a/layout.c b/layout.c index 4fb0be3..46e82c2 100644 --- a/layout.c +++ b/layout.c @@ -42,22 +42,30 @@ arrange(void) { } void -focusclient(const char *arg) { +focusnext(const char *arg) { Client *c; - - if(!sel || !arg) + + if(!sel) return; - if(atoi(arg) < 0) { - 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); - } + 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(); } - else { - for(c = sel->next; c && !isvisible(c); c = c->next); - if(!c) - for(c = clients; c && !isvisible(c); c = c->next); +} + +void +focusprev(const char *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); @@ -86,10 +94,10 @@ void initlayouts(void) { unsigned int i, w; - lt = &layout[0]; - nlayouts = sizeof layout / sizeof layout[0]; + lt = &layouts[0]; + nlayouts = sizeof layouts / sizeof layouts[0]; for(blw = i = 0; i < nlayouts; i++) { - w = textw(layout[i].symbol); + w = textw(layouts[i].symbol); if(w > blw) blw = w; } @@ -136,14 +144,14 @@ setlayout(const char *arg) { if(!arg) { lt++; - if(lt == layout + nlayouts) - lt = layout; + if(lt == layouts + nlayouts) + lt = layouts; } else { i = atoi(arg); if(i < 0 || i >= nlayouts) return; - lt = &layout[i]; + lt = &layouts[i]; } if(sel) arrange();