Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
ScreenInfo.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3#pragma once
4
5// ScreenInfo — POD descriptor + QML-friendly serialiser.
6//
7// QML payload shape:
8// QML consumers binding individual keys via QVariantMap should be aware
9// that the variant map produced by screenInfoListToVariantList() emits
10// `width`, `height`, `resolution`, `x`, `y`, and `isVirtualScreen` with
11// the semantics documented in libs/phosphor-screens/CHANGES.md. In
12// particular, `isVirtualScreen` is ALWAYS present (was: only when
13// true); QML that uses `Object.keys(map).includes('isVirtualScreen')`
14// to disambiguate physical-vs-virtual must be audited. See the
15// screenInfoListToVariantList() docstring below for the full key list.
16//
17// Sentinel convention for width/height/virtualIndex (NOT x/y — see below):
18// - `width` / `height` use `0` (not -1) as "unknown / not yet reported".
19// The producer is expected to fill positive values when geometry is
20// known. `screenInfoListToVariantList()` skips emitting a dimension
21// when it's non-positive so a `0×0` tile doesn't render in pickers.
22// - `x` / `y` (screen-space position) have NO sentinel: 0 is a valid
23// origin and negatives are normal, so they are emitted unconditionally.
24// - `virtualIndex` uses `-1` as "not a virtual screen". `isVirtualScreen`
25// must be true and `virtualIndex >= 0` for a meaningful virtual id;
26// the serialiser warns when this invariant is violated.
27// Flipping these to negative-sentinel form would be API-breaking for
28// downstream producers, so the existing convention is locked in.
29
30#include <QList>
31#include <QString>
32#include <QVariantList>
33
34#include "phosphorscreenscore_export.h"
35
36namespace PhosphorScreens {
37
47struct PHOSPHORSCREENSCORE_EXPORT ScreenInfo
48{
49 QString name;
50 bool isPrimary = false;
51 QString manufacturer;
52 QString model;
53 int width = 0;
54 int height = 0;
63 int x = 0;
64 int y = 0;
65 QString screenId;
66 bool isVirtualScreen = false;
70 int virtualIndex = -1;
73};
74
87[[nodiscard]] PHOSPHORSCREENSCORE_EXPORT QVariantList screenInfoListToVariantList(const QList<ScreenInfo>& screens);
88
89} // namespace PhosphorScreens
Definition IWindowTrackingService.h:27
PHOSPHORSCREENSCORE_EXPORT QVariantList screenInfoListToVariantList(const QList< ScreenInfo > &screens)
Convert a ScreenInfo list to QVariantList suitable for QML consumption.
Lightweight descriptor for a connected screen, suitable for passing across settings UIs and QML.
Definition ScreenInfo.h:48
QString virtualDisplayName
User-facing name for virtual screens (e.g.
Definition ScreenInfo.h:72
QString name
Definition ScreenInfo.h:49
QString manufacturer
Definition ScreenInfo.h:51
QString screenId
Definition ScreenInfo.h:65
QString connectorName
Physical connector (e.g.
Definition ScreenInfo.h:68
QString model
Definition ScreenInfo.h:52