8#include <phosphortiles_export.h>
43 Q_PROPERTY(QString screenId READ screenId CONSTANT)
44 Q_PROPERTY(
int windowCount READ windowCount NOTIFY windowCountChanged)
45 Q_PROPERTY(
int tiledWindowCount READ tiledWindowCount NOTIFY windowCountChanged)
46 Q_PROPERTY(
int masterCount READ masterCount WRITE setMasterCount NOTIFY masterCountChanged)
47 Q_PROPERTY(qreal splitRatio READ splitRatio WRITE setSplitRatio NOTIFY splitRatioChanged)
55 explicit TilingState(
const QString& screenId, QObject* parent =
nullptr);
98 bool addWindow(
const QString& windowId,
int position = -1);
439 QStringList m_windowOrder;
440 QSet<QString> m_floatingWindows;
441 QString m_focusedWindow;
442 int m_masterCount = AutotileDefaults::DefaultMasterCount;
443 qreal m_splitRatio = AutotileDefaults::DefaultSplitRatio;
444 QVector<QRect> m_calculatedZones;
445 std::unique_ptr<SplitTree> m_splitTree;
448 void notifyStateChanged();
455 void forEachTiledWindow(
const std::function<
bool(
const QString& windowId,
int tiledIndex)>& func)
const;
458 static int clampMasterCount(
int value);
459 static qreal clampSplitRatio(qreal value);
462 void syncTreeInsert(
const QString& windowId,
int position = -1);
463 void syncTreeRemove(
const QString& windowId);
464 void syncTreeSwap(
const QString& idA,
const QString& idB);
465 void syncTreeLazyCreate();
Algorithm-layer constants for the autotile/tile primitives.
Per-screen placement state contract.
Definition IPlacementState.h:26
A binary split tree for interactive window tiling.
Definition SplitTree.h:58
Tracks tiling state for a single screen.
Definition TilingState.h:40
TilingState & operator=(const TilingState &)=delete
bool moveToFront(const QString &windowId)
Move a window to the front (alias for promoteToMaster)
void clear()
Clear all state (remove all windows, reset to defaults)
void setMasterCount(int count)
Set number of windows in master area.
void setSplitRatio(qreal ratio)
Set the master/stack split ratio.
void windowOrderChanged()
Emitted when window order changes (move/swap)
QStringList stackWindows() const
Get windows currently in stack area.
bool isMaster(const QString &windowId) const
Check if a window is in the master area.
bool rotateWindows(bool clockwise=true)
Rotate all windows by one position.
bool insertAfterFocused(const QString &windowId)
Insert a window after the currently focused window.
void setSplitTree(std::unique_ptr< SplitTree > tree)
Set or replace the split tree.
int tiledWindowCount() const override
Get number of tiled windows (excluding floating)
bool isFloating(const QString &windowId) const override
Check if a window is floating (excluded from tiling)
QStringList windowOrder() const
Get the ordered list of window IDs.
QStringList floatingWindows() const override
Get list of floating windows.
void setFloating(const QString &windowId, bool floating)
Set a window's floating state.
TilingState(const TilingState &)=delete
QStringList masterWindows() const
Get windows currently in master area.
void setCalculatedZones(const QVector< QRect > &zones)
Store calculated zone geometries.
QString screenId() const override
Get the screen ID this state belongs to.
QVector< QRect > calculatedZones() const
Get stored calculated zone geometries.
int windowCount() const override
Get total number of tracked windows (including floating)
TilingState(const QString &screenId, QObject *parent=nullptr)
Construct a TilingState for a specific screen.
int windowPosition(const QString &windowId) const
Get the position of a window (alias for windowIndex)
QStringList tiledWindows() const
Get only tiled (non-floating) windows in order.
int masterCount() const override
Get number of windows in master area.
QJsonObject toJson() const override
Serialize state to JSON.
bool removeWindow(const QString &windowId)
Remove a window from the tiling.
bool promoteToMaster(const QString &windowId)
Promote a window to master (move to position 0)
void decreaseSplitRatio(qreal delta=0.05)
Decrease split ratio by delta.
int tiledWindowIndex(const QString &windowId) const
Get the index of a window within the tiled-only list.
void setFocusedWindow(const QString &windowId)
Set the focused window.
void stateChanged()
Emitted when any state change requires retiling.
bool toggleFloating(const QString &windowId)
Toggle a window's floating state.
void rebuildSplitTree()
Rebuild the split tree from the current tiled window order.
bool moveToTiledPosition(const QString &windowId, int tiledPosition)
Move a window to a specific position in the tiled-only list.
void increaseSplitRatio(qreal delta=0.05)
Increase split ratio by delta.
bool swapWindows(int index1, int index2)
Swap two windows' positions.
bool swapWindowsById(const QString &windowId1, const QString &windowId2)
Swap two windows by their IDs.
void clearSplitTree()
Clear the split tree (e.g., on algorithm switch)
int windowIndex(const QString &windowId) const
Get the index of a window.
bool moveWindow(int fromIndex, int toIndex)
Move a window to a different position.
bool addWindow(const QString &windowId, int position=-1)
Add a window to the tiling.
QString focusedWindow() const
Get the currently focused window.
void splitRatioChanged()
Emitted when split ratio changes.
void masterCountChanged()
Emitted when master count changes.
void windowCountChanged()
Emitted when window count changes (add/remove)
SplitTree * splitTree() const
Get the persistent split tree (may be null)
bool moveToPosition(const QString &windowId, int position)
Move a window to a specific position by its ID.
static TilingState * fromJson(const QJsonObject &json, QObject *parent=nullptr)
Deserialize state from JSON.
void focusedWindowChanged()
Emitted when focused window changes.
void floatingChanged(const QString &windowId, bool floating)
Emitted when a window's floating state changes.
QString placementIdForWindow(const QString &windowId) const override
Opaque placement identifier for the window's current slot.
qreal splitRatio() const
Get the master/stack split ratio.
QStringList managedWindows() const override
All windows managed by this state (tiled + floating).
int focusedTiledIndex() const
Get index of focused window in tiled list.
bool containsWindow(const QString &windowId) const override
Check if a window is tracked.
Definition AutotileEngine.h:71