Skip to main content

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 static focus array (line 86):

Computed Property

Bool
Returns true for all focus actions (line 96)
Used to identify actions that change window focus without resizing or moving the focused window.

Directional Focus

Directional focus actions move keyboard focus to the nearest window in the specified direction.

focusLeft

WindowDirection
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
Navigation Direction: .left (line 151)Visual:

focusRight

WindowDirection
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
Navigation Direction: .right (line 152)Visual:

focusUp

WindowDirection
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
Navigation Direction: .top (line 153)Visual:

focusDown

WindowDirection
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
Navigation Direction: .bottom (line 154)Visual:

Stack-Based Focus

focusNextInStack

WindowDirection
Moves focus to the next window in the stacking order.Raw Value: "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
Stacking Order:
Use Case: Cycle through overlapping windows without spatial reasoning
Focus actions map to NavigationDirection for internal routing (lines 149-157):
This property enables directional window discovery algorithms.

Usage Examples

Vim-Style Navigation

Bind to keyboard shortcuts:
  • 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:
  1. Calculate center points of all visible windows
  2. Filter by direction (e.g., for focusLeft, only windows with center X < current window center X)
  3. Compute distances from current window center to candidate window centers
  4. Select nearest window based on Euclidean distance
  5. Activate the target window

Edge Cases

When multiple windows are equidistant, Loop selects based on:
  • Z-order (frontmost window preferred)
  • Window size (larger windows preferred)
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
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):
They appear as menu options rather than directional triggers.

Keyboard-Driven Workflows

Focus actions enable fully keyboard-driven window management:

Tiling Workflow

  1. Focus window with directional navigation
  2. Position window with positioning actions
  3. 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

  • 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
  • Only visible windows are included in stack order
  • Minimized and hidden windows are excluded
  • Stack order reflects z-order, not window creation order
  • 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)

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

Best Practices

Combine with positioning: Use focus actions to select a window, then immediately apply a positioning action. This creates powerful keyboard-driven workflows.
Consistent keybinds: Map focus actions to easily reachable key combinations. Vim-style HJKL or arrow key combinations work well.
Multi-step navigation: For complex layouts, use multiple focus actions in sequence to reach distant windows efficiently.