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

Scoped helper that performs virtual-screen swap and rotate operations against an injected IConfigStore. More...

#include <phosphor-screens/include/PhosphorScreens/Swapper.h>

Public Types

enum class  Result {
  Ok , NotVirtual , NoSubdivision , UnknownVirtualScreen ,
  NoSiblingInDirection , InvalidDirection , SwapFailed , SettingsRejected
}
 Structured outcome for swap/rotate operations. More...
 

Public Member Functions

 VirtualScreenSwapper (IConfigStore *store)
 
Result swapInDirection (const QString &currentVirtualScreenId, const QString &direction)
 Swap the region of currentVirtualScreenId with the adjacent sibling VS in the given direction within the same physical monitor.
 
Result rotate (const QString &physicalScreenId, bool clockwise)
 Rotate all VS regions on physicalScreenId.
 

Static Public Member Functions

static QString reasonString (Result result)
 Translate a Result to a stable string token suitable for OSD reasons and D-Bus logs.
 

Detailed Description

Scoped helper that performs virtual-screen swap and rotate operations against an injected IConfigStore.

Both operations mutate the VirtualScreenConfig for a single physical monitor. Swap exchanges the region between two sibling VSs; rotate cycles regions through all siblings on the physical monitor's spatial clockwise ring. VS IDs and every other per-VS field are preserved, so downstream state keyed on VS ID — windows, layouts, autotile state, assignment entries — remains bound and simply follows the new geometry via the host's IConfigStore::changed propagation.

Lifetime: the swapper does not own the store. Caller must keep both alive for the duration of any swap/rotate call.

Member Enumeration Documentation

◆ Result

Structured outcome for swap/rotate operations.

Lets callers distinguish "geometry changed" from each rejection reason so the OSD / D-Bus layer can emit specific failure feedback instead of a generic boolean.

Enumerator
Ok 

Mutation applied and committed via IConfigStore::save.

NotVirtual 

Caller passed a physical id where a VS id was required (or vice versa).

NoSubdivision 

The physical monitor has fewer than two virtual screens.

NOTE: deliberately conflated with "physical id not in store" — an unknown physId returns an empty config from the store which fails the same size-check and lands here. Callers that need to distinguish the two cases should cross-check existence against ScreenManager first.

UnknownVirtualScreen 

The VS id is well-formed but not present in the current config.

NoSiblingInDirection 

Swap: no sibling VS lies in the requested direction.

InvalidDirection 

Swap: direction string was empty or unrecognised.

SwapFailed 

In-memory swap/rotate step failed (duplicate ids, ids not in the working config).

Distinct from SettingsRejected because nothing was ever handed to the store — the caller's input is the problem.

SettingsRejected 

IConfigStore::save rejected the mutated config.

Constructor & Destructor Documentation

◆ VirtualScreenSwapper()

Phosphor::Screens::VirtualScreenSwapper::VirtualScreenSwapper ( IConfigStore store)
explicit

Member Function Documentation

◆ reasonString()

static QString Phosphor::Screens::VirtualScreenSwapper::reasonString ( Result  result)
static

Translate a Result to a stable string token suitable for OSD reasons and D-Bus logs.

Empty string for Ok.

◆ rotate()

Result Phosphor::Screens::VirtualScreenSwapper::rotate ( const QString &  physicalScreenId,
bool  clockwise 
)

Rotate all VS regions on physicalScreenId.

The ring order is the spatial clockwise sort of VS centres around the physical monitor's centroid; for 1D strips (all centres collinear) the helper falls back to a sort along the varying axis so the visual result matches user expectation. clockwise follows VirtualScreenConfig::rotateRegions.

◆ swapInDirection()

Result Phosphor::Screens::VirtualScreenSwapper::swapInDirection ( const QString &  currentVirtualScreenId,
const QString &  direction 
)

Swap the region of currentVirtualScreenId with the adjacent sibling VS in the given direction within the same physical monitor.

direction must match one of Direction::{Left, Right, Up, Down}.


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