]> git.sur5r.net Git - i3/i3/commitdiff
Implement focus switching (focus left/right) for floating windows
authorMichael Stapelberg <michael@stapelberg.de>
Sat, 17 Sep 2011 18:28:41 +0000 (19:28 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 17 Sep 2011 18:28:41 +0000 (19:28 +0100)
Fixes: #475
src/tree.c

index 240c22a6551957b2c0fe2ccf162bfe80429d3342..3f0705fc0ef92f907d93f8aa7c43245e306e33e9 100644 (file)
@@ -421,12 +421,35 @@ static bool _tree_next(Con *con, char way, orientation_t orientation, bool wrap)
         return true;
     }
 
+    Con *parent = con->parent;
+
     if (con->type == CT_FLOATING_CON) {
-        /* TODO: implement focus for floating windows */
-        return false;
-    }
+        /* left/right focuses the previous/next floating container */
+        if (orientation == HORIZ) {
+            Con *next;
+            if (way == 'n')
+                next = TAILQ_NEXT(con, floating_windows);
+            else next = TAILQ_PREV(con, floating_head, floating_windows);
+
+            /* If there is no next/previous container, wrap */
+            if (!next) {
+                if (way == 'n')
+                    next = TAILQ_FIRST(&(parent->floating_head));
+                else next = TAILQ_LAST(&(parent->floating_head), floating_head);
+            }
 
-    Con *parent = con->parent;
+            /* Still no next/previous container? bail out */
+            if (!next)
+                return false;
+
+            con_focus(con_descend_focused(next));
+            return true;
+        } else {
+            /* up/down cycles through the Z-index */
+            /* TODO: implement cycling through the z-index */
+            return false;
+        }
+    }
 
     /* If the orientation does not match or there is no other con to focus, we
      * need to go higher in the hierarchy */