Overview
Focus actions enable keyboard-driven navigation between windows based on their spatial relationship. Instead of cycling through windows with Cmd+Tab, you can move focus directionally (up, down, left, right) or through window stacking order. Defined in the staticfocus array (line 86):
Computed Property
Returns Used to identify actions that change window focus without resizing or moving the focused window.
true for all focus actions (line 96)Directional Focus
Directional focus actions move keyboard focus to the nearest window in the specified direction.focusLeft
Moves focus to the nearest window positioned to the left.Raw Value:
"FocusLeft"URL Scheme: loop://FocusLeftBehavior:- Activates the window whose center point is nearest to the left
- Searches within the same screen/Space
- No effect if no window exists to the left
- Does not move or resize any windows
.left (line 151)Visual:focusRight
Moves focus to the nearest window positioned to the right.Raw Value:
"FocusRight"URL Scheme: loop://FocusRightBehavior:- Activates the window whose center point is nearest to the right
- Searches within the same screen/Space
- No effect if no window exists to the right
- Does not move or resize any windows
.right (line 152)Visual:focusUp
Moves focus to the nearest window positioned above.Raw Value:
"FocusUp"URL Scheme: loop://FocusUpBehavior:- Activates the window whose center point is nearest above
- Searches within the same screen/Space
- No effect if no window exists above
- Does not move or resize any windows
.top (line 153)Visual:focusDown
Moves focus to the nearest window positioned below.Raw Value:
"FocusDown"URL Scheme: loop://FocusDownBehavior:- Activates the window whose center point is nearest below
- Searches within the same screen/Space
- No effect if no window exists below
- Does not move or resize any windows
.bottom (line 154)Visual:Stack-Based Focus
focusNextInStack
Moves focus to the next window in the stacking order.Raw Value: Use Case: Cycle through overlapping windows without spatial reasoning
"FocusNextInStack"URL Scheme: loop://FocusNextInStackBehavior:- Cycles through windows in z-order (front to back)
- Similar to Cmd+Tab but for visible windows only
- Wraps around to first window after reaching last
- Works within current screen/Space
- Does not move or resize any windows
Navigation Direction Mapping
Focus actions map toNavigationDirection for internal routing (lines 149-157):
Usage Examples
Vim-Style Navigation
- Cmd+Ctrl+H: Focus left
- Cmd+Ctrl+J: Focus down
- Cmd+Ctrl+K: Focus up
- Cmd+Ctrl+L: Focus right
Multi-Window Workflow
Overlapping Windows
Combining with Positioning
Focus actions are particularly powerful when combined with window positioning:Spatial Navigation Algorithm
Directional focus uses spatial proximity to determine the target window:- Calculate center points of all visible windows
- Filter by direction (e.g., for
focusLeft, only windows with center X < current window center X) - Compute distances from current window center to candidate window centers
- Select nearest window based on Euclidean distance
- Activate the target window
Edge Cases
Multiple windows at same distance
Multiple windows at same distance
When multiple windows are equidistant, Loop selects based on:
- Z-order (frontmost window preferred)
- Window size (larger windows preferred)
No window in direction
No window in direction
If no window exists in the specified direction:
- Focus remains on current window
- No visual feedback or error
- Can be combined with screen switching for cross-display navigation
Diagonal window positions
Diagonal window positions
For windows positioned diagonally:
- Directional focus uses the primary axis (horizontal or vertical)
- May require two focus actions to reach diagonal windows
- Example: Focus right, then focus up
Radial Menu Behavior
Focus actions don’t have specific directional angles in the radial menu (line 102):Keyboard-Driven Workflows
Focus actions enable fully keyboard-driven window management:Tiling Workflow
- Focus window with directional navigation
- Position window with positioning actions
- Repeat for all windows in layout
Quick Reference Layout
Accessibility Benefits
Focus actions provide significant accessibility advantages:- Keyboard-only navigation: No mouse required
- Spatial reasoning: Intuitive directional movement
- Predictable behavior: Consistent navigation patterns
- Fast context switching: Direct window selection without cycling
Troubleshooting
Focus doesn't move to expected window
Focus doesn't move to expected window
- Verify windows are on the same screen/Space
- Check if target window is minimized or hidden
- Ensure target window is actually positioned in the expected direction
- Hidden windows and minimized windows are excluded from focus navigation
focusNextInStack cycles unexpectedly
focusNextInStack cycles unexpectedly
- Only visible windows are included in stack order
- Minimized and hidden windows are excluded
- Stack order reflects z-order, not window creation order
Focus action has no effect
Focus action has no effect
- No window exists in the specified direction
- Current window is the only visible window
- Target window may be on a different screen (use screen switching first)
Related Actions
Screen Switching
Move focus to windows on other displays
General Actions
Minimize and hide windows
Size Adjustment
Move windows after focusing them
WindowDirection Overview
Complete action reference