Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorTileEngine::NavigationController Class Reference

Handles navigation, focus cycling, and ratio/count adjustments. More...

#include <phosphor-tile-engine/include/PhosphorTileEngine/NavigationController.h>

Public Member Functions

 NavigationController (AutotileEngine *engine)
 
void focusNext ()
 
void focusPrevious ()
 
void focusMaster ()
 
void swapFocusedWithMaster ()
 
void rotateWindowOrder (bool clockwise)
 
void swapFocusedInDirection (const QString &direction, const QString &action, const QString &explicitWindowId=QString())
 explicitWindowId (when non-empty) overrides the state's internal focusedWindow() for the operation.
 
void focusInDirection (const QString &direction, const QString &action, const QString &explicitWindowId=QString())
 
void moveFocusedToPosition (int position, const QString &explicitWindowId=QString())
 
void increaseMasterRatio (qreal delta)
 
void decreaseMasterRatio (qreal delta)
 
void setGlobalSplitRatio (qreal ratio)
 
void setGlobalMasterCount (int count)
 
void adjustMasterCount (int delta)
 
QString entryWindowOnScreen (const QString &screenId, const QString &direction) const
 The tiled window at screenId's entry edge facing the source when a crossing arrives in direction (crossing "right" enters the target's LEFT edge → the leftmost tile, etc.).
 
int windowOrderIndexOnScreen (const QString &screenId, const QString &windowId) const
 The RAW window-order index of windowId on screenId's current state (counting floating windows, as TilingState::addWindow does), or -1 when not present.
 
QStringList tiledWindowsForFocusedScreen (QString &outScreenId, PhosphorTiles::TilingState *&outState, const QString &explicitWindowId=QString(), bool requireTiledWindows=true)
 Resolve the screen a navigation operation should act on, with its state and tiled-window list.
 

Detailed Description

Handles navigation, focus cycling, and ratio/count adjustments.

NavigationController is a stateless helper extracted from AutotileEngine. It manages keyboard-driven navigation (focus next/previous/master), window swapping, rotation, directional focus/swap, position moves, and master ratio/count adjustments.

Stateless — no member data moves from AutotileEngine. All state is accessed via the back-pointer to AutotileEngine.

See also
AutotileEngine for the owning engine

Constructor & Destructor Documentation

◆ NavigationController()

PhosphorTileEngine::NavigationController::NavigationController ( AutotileEngine engine)
explicit

Member Function Documentation

◆ adjustMasterCount()

void PhosphorTileEngine::NavigationController::adjustMasterCount ( int  delta)

◆ decreaseMasterRatio()

void PhosphorTileEngine::NavigationController::decreaseMasterRatio ( qreal  delta)

◆ entryWindowOnScreen()

QString PhosphorTileEngine::NavigationController::entryWindowOnScreen ( const QString &  screenId,
const QString &  direction 
) const

The tiled window at screenId's entry edge facing the source when a crossing arrives in direction (crossing "right" enters the target's LEFT edge → the leftmost tile, etc.).

Empty when the screen has no tiling state or no tiled windows. Used by the daemon to pick the cross-mode swap partner on an autotile target.

Note
When geometry isn't computed yet OR the screen is over its maxWindows cap (calculatedZones covers only the capped subset, so it can't align 1:1 with tiledWindows), this degrades to the first tiled window (the master) rather than the geometric edge tile.

◆ focusInDirection()

void PhosphorTileEngine::NavigationController::focusInDirection ( const QString &  direction,
const QString &  action,
const QString &  explicitWindowId = QString() 
)

◆ focusMaster()

void PhosphorTileEngine::NavigationController::focusMaster ( )

◆ focusNext()

void PhosphorTileEngine::NavigationController::focusNext ( )

◆ focusPrevious()

void PhosphorTileEngine::NavigationController::focusPrevious ( )

◆ increaseMasterRatio()

void PhosphorTileEngine::NavigationController::increaseMasterRatio ( qreal  delta)

◆ moveFocusedToPosition()

void PhosphorTileEngine::NavigationController::moveFocusedToPosition ( int  position,
const QString &  explicitWindowId = QString() 
)

◆ rotateWindowOrder()

void PhosphorTileEngine::NavigationController::rotateWindowOrder ( bool  clockwise)

◆ setGlobalMasterCount()

void PhosphorTileEngine::NavigationController::setGlobalMasterCount ( int  count)

◆ setGlobalSplitRatio()

void PhosphorTileEngine::NavigationController::setGlobalSplitRatio ( qreal  ratio)

◆ swapFocusedInDirection()

void PhosphorTileEngine::NavigationController::swapFocusedInDirection ( const QString &  direction,
const QString &  action,
const QString &  explicitWindowId = QString() 
)

explicitWindowId (when non-empty) overrides the state's internal focusedWindow() for the operation.

The IPlacementEngine virtual-method overrides on AutotileEngine pass the CANONICALIZED ctx.windowId (canonicalizeForLookup) here so navigation follows the daemon's authoritative focus tracking even when the engine's per-state focusedWindow tracker is stale. The canonicalization is load-bearing: the lookups below match this id against the ids the tiling states hold, so a raw ctx.windowId in a non-canonical form would find no state and silently fall through to the focused-screen path.

◆ swapFocusedWithMaster()

void PhosphorTileEngine::NavigationController::swapFocusedWithMaster ( )

◆ tiledWindowsForFocusedScreen()

QStringList PhosphorTileEngine::NavigationController::tiledWindowsForFocusedScreen ( QString &  outScreenId,
PhosphorTiles::TilingState *&  outState,
const QString &  explicitWindowId = QString(),
bool  requireTiledWindows = true 
)

Resolve the screen a navigation operation should act on, with its state and tiled-window list.

Three tiers, all on the current desktop/activity:

  1. explicitWindowId — locate the state containing that window. The daemon may know the true focused window even when the engine's per-state focusedWindow() tracker is stale. This tier alone is NOT gated on autotile mode: a state that still holds the window is authoritative about where that window lives, and refusing it would silently retarget the operation at a different monitor during the window between a mode switch and the state teardown that follows.
  2. The active-screen hint (onWindowFocused, and the daemon's setActiveScreenHint on every autotile shortcut), accepted whenever that screen HAS tiled windows. Deliberately NOT gated on a tracked focusedWindow(): focus can sit on a floating, snapped, or never-tracked window there, and requiring one sent every screen-scoped operation to tier 3 and onto the wrong monitor.
  3. A scan of the remaining states, preferring one that also holds the focus, then the primary screen. Runners-up are ranked (hint, primary, lowest screenId) rather than taken in QHash order, so a mutation cannot land on an arbitrary monitor run to run. Tiers 2 and 3 and the primary-screen fallback are restricted to autotile screens.

requireTiledWindows selects what tiers 2 and 3 accept. The default, true, wants a screen with a layout to operate on. Pass false when the caller wants "the screen holding the focus" even if everything on it is floating — toggling a floating window back into the layout is exactly that case, and it would otherwise resolve a different monitor.

outScreenId is always set to a usable output when one exists, even on a total miss, because callers emit navigationFeedback on failure and the OSD needs somewhere to appear.

The name is historical — resolution is hint-first and gated on tiled windows, not on focus. Consumers that genuinely need a focused window (swap-with-master, directional swap) check state->focusedWindow() themselves and report no_focus.

◆ windowOrderIndexOnScreen()

int PhosphorTileEngine::NavigationController::windowOrderIndexOnScreen ( const QString &  screenId,
const QString &  windowId 
) const

The RAW window-order index of windowId on screenId's current state (counting floating windows, as TilingState::addWindow does), or -1 when not present.

Lets the daemon capture a window's slot before a cross-mode swap so its counterpart lands in the same place when re-inserted via HandoffContext.insertIndex.


The documentation for this class was generated from the following file: