Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
ScreenIdentity.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 "phosphorscreenscore_export.h"
7
8// EDID parsing primitives + the wire-format helpers (`buildBaseId`,
9// `buildScreenBaseId`, `normalizeHexSerial`, `readEdidHeaderSerial`,
10// `invalidateEdidCache`) live in PhosphorIdentity::ScreenId — they're
11// cross-process and the KWin effect needs them without pulling in
12// Qt6::Gui. Re-include here so callers of this header don't have to
13// chase the indirection.
15
16#include <QString>
17#include <QStringList>
18
19class QScreen;
20
21namespace Phosphor::Screens {
22
53namespace ScreenIdentity {
54
55// ─── QScreen-aware helpers ───────────────────────────────────────────────
56//
57// The EDID parsing + base-ID assembly primitives live in
58// PhosphorIdentity::ScreenId (re-included via the header above so callers
59// can just write `using namespace PhosphorIdentity::ScreenId;` if they
60// want both surfaces).
61
72PHOSPHORSCREENSCORE_EXPORT void reset();
73
82PHOSPHORSCREENSCORE_EXPORT void invalidateEdidCache(const QString& connectorName = QString());
83
102PHOSPHORSCREENSCORE_EXPORT void invalidateComputedIdentifiers();
103
115PHOSPHORSCREENSCORE_EXPORT QString baseIdentifierFor(const QScreen* screen);
116
125PHOSPHORSCREENSCORE_EXPORT QString identifierFor(const QScreen* screen);
126
145PHOSPHORSCREENSCORE_EXPORT QScreen* findByIdOrName(const QString& identifier);
146
148inline bool isConnectorName(const QString& identifier)
149{
150 return !identifier.isEmpty() && !identifier.contains(QLatin1Char(':'));
151}
152
154PHOSPHORSCREENSCORE_EXPORT QString idForName(const QString& connectorName);
155
157PHOSPHORSCREENSCORE_EXPORT QString nameForId(const QString& screenId);
158
177inline QStringList variantsFor(const QString& screenIdOrName)
178{
179 QStringList variants;
180 if (screenIdOrName.isEmpty()) {
181 return variants;
182 }
183 variants.append(screenIdOrName);
184 if (isConnectorName(screenIdOrName)) {
185 const QString resolved = idForName(screenIdOrName);
186 if (!resolved.isEmpty() && resolved != screenIdOrName) {
187 variants.append(resolved);
188 }
189 } else {
190 const QString connector = nameForId(screenIdOrName);
191 if (!connector.isEmpty() && connector != screenIdOrName) {
192 variants.append(connector);
193 }
194 }
195 return variants;
196}
197
206PHOSPHORSCREENSCORE_EXPORT bool screensMatch(const QString& a, const QString& b);
207
213PHOSPHORSCREENSCORE_EXPORT bool belongsToPhysicalScreen(const QString& storedScreenId, const QString& physicalScreenId);
214
215} // namespace ScreenIdentity
216
217} // namespace Phosphor::Screens
bool isConnectorName(const QString &identifier)
True if the identifier looks like a connector name (no ':').
Definition ScreenIdentity.h:148
PHOSPHORSCREENSCORE_EXPORT QString nameForId(const QString &screenId)
Convert a screen identifier back to its current connector name.
QStringList variantsFor(const QString &screenIdOrName)
Return every equivalent form of screenIdOrName.
Definition ScreenIdentity.h:177
PHOSPHORSCREENSCORE_EXPORT void reset()
Unconditionally drop every cache this namespace holds (local identifier caches AND the cross-process ...
PHOSPHORSCREENSCORE_EXPORT bool screensMatch(const QString &a, const QString &b)
Tolerance-aware equality between two screen identifiers.
PHOSPHORSCREENSCORE_EXPORT QScreen * findByIdOrName(const QString &identifier)
Resolve an identifier (connector name OR EDID-style ID, with or without "/vs:N" virtual-screen suffix...
PHOSPHORSCREENSCORE_EXPORT QString baseIdentifierFor(const QScreen *screen)
Compute the EDID-based base ID for a QScreen*.
PHOSPHORSCREENSCORE_EXPORT QString idForName(const QString &connectorName)
Convert a connector name to its current screen identifier.
PHOSPHORSCREENSCORE_EXPORT void invalidateEdidCache(const QString &connectorName=QString())
Drop the QScreen-keyed identifier caches AND the underlying EDID-serial cache (cascades to PhosphorId...
PHOSPHORSCREENSCORE_EXPORT void invalidateComputedIdentifiers()
Drop the computed-identifier and reverse-lookup caches without touching the EDID-serial cache.
PHOSPHORSCREENSCORE_EXPORT QString identifierFor(const QScreen *screen)
Compute the canonical identifier for a QScreen*.
PHOSPHORSCREENSCORE_EXPORT bool belongsToPhysicalScreen(const QString &storedScreenId, const QString &physicalScreenId)
Whether storedScreenId belongs to the physical screen physicalScreenId.
Definition IWindowTrackingService.h:26