Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
DBusScreenAdaptor.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 "phosphorscreens_export.h"
7
8#include <QDBusAbstractAdaptor>
9#include <QHash>
10#include <QObject>
11#include <QPointer>
12#include <QRect>
13#include <QStringList>
14
15#include <functional>
16
17class QScreen;
18
19namespace Phosphor::Screens {
20
21class IConfigStore;
22class ScreenManager;
23
42class PHOSPHORSCREENS_EXPORT DBusScreenAdaptor : public QDBusAbstractAdaptor
43{
44 Q_OBJECT
45 Q_CLASSINFO("D-Bus Interface", "org.plasmazones.Screen")
46
47public:
52 explicit DBusScreenAdaptor(ScreenManager* manager, IConfigStore* store, QObject* parent = nullptr);
54
55public Q_SLOTS:
56 // Screen queries
57 QStringList getScreens();
58 QString getScreenInfo(const QString& screenId);
60 QString getScreenId(const QString& connectorName);
61 void setPrimaryScreenFromKWin(const QString& connectorName);
68 void setAvailableGeometryFromKWin(const QString& screenName, int x, int y, int width, int height);
69 QRect getAvailableGeometry(const QString& screenId);
70 QRect getScreenGeometry(const QString& screenId);
71
72 // Virtual screen management
73 QString getVirtualScreenConfig(const QString& physicalScreenId);
80 QString setVirtualScreenConfig(const QString& physicalScreenId, const QString& configJson);
81 QStringList getPhysicalScreens();
82 QString getEffectiveScreenAt(int x, int y);
83
92 QString swapVirtualScreenInDirection(const QString& currentVirtualScreenId, const QString& direction);
93
98 QString rotateVirtualScreens(const QString& physicalScreenId, bool clockwise);
99
100Q_SIGNALS:
101 void screenAdded(const QString& screenId);
102 void screenRemoved(const QString& screenId);
103 void screenGeometryChanged(const QString& screenId);
104 void virtualScreensChanged(const QString& physicalScreenId);
105
106protected:
114
115private:
116 void handleScreenGeometryChanged(QScreen* screen, const QString& physId);
117 void handleScreenRemoved(QScreen* removedScreen, QScreen* targetScreen, const QString& cachedId);
126 void handleScreenIdentifierChanged(const QString& oldId, const QString& newId);
127 bool emitForEffectiveScreens(const QString& physId, const std::function<void(const QString&)>& emitFn);
128 void invalidateScreenInfoCache();
129 void connectScreenManagerSignals(ScreenManager* mgr);
130 void disconnectScreenManagerSignals(ScreenManager* mgr);
131 void wireQGuiApplicationSignals();
132
133 QString m_primaryScreenOverride;
134 // QPointer-guarded so a ScreenManager / IConfigStore destroyed before
135 // this adaptor (e.g. daemon tears down data members before QObject
136 // children) safely reads as null rather than dangling. Prevents UAF in
137 // the destructor's disconnect path.
138 QPointer<ScreenManager> m_screenManager;
139 QPointer<IConfigStore> m_configStore;
140
141 QStringList m_lastEmittedEffectiveIds;
142 QHash<QString, QStringList> m_cachedEffectiveIdsPerScreen;
143 QHash<QString, QString> m_cachedScreenInfoJson;
144
145 bool m_qGuiAppSignalsWired = false;
146};
147
148} // namespace Phosphor::Screens
D-Bus adaptor for the org.plasmazones.Screen screen-topology surface: screen queries,...
Definition DBusScreenAdaptor.h:43
void screenGeometryChanged(const QString &screenId)
QRect getScreenGeometry(const QString &screenId)
QString setVirtualScreenConfig(const QString &physicalScreenId, const QString &configJson)
Set the virtual screen subdivision configuration for a physical screen.
void virtualScreensChanged(const QString &physicalScreenId)
QString getScreenInfo(const QString &screenId)
QString getScreenId(const QString &connectorName)
QRect getAvailableGeometry(const QString &screenId)
void screenAdded(const QString &screenId)
DBusScreenAdaptor(ScreenManager *manager, IConfigStore *store, QObject *parent=nullptr)
Primary constructor: wires the screen-topology service and the VS config store at construction time.
void screenRemoved(const QString &screenId)
IConfigStore * configStore() const
QString rotateVirtualScreens(const QString &physicalScreenId, bool clockwise)
Rotate every VS region on physicalScreenId through a spatial clockwise ring order.
QString getVirtualScreenConfig(const QString &physicalScreenId)
QString getEffectiveScreenAt(int x, int y)
QString swapVirtualScreenInDirection(const QString &currentVirtualScreenId, const QString &direction)
Swap the region of currentVirtualScreenId with the adjacent sibling VS in the given direction (left/r...
ScreenManager * screenManager() const
void setPrimaryScreenFromKWin(const QString &connectorName)
void setAvailableGeometryFromKWin(const QString &screenName, int x, int y, int width, int height)
Record the authoritative per-screen available geometry as reported by the compositor (the KWin effect...
Pluggable persistence for virtual-screen configurations.
Definition IConfigStore.h:37
Centralized screen-topology service.
Definition Manager.h:75
Definition IWindowTrackingService.h:26