JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
merged focus{prev.next} into focusclient(1/-1)
[dwm.git] / layout.c
index 8b4c940..1e8f113 100644 (file)
--- a/layout.c
+++ b/layout.c
@@ -2,6 +2,7 @@
  * See LICENSE file for license details.
  */
 #include "dwm.h"
+#include <stdlib.h>
 
 unsigned int blw = 0;
 Layout *lt = NULL;
@@ -69,30 +70,26 @@ LAYOUTS
 /* extern */
 
 void
-focusnext(const char *arg) {
+focusclient(const char *arg) {
        Client *c;
    
-       if(!sel)
+       if(!sel || !arg)
                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(const char *arg) {
-       Client *c;
-
-       if(!sel)
+       switch(atoi(arg)) {
+       default:
                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);
+       case 1:
+               for(c = sel->next; c && !isvisible(c); c = c->next);
+               if(!c)
+                       for(c = clients; c && !isvisible(c); c = c->next);
+               break;
+       case -1:
+               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);
+               }
+               break;
        }
        if(c) {
                focus(c);
@@ -119,11 +116,17 @@ incmasterw(const char *arg) {
 
 void
 incnmaster(const char *arg) {
-       int i = arg ? atoi(arg) : 0;
-       if((lt->arrange != tile) || (nmaster + i < 1)
-       || (wah / (nmaster + i) <= 2 * BORDERPX))
-               return;
-       nmaster += i;
+       int i;
+
+       if(!arg)
+               nmaster = NMASTER;
+       else {
+               i = atoi(arg);
+               if((lt->arrange != tile) || (nmaster + i < 1)
+               || (wah / (nmaster + i) <= 2 * BORDERPX))
+                       return;
+               nmaster += i;
+       }
        if(sel)
                lt->arrange();
        else
@@ -174,7 +177,7 @@ restack(void) {
 
 void
 setlayout(const char *arg) {
-       unsigned int i;
+       int i;
 
        if(!arg) {
                for(i = 0; i < nlayouts && lt != &layout[i]; i++);