X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=layout.c;h=c4670801b35db635a19cee0d00e78dfe2bcfa965;hb=e40448fd6340620354d82d801d975eaa53dbd924;hp=a660fd7dd93c9527b64288d4a4b9da85685270a4;hpb=77044e876511f51c34bde379d89e2de754707ee6;p=dwm.git diff --git a/layout.c b/layout.c index a660fd7..c467080 100644 --- a/layout.c +++ b/layout.c @@ -2,6 +2,8 @@ #include "dwm.h" #include +/* static */ + typedef struct { const char *symbol; void (*arrange)(void); @@ -10,10 +12,8 @@ typedef struct { unsigned int blw = 0; static Layout *lt = NULL; -/* static */ - static void -floating(void) { +floating(void) { /* default floating layout */ Client *c; for(c = clients; c; c = c->next) @@ -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);