9#include "phosphorzones_export.h"
41class PHOSPHORZONES_EXPORT
Layout :
public QObject
45 Q_PROPERTY(QUuid
id READ
id CONSTANT)
93 explicit Layout(QObject* parent =
nullptr);
94 explicit Layout(
const QString&
name, QObject* parent =
nullptr);
133 return m_description;
140 return m_zonePadding;
145 return m_zonePadding >= 0;
156 return m_outerGap >= 0;
163 return m_usePerSideOuterGap;
168 return m_outerGapTop;
173 return m_outerGapBottom;
178 return m_outerGapLeft;
183 return m_outerGapRight;
188 return m_usePerSideOuterGap
189 && (m_outerGapTop >= 0 || m_outerGapBottom >= 0 || m_outerGapLeft >= 0 || m_outerGapRight >= 0);
198 return {m_outerGapTop, m_outerGapBottom, m_outerGapLeft, m_outerGapRight};
203 return m_showZoneNumbers;
209 return m_overlayDisplayMode;
214 return m_overlayDisplayMode >= 0;
233 return m_systemSourcePath;
237 m_systemSourcePath = path;
241 return !m_systemSourcePath.isEmpty();
247 return m_aspectRatioClass;
252 return static_cast<int>(m_aspectRatioClass);
257 return m_minAspectRatio;
262 return m_maxAspectRatio;
276 return m_hiddenFromSelector;
281 return m_allowedScreens;
286 return m_allowedDesktops;
291 return m_allowedActivities;
305 return m_useFullScreenGeometry;
317 return m_fixedGeometryInDevicePixels;
333 return (m_fixedGeometryInDevicePixels && screenScale > 0.0) ? screenScale : 1.0;
367 return m_defaultOrder;
371 m_defaultOrder = order;
377 return m_zones.size();
396 Q_INVOKABLE
void moveZone(
int fromIndex,
int toIndex);
402 Q_INVOKABLE QVector<Zone*>
adjacentZones(
const QPointF& point, qreal threshold = 20)
const;
408 return m_lastRecalcGeometry;
413 m_lastRecalcGeometry = geom;
414 if (screenScale > 0.0) {
415 m_lastRecalcScale = screenScale;
433 bool needsRecalc(
const QRectF& screenGeometry, qreal screenScale = 0.0)
const
435 return screenGeometry != m_lastRecalcGeometry || m_zoneGeometryDirty
448 return m_lastRecalcScale;
458 return m_zoneGeometryEpoch;
466 return m_syncRecalcEpoch;
476 m_lastRecalcGeometry = geom;
477 m_zoneGeometryDirty =
false;
478 if (screenScale > 0.0) {
479 m_lastRecalcScale = screenScale;
569 void emitModifiedIfNotBatched();
573 void markZoneGeometryDirty()
575 m_zoneGeometryDirty =
true;
576 ++m_zoneGeometryEpoch;
585 void initFromJson(
const QJsonObject& json);
589 QString m_description;
590 int m_zonePadding = -1;
592 bool m_usePerSideOuterGap =
false;
593 int m_outerGapTop = -1;
594 int m_outerGapBottom = -1;
595 int m_outerGapLeft = -1;
596 int m_outerGapRight = -1;
597 bool m_showZoneNumbers =
true;
598 int m_overlayDisplayMode = -1;
599 QString m_sourcePath;
600 QString m_systemSourcePath;
601 int m_defaultOrder = DefaultOrderUnset;
602 QVector<Zone*> m_zones;
605 bool m_autoAssign =
false;
608 bool m_useFullScreenGeometry =
false;
612 qreal m_minAspectRatio = 0.0;
613 qreal m_maxAspectRatio = 0.0;
616 bool m_hiddenFromSelector =
false;
617 QStringList m_allowedScreens;
618 QList<int> m_allowedDesktops;
619 QStringList m_allowedActivities;
624 QRectF m_lastRecalcGeometry;
635 bool m_zoneGeometryDirty =
false;
640 bool m_isSystemLayout =
false;
643 bool m_dirty =
false;
644 int m_batchModifyDepth = 0;
647 bool m_fixedGeometryInDevicePixels =
false;
651 qreal m_lastRecalcScale = 1.0;
654 quint64 m_zoneGeometryEpoch = 0;
655 quint64 m_syncRecalcEpoch = 0;
660 bool m_batchModified =
false;
bool hasOuterGapOverride() const
Definition Layout.h:154
bool needsRecalc(const QRectF &screenGeometry, qreal screenScale=0.0) const
The complete staleness predicate recalculateZoneGeometries() gates on: the screen rect changed OR the...
Definition Layout.h:433
int overlayDisplayMode() const
Definition Layout.h:207
qreal lastRecalcScale() const
The newest output scale a recalculation was asked for (1.0 until a scale is known).
Definition Layout.h:446
Zone * nearestZone(const QPointF &point, qreal maxDistance=-1) const
int zonePadding() const
Definition Layout.h:138
void markRecalculated(const QRectF &geom, qreal screenScale=0.0)
Full-recalc bookkeeping for external appliers (the async worker path): stamps the rect AND clears the...
Definition Layout.h:474
QList< int > allowedDesktops() const
Definition Layout.h:284
int outerGapLeft() const
Definition Layout.h:176
::PhosphorLayout::EdgeGaps rawOuterGaps() const
Raw per-side gap overrides.
Definition Layout.h:196
bool usePerSideOuterGap() const
Definition Layout.h:161
bool isSystemLayout() const
bool isDirty() const
Definition Layout.h:516
void moveZone(int fromIndex, int toIndex)
Zone * zoneById(const QUuid &id) const
void setSourcePath(const QString &path)
void setAllowedActivities(const QStringList &activities)
qreal fixedGeometryDivisor(qreal screenScale) const
What a fixed geometry is divided by on an output whose logical scale is screenScale: that scale when ...
Definition Layout.h:331
QString systemSourcePath() const
Definition Layout.h:231
int defaultOrder() const
Definition Layout.h:365
void zoneRemoved(Zone *zone)
static Layout * createPriorityGridLayout(QObject *parent=nullptr)
int outerGapTop() const
Definition Layout.h:166
void allowedScreensChanged()
void aspectRatioClassChanged()
void setDefaultOrder(int order)
Definition Layout.h:369
bool hasFixedGeometryZones() const
Returns true if any zone uses fixed (pixel) geometry mode.
void setAspectRatioClass(::PhosphorLayout::AspectRatioClass cls)
void setOuterGapTop(int gap)
void clearOuterGapOverride()
void setUseFullScreenGeometry(bool enabled)
void setHiddenFromSelector(bool hidden)
qreal maxAspectRatio() const
Definition Layout.h:260
QRectF fixedZoneBoundingBox() const
Bounding box of all fixed-geometry zones, anchored at (0, 0), in the LOGICAL units of the last recalc...
void markDirty()
Definition Layout.h:520
void overlayDisplayModeChanged()
QRectF fixedZoneReferenceGeometry() const
Reference geometry suitable for normalizing fixed-pixel zones to 0–1 relative coordinates.
void setOuterGap(int gap)
bool matchesAspectRatio(qreal screenAspectRatio) const
Check if this layout is suitable for a screen with the given aspect ratio.
void setUsePerSideOuterGap(bool enabled)
bool hasZonePaddingOverride() const
Definition Layout.h:143
Layout(const QString &name, QObject *parent=nullptr)
void setZonePadding(int padding)
QString sourcePath() const
Definition Layout.h:219
void setAutoAssign(bool enabled)
void setLastRecalcGeometry(const QRectF &geom, qreal screenScale=0.0)
Stamps the rect, and a positive screenScale as the scale with it.
Definition Layout.h:411
Layout(const Layout &)=delete
QVector< Zone * > adjacentZones(const QPointF &point, qreal threshold=20) const
bool hasSystemOrigin() const
Definition Layout.h:239
static void setScreenIdResolver(ScreenIdResolver resolver)
int zoneCount() const
Definition Layout.h:375
QJsonObject toJson() const
Zone * zoneByNumber(int number) const
void hiddenFromSelectorChanged()
bool hasPerSideOuterGapOverride() const
Definition Layout.h:186
bool hasOverlayDisplayModeOverride() const
Definition Layout.h:212
void fixedGeometryInDevicePixelsChanged()
Zone * zone(int index) const
std::function< QString(const QString &)> ScreenIdResolver
Screen-id resolver.
Definition Layout.h:499
QStringList allowedActivities() const
Definition Layout.h:289
void setOverlayDisplayMode(int mode)
int outerGapRight() const
Definition Layout.h:181
quint64 syncRecalcEpoch() const
Bumped by every recalculateZoneGeometries() call, including one that finds nothing to recompute,...
Definition Layout.h:464
int outerGap() const
Definition Layout.h:149
static Layout * createGridLayout(int columns, int rows, QObject *parent=nullptr)
QVector< Zone * > zonesInRect(const QRectF &rect) const
static Layout * createFocusLayout(QObject *parent=nullptr)
Layout(QObject *parent=nullptr)
bool useFullScreenGeometry() const
Definition Layout.h:303
void setDescription(const QString &description)
void setFixedGeometryInDevicePixels(bool enabled)
bool hiddenFromSelector() const
Definition Layout.h:274
::PhosphorLayout::AspectRatioClass aspectRatioClass() const
Definition Layout.h:245
void setMinAspectRatio(qreal ratio)
Layout & operator=(const Layout &)=delete
QRectF lastRecalcGeometry() const
Definition Layout.h:406
void setSystemSourcePath(const QString &path)
Definition Layout.h:235
Zone * zoneAtPoint(const QPointF &point) const
QStringList allowedScreens() const
Definition Layout.h:279
bool showZoneNumbers() const
Definition Layout.h:201
void setAspectRatioClassInt(int cls)
void allowedDesktopsChanged()
void removeZone(Zone *zone)
void showZoneNumbersChanged()
void setAllowedScreens(const QStringList &screens)
Zone * zoneByName(const QString &name) const
First zone (in zone-number order) whose name equals name after trimming, compared case-insensitively.
static constexpr int DefaultOrderUnset
Sentinel for "no explicit default order set" on defaultOrder.
Definition Layout.h:362
bool fixedGeometryInDevicePixels() const
Whether this layout's fixed-geometry zones count DEVICE pixels.
Definition Layout.h:315
static ScreenIdResolver screenIdResolver()
Returns a copy of the currently-installed resolver (empty if none).
void allowedActivitiesChanged()
void recalculateZoneGeometries(const QRectF &screenGeometry, qreal screenScale=0.0)
Recalculate every zone's absolute geometry against screenGeometry.
void setName(const QString &name)
void setOuterGapRight(int gap)
void clearOverlayDisplayModeOverride()
void setOuterGapBottom(int gap)
void setOuterGapLeft(int gap)
quint64 zoneGeometryEpoch() const
Bumped when the zone set changes (a zone added, removed or replaced) or the fixed-geometry unit flips...
Definition Layout.h:456
void clearZonePaddingOverride()
void removeZoneAt(int index)
QString name() const
Definition Layout.h:125
QUuid id() const
Definition Layout.h:121
Layout * clone(QObject *parent=nullptr) const
Deep-copy this layout into a new, independently owned Layout.
void setMaxAspectRatio(qreal ratio)
void zonePaddingChanged()
QString description() const
Definition Layout.h:131
qreal minAspectRatio() const
Definition Layout.h:255
void useFullScreenGeometryChanged()
void setAllowedDesktops(const QList< int > &desktops)
static Layout * fromJson(const QJsonObject &json, QObject *parent=nullptr)
static Layout * createRowsLayout(int rows, QObject *parent=nullptr)
QVector< Zone * > zones() const
Definition Layout.h:379
int outerGapBottom() const
Definition Layout.h:171
bool autoAssign() const
Definition Layout.h:296
void descriptionChanged()
void zoneAdded(Zone *zone)
void setShowZoneNumbers(bool show)
int aspectRatioClassInt() const
Definition Layout.h:250
static Layout * createColumnsLayout(int columns, QObject *parent=nullptr)
void clearDirty()
Definition Layout.h:524
Represents a single zone within a layout.
Definition Zone.h:47
AspectRatioClass
Screen aspect-ratio classification.
Definition AspectRatioClass.h:22
@ Any
Suitable for all aspect ratios (default).
Definition AspectRatioClass.h:23
Definition IWindowTrackingService.h:24
LayoutCategory
Category for layout type.
Definition Layout.h:28
@ Autotile
Dynamic auto-tiling algorithm.
Definition Layout.h:30
@ Manual
Traditional zone-based layout.
Definition Layout.h:29
Per-side edge gap values (resolved, non-negative pixel values).
Definition EdgeGaps.h:27