Tracks tiling state for a single screen. More...
#include <phosphor-tiles/include/PhosphorTiles/TilingState.h>
Signals | |
| void | windowCountChanged () |
| Emitted when window count changes (add/remove) | |
| void | windowOrderChanged () |
| Emitted when window order changes (move/swap) | |
| void | masterCountChanged () |
| Emitted when master count changes. | |
| void | splitRatioChanged () |
| Emitted when split ratio changes. | |
| void | floatingChanged (const QString &windowId, bool floating) |
| Emitted when a window's floating state changes. | |
| void | focusedWindowChanged () |
| Emitted when focused window changes. | |
| void | stateChanged () |
| Emitted when any state change requires retiling. | |
Public Member Functions | |
| TilingState (const QString &screenId, QObject *parent=nullptr) | |
| Construct a TilingState for a specific screen. | |
| ~TilingState () override | |
| TilingState (const TilingState &)=delete | |
| TilingState & | operator= (const TilingState &)=delete |
| QString | screenId () const override |
| Get the screen ID this state belongs to. | |
| int | windowCount () const override |
| Get total number of tracked windows (including floating) | |
| int | tiledWindowCount () const override |
| Get number of tiled windows (excluding floating) | |
| QStringList | windowOrder () const |
| Get the ordered list of window IDs. | |
| QStringList | tiledWindows () const |
| Get only tiled (non-floating) windows in order. | |
| bool | addWindow (const QString &windowId, int position=-1) |
| Add a window to the tiling. | |
| bool | removeWindow (const QString &windowId) |
| Remove a window from the tiling. | |
| bool | moveWindow (int fromIndex, int toIndex) |
| Move a window to a different position. | |
| bool | swapWindows (int index1, int index2) |
| Swap two windows' positions. | |
| bool | swapWindowsById (const QString &windowId1, const QString &windowId2) |
| Swap two windows by their IDs. | |
| int | windowIndex (const QString &windowId) const |
| Get the index of a window. | |
| bool | containsWindow (const QString &windowId) const override |
| Check if a window is tracked. | |
| int | masterCount () const override |
| Get number of windows in master area. | |
| void | setMasterCount (int count) |
| Set number of windows in master area. | |
| bool | isMaster (const QString &windowId) const |
| Check if a window is in the master area. | |
| QStringList | masterWindows () const |
| Get windows currently in master area. | |
| QStringList | stackWindows () const |
| Get windows currently in stack area. | |
| bool | promoteToMaster (const QString &windowId) |
| Promote a window to master (move to position 0) | |
| bool | moveToFront (const QString &windowId) |
| Move a window to the front (alias for promoteToMaster) | |
| bool | insertAfterFocused (const QString &windowId) |
| Insert a window after the currently focused window. | |
| bool | moveToPosition (const QString &windowId, int position) |
| Move a window to a specific position by its ID. | |
| int | windowPosition (const QString &windowId) const |
| Get the position of a window (alias for windowIndex) | |
| int | tiledWindowIndex (const QString &windowId) const |
| Get the index of a window within the tiled-only list. | |
| bool | moveToTiledPosition (const QString &windowId, int tiledPosition) |
| Move a window to a specific position in the tiled-only list. | |
| bool | rotateWindows (bool clockwise=true) |
| Rotate all windows by one position. | |
| qreal | splitRatio () const |
| Get the master/stack split ratio. | |
| void | setSplitRatio (qreal ratio) |
| Set the master/stack split ratio. | |
| void | increaseSplitRatio (qreal delta=0.05) |
| Increase split ratio by delta. | |
| void | decreaseSplitRatio (qreal delta=0.05) |
| Decrease split ratio by delta. | |
| bool | isFloating (const QString &windowId) const override |
| Check if a window is floating (excluded from tiling) | |
| void | setFloating (const QString &windowId, bool floating) |
| Set a window's floating state. | |
| bool | toggleFloating (const QString &windowId) |
| Toggle a window's floating state. | |
| QStringList | floatingWindows () const override |
| Get list of floating windows. | |
| QStringList | managedWindows () const override |
| All windows managed by this state (tiled + floating). | |
| QString | placementIdForWindow (const QString &windowId) const override |
| Opaque placement identifier for the window's current slot. | |
| QString | focusedWindow () const |
| Get the currently focused window. | |
| void | setFocusedWindow (const QString &windowId) |
| Set the focused window. | |
| int | focusedTiledIndex () const |
| Get index of focused window in tiled list. | |
| QJsonObject | toJson () const override |
| Serialize state to JSON. | |
| void | clear () |
| Clear all state (remove all windows, reset to defaults) | |
| void | setCalculatedZones (const QVector< QRect > &zones) |
| Store calculated zone geometries. | |
| QVector< QRect > | calculatedZones () const |
| Get stored calculated zone geometries. | |
| SplitTree * | splitTree () const |
| Get the persistent split tree (may be null) | |
| void | setSplitTree (std::unique_ptr< SplitTree > tree) |
| Set or replace the split tree. | |
| void | clearSplitTree () |
| Clear the split tree (e.g., on algorithm switch) | |
| void | rebuildSplitTree () |
| Rebuild the split tree from the current tiled window order. | |
Public Member Functions inherited from PhosphorEngine::IPlacementState | |
| virtual | ~IPlacementState ()=default |
Static Public Member Functions | |
| static TilingState * | fromJson (const QJsonObject &json, QObject *parent=nullptr) |
| Deserialize state from JSON. | |
Tracks tiling state for a single screen.
TilingState maintains all the mutable state needed for autotiling:
This class is used by AutotileEngine to track state and by TilingAlgorithm implementations to calculate zone geometries.
Note: Window IDs are KWin's internal resource names (QString).
|
explicit |
Construct a TilingState for a specific screen.
| screenId | Unique identifier for the screen |
| parent | Parent QObject |
|
override |
|
delete |
| bool PhosphorTiles::TilingState::addWindow | ( | const QString & | windowId, |
| int | position = -1 |
||
| ) |
Add a window to the tiling.
| windowId | Window identifier |
| position | Insert position (-1 = end, 0 = beginning/master) |
| QVector< QRect > PhosphorTiles::TilingState::calculatedZones | ( | ) | const |
Get stored calculated zone geometries.
| void PhosphorTiles::TilingState::clear | ( | ) |
Clear all state (remove all windows, reset to defaults)
| void PhosphorTiles::TilingState::clearSplitTree | ( | ) |
Clear the split tree (e.g., on algorithm switch)
|
overridevirtual |
Check if a window is tracked.
Implements PhosphorEngine::IPlacementState.
| void PhosphorTiles::TilingState::decreaseSplitRatio | ( | qreal | delta = 0.05 | ) |
Decrease split ratio by delta.
| delta | Amount to decrease (default 0.05) |
|
signal |
Emitted when a window's floating state changes.
| windowId | Affected window |
| floating | New floating state |
|
overridevirtual |
Get list of floating windows.
Implements PhosphorEngine::IPlacementState.
| int PhosphorTiles::TilingState::focusedTiledIndex | ( | ) | const |
Get index of focused window in tiled list.
| QString PhosphorTiles::TilingState::focusedWindow | ( | ) | const |
Get the currently focused window.
|
signal |
Emitted when focused window changes.
|
static |
Deserialize state from JSON.
| json | Serialized state |
| parent | Parent QObject |
Ownership: caller takes ownership (Qt parent set if provided)
| void PhosphorTiles::TilingState::increaseSplitRatio | ( | qreal | delta = 0.05 | ) |
Increase split ratio by delta.
| delta | Amount to increase (default 0.05) |
| bool PhosphorTiles::TilingState::insertAfterFocused | ( | const QString & | windowId | ) |
Insert a window after the currently focused window.
| windowId | Window to insert |
|
overridevirtual |
Check if a window is floating (excluded from tiling)
Implements PhosphorEngine::IPlacementState.
| bool PhosphorTiles::TilingState::isMaster | ( | const QString & | windowId | ) | const |
Check if a window is in the master area.
|
overridevirtual |
All windows managed by this state (tiled + floating).
Implements PhosphorEngine::IPlacementState.
|
overridevirtual |
Get number of windows in master area.
Reimplemented from PhosphorEngine::IPlacementState.
|
signal |
Emitted when master count changes.
| QStringList PhosphorTiles::TilingState::masterWindows | ( | ) | const |
Get windows currently in master area.
| bool PhosphorTiles::TilingState::moveToFront | ( | const QString & | windowId | ) |
Move a window to the front (alias for promoteToMaster)
| windowId | Window to move |
| bool PhosphorTiles::TilingState::moveToPosition | ( | const QString & | windowId, |
| int | position | ||
| ) |
Move a window to a specific position by its ID.
| windowId | Window to move |
| position | Target position |
| bool PhosphorTiles::TilingState::moveToTiledPosition | ( | const QString & | windowId, |
| int | tiledPosition | ||
| ) |
Move a window to a specific position in the tiled-only list.
| windowId | Window to move |
| tiledPosition | Target position in tiled list (skipping floating) |
| bool PhosphorTiles::TilingState::moveWindow | ( | int | fromIndex, |
| int | toIndex | ||
| ) |
Move a window to a different position.
| fromIndex | Current position |
| toIndex | Target position |
|
delete |
|
overridevirtual |
Opaque placement identifier for the window's current slot.
Snap mode: zone UUID. Autotile mode: tiling-order index as string. Empty if the window is floating or unassigned.
Implements PhosphorEngine::IPlacementState.
| bool PhosphorTiles::TilingState::promoteToMaster | ( | const QString & | windowId | ) |
Promote a window to master (move to position 0)
| windowId | Window to promote |
| void PhosphorTiles::TilingState::rebuildSplitTree | ( | ) |
Rebuild the split tree from the current tiled window order.
Used after operations that reorder windows (move, promote, rotate) to preserve the tree's existence while matching the new order. Split ratios are preserved positionally where possible, so DwindleMemoryAlgorithm doesn't fall back to stateless mode.
| bool PhosphorTiles::TilingState::removeWindow | ( | const QString & | windowId | ) |
Remove a window from the tiling.
| windowId | Window to remove |
| bool PhosphorTiles::TilingState::rotateWindows | ( | bool | clockwise = true | ) |
Rotate all windows by one position.
Clockwise: each window moves to the next position, last becomes first Counterclockwise: each window moves to the previous position, first becomes last
| clockwise | Direction of rotation |
|
overridevirtual |
Get the screen ID this state belongs to.
Implements PhosphorEngine::IPlacementState.
| void PhosphorTiles::TilingState::setCalculatedZones | ( | const QVector< QRect > & | zones | ) |
Store calculated zone geometries.
Called by AutotileEngine after algorithm computes zones. Stored for later application to windows.
| zones | Calculated zone geometries (one per tiled window) |
| void PhosphorTiles::TilingState::setFloating | ( | const QString & | windowId, |
| bool | floating | ||
| ) |
Set a window's floating state.
| windowId | Window to modify |
| floating | true to exclude from tiling |
| void PhosphorTiles::TilingState::setFocusedWindow | ( | const QString & | windowId | ) |
Set the focused window.
| windowId | Window that received focus |
| void PhosphorTiles::TilingState::setMasterCount | ( | int | count | ) |
Set number of windows in master area.
| count | New master count (clamped to 1..windowCount) |
| void PhosphorTiles::TilingState::setSplitRatio | ( | qreal | ratio | ) |
Set the master/stack split ratio.
| ratio | New ratio (clamped to 0.1..0.9) |
| void PhosphorTiles::TilingState::setSplitTree | ( | std::unique_ptr< SplitTree > | tree | ) |
Set or replace the split tree.
| tree | Ownership transferred to TilingState |
| qreal PhosphorTiles::TilingState::splitRatio | ( | ) | const |
Get the master/stack split ratio.
|
signal |
Emitted when split ratio changes.
| SplitTree * PhosphorTiles::TilingState::splitTree | ( | ) | const |
Get the persistent split tree (may be null)
Used by DwindleMemoryAlgorithm to read the tree structure. Returns nullptr if no split tree has been created for this state.
| QStringList PhosphorTiles::TilingState::stackWindows | ( | ) | const |
Get windows currently in stack area.
|
signal |
Emitted when any state change requires retiling.
| bool PhosphorTiles::TilingState::swapWindows | ( | int | index1, |
| int | index2 | ||
| ) |
Swap two windows' positions.
| index1 | First window position |
| index2 | Second window position |
| bool PhosphorTiles::TilingState::swapWindowsById | ( | const QString & | windowId1, |
| const QString & | windowId2 | ||
| ) |
Swap two windows by their IDs.
| windowId1 | First window ID |
| windowId2 | Second window ID |
|
overridevirtual |
Get number of tiled windows (excluding floating)
Reimplemented from PhosphorEngine::IPlacementState.
| int PhosphorTiles::TilingState::tiledWindowIndex | ( | const QString & | windowId | ) | const |
Get the index of a window within the tiled-only list.
| windowId | Window to find |
| QStringList PhosphorTiles::TilingState::tiledWindows | ( | ) | const |
Get only tiled (non-floating) windows in order.
| bool PhosphorTiles::TilingState::toggleFloating | ( | const QString & | windowId | ) |
Toggle a window's floating state.
| windowId | Window to toggle |
|
overridevirtual |
Serialize state to JSON.
Implements PhosphorEngine::IPlacementState.
|
overridevirtual |
Get total number of tracked windows (including floating)
Implements PhosphorEngine::IPlacementState.
|
signal |
Emitted when window count changes (add/remove)
| int PhosphorTiles::TilingState::windowIndex | ( | const QString & | windowId | ) | const |
Get the index of a window.
| windowId | Window to find |
| QStringList PhosphorTiles::TilingState::windowOrder | ( | ) | const |
Get the ordered list of window IDs.
|
signal |
Emitted when window order changes (move/swap)
| int PhosphorTiles::TilingState::windowPosition | ( | const QString & | windowId | ) | const |
Get the position of a window (alias for windowIndex)
| windowId | Window to find |