JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Add some #define to make code more obvious
[spectrwm.git] / scrotwm.c
index d8e5d05..a75a942 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -420,7 +420,8 @@ union arg {
 
 void   focus(struct swm_region *, union arg *);
 void   focus_magic(struct ws_win *, int);
-
+#define SWM_F_GENERIC          (0)
+#define SWM_F_TRANSIENT                (1)
 /* quirks */
 struct quirk {
        char                    *class;
@@ -1653,15 +1654,14 @@ focus(struct swm_region *r, union arg *args)
                else
                        winfocus = TAILQ_FIRST(&r->ws->winlist);
                        
-               focus_magic(winfocus, 0);
+               focus_magic(winfocus, SWM_F_GENERIC);
                return;
        }
 
-       cur_focus = r->ws->focus;
-       if (cur_focus == NULL) {
+       if (r->ws->focus == NULL)
                return;
-       }
 
+       cur_focus = r->ws->focus;
        ws = r->ws;
        wl = &ws->winlist;
 
@@ -1695,22 +1695,12 @@ focus(struct swm_region *r, union arg *args)
                }
                break;
        case SWM_ARG_ID_FOCUSNEXT:
-               cur_focus = r->ws->focus;
-               if (cur_focus == NULL)
-                       return;
-               wl = &cur_focus->ws->winlist;
-
                winfocus = TAILQ_NEXT(cur_focus, entry);
                if (winfocus == NULL)
                        winfocus = TAILQ_FIRST(wl);
                break;
 
        case SWM_ARG_ID_FOCUSMAIN:
-               cur_focus = r->ws->focus;
-               if (cur_focus == NULL)
-                       return;
-               wl = &cur_focus->ws->winlist;
-
                winfocus = TAILQ_FIRST(wl);
                if (winfocus == cur_focus)
                        winfocus = cur_focus->ws->focus_prev;
@@ -1725,7 +1715,7 @@ focus(struct swm_region *r, union arg *args)
        if (winfocus == winlostfocus || winfocus == NULL)
                return;
 
-       focus_magic(winfocus, 0);
+       focus_magic(winfocus, SWM_F_GENERIC);
 }
 
 void
@@ -2193,7 +2183,7 @@ max_stack(struct workspace *ws, struct swm_geometry *g)
                if (parent)
                        XMapRaised(display, parent->id);
                stack_floater(wintrans, ws->r);
-               focus_magic(wintrans, 1);
+               focus_magic(wintrans, SWM_F_TRANSIENT);
        }
 }
 
@@ -3737,7 +3727,7 @@ focus_magic(struct ws_win *win, int do_trans)
        if (win == NULL)
                return;
 
-       if (do_trans && win->child_trans) {
+       if (do_trans == SWM_F_TRANSIENT && win->child_trans) {
                /* win = parent & has a transient so focus on that */
                if (win->java) {
                        focus_win(win->child_trans);
@@ -3803,7 +3793,7 @@ buttonpress(XEvent *e)
        if ((win = find_window(ev->window)) == NULL)
                return;
 
-       focus_magic(win, 1);
+       focus_magic(win, SWM_F_TRANSIENT);
        action = client_click;
 
        for (i = 0; i < LENGTH(buttons); i++)
@@ -3913,7 +3903,7 @@ enternotify(XEvent *e)
        if ((win = find_window(ev->window)) == NULL)
                return;
 
-       focus_magic(win, 1);
+       focus_magic(win, SWM_F_TRANSIENT);
 }
 
 void
@@ -3976,7 +3966,7 @@ maprequest(XEvent *e)
        /* make new win focused */
        r = root_to_region(win->wa.root);
        if (win->ws == r->ws)
-               focus_magic(win, 0);
+               focus_magic(win, SWM_F_GENERIC);
 }
 
 void