Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
TilingParams.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <phosphortiles_export.h>
7
8// EdgeGaps is the per-side gap shape shared between manual layout and tiling;
9// it lives in libs/phosphor-layout-api so neither side has to depend on the
10// other's headers.
12
13#include <QRect>
14#include <QSize>
15#include <QString>
16#include <QVariantMap>
17#include <QVector>
18
19#include <functional>
20
21namespace PhosphorTiles {
22
23// Shorthand for the shared shape — re-declared here (rather than relying on a
24// transitive include of core/constants.h) so this header is self-contained.
26
27class TilingState;
28
36{
37 QString appId;
38 bool focused = false;
39 QString windowId;
40};
41
51{
52 int index = -1;
53 QRect oldRect;
54 QRect newRect;
55 // At most one edge per axis is ever set: left XOR right, top XOR bottom.
56 // Both edges of an axis moving together is a translation (move), not a
57 // resize, and reports neither. Hooks may rely on this mutual exclusion.
58 bool left = false;
59 bool right = false;
60 bool top = false;
61 bool bottom = false;
62};
63
71{
72 QString id;
73 bool portrait = false;
74 qreal aspectRatio = 0.0;
75};
76
84{
85 int windowCount = 0;
90 const TilingState* state = nullptr;
91 int innerGap = 0;
93 QVector<QSize> minSizes = {};
94
95 // ── Enriched context (v2) ──────────────────────────────────────────
96 QVector<WindowInfo> windowInfos;
97 int focusedIndex = -1;
99 QVariantMap customParams;
100
108 QVector<QRect> currentGeometries;
109
111 static TilingParams forPreview(int count, const QRect& rect, const TilingState* state)
112 {
113 TilingParams p;
114 p.windowCount = count;
115 p.screenGeometry = rect;
116 p.state = state;
117 return p;
118 }
119};
120
142PHOSPHORTILES_EXPORT QVector<WindowInfo> buildWindowInfos(const TilingState* state, int windowCount,
143 const std::function<QString(const QString&)>& appIdResolver,
144 int& focusedIndex);
145
146} // namespace PhosphorTiles
Tracks tiling state for a single screen.
Definition TilingState.h:40
Definition AutotileEngine.h:46
PHOSPHORTILES_EXPORT QVector< WindowInfo > buildWindowInfos(const TilingState *state, int windowCount, const std::function< QString(const QString &)> &appIdResolver, int &focusedIndex)
Build per-window metadata from a TilingState.
Per-side edge gap values (resolved, non-negative pixel values)
Definition EdgeGaps.h:27
Describes an interactive resize that triggered a retile.
Definition TilingParams.h:51
bool left
Left edge moved beyond the threshold (and right did not)
Definition TilingParams.h:58
bool right
Right edge moved (and left did not)
Definition TilingParams.h:59
QRect oldRect
Window frame before the resize (drag baseline)
Definition TilingParams.h:53
QRect newRect
Window frame after the resize.
Definition TilingParams.h:54
bool bottom
Bottom edge moved (and top did not)
Definition TilingParams.h:61
int index
0-based tiled index of the resized window (parallel to windowInfos)
Definition TilingParams.h:52
bool top
Top edge moved (and bottom did not)
Definition TilingParams.h:60
Parameters for zone calculation.
Definition TilingParams.h:84
int windowCount
Number of windows to tile.
Definition TilingParams.h:85
const TilingState * state
Current tiling state.
Definition TilingParams.h:90
QVector< QSize > minSizes
Per-window minimum sizes (may be empty)
Definition TilingParams.h:93
EdgeGaps outerGaps
Gaps at screen edges in pixels (per-side)
Definition TilingParams.h:92
QVector< WindowInfo > windowInfos
Per-window metadata (parallel to window list)
Definition TilingParams.h:96
int focusedIndex
Index of focused window in tiled list (-1 = unknown)
Definition TilingParams.h:97
TilingScreenInfo screenInfo
Physical screen metadata.
Definition TilingParams.h:98
static TilingParams forPreview(int count, const QRect &rect, const TilingState *state)
Create minimal params for preview rendering (no per-window/screen context)
Definition TilingParams.h:111
QVariantMap customParams
Algorithm-declared custom parameters.
Definition TilingParams.h:99
int innerGap
Gap between adjacent zones in pixels.
Definition TilingParams.h:91
QRect screenGeometry
Available screen area in absolute pixels.
Definition TilingParams.h:86
QVector< QRect > currentGeometries
Last applied zones (parallel to the window list), exposed to scripts as ctx.currentGeometries.
Definition TilingParams.h:108
Screen metadata passed to tiling algorithms.
Definition TilingParams.h:71
QString id
Screen connector name (e.g., "HDMI-1", "DP-2")
Definition TilingParams.h:72
bool portrait
True if height > width (portrait orientation)
Definition TilingParams.h:73
qreal aspectRatio
width/height (e.g., 1.78 for 16:9, 0.56 for portrait)
Definition TilingParams.h:74
Per-window metadata passed to algorithms.
Definition TilingParams.h:36
QString appId
Application identifier (e.g., "firefox", "org.kde.dolphin")
Definition TilingParams.h:37
bool focused
Whether this window currently has focus.
Definition TilingParams.h:38
QString windowId
Opaque instance id (stable across retiles; lets scripts key persistent state)
Definition TilingParams.h:39