Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorScreens::DBusScreenAdaptor Class Reference

D-Bus adaptor for the org.phosphor_works.Placement.Screen screen-topology surface: screen queries, virtual-screen mutation, the JSON round-trip for setVirtualScreenConfig, caches, and signals. More...

#include <PhosphorScreens/DBusScreenAdaptor.h>

Inheritance diagram for PhosphorScreens::DBusScreenAdaptor:
[legend]

Public Types

using CompositorReportGate = std::function<bool(QLatin1StringView member)>
 The admission check for the methods only the compositor may call (setPrimaryScreenFromKWin, setAvailableGeometryFromKWin, setPixelSizeFromKWin), which report what the compositor saw.

Public Slots

QStringList getScreens ()
QString getScreenInfo (const QString &screenId)
 JSON object describing screenId.
QString getPrimaryScreen ()
QString getScreenId (const QString &connectorName)
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's clientArea(MaximizeArea) query).
QRect getAvailableGeometry (const QString &screenId)
 The geometry queries answer the primary screen for an EMPTY id only.
QRect getScreenGeometry (const QString &screenId)
QString getVirtualScreenConfig (const QString &physicalScreenId)
QString setVirtualScreenConfig (const QString &physicalScreenId, const QString &configJson)
 Set the virtual screen subdivision configuration for a physical screen.
QStringList getPhysicalScreens ()
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/right/up/down) within the same physical monitor.
QString rotateVirtualScreens (const QString &physicalScreenId, bool clockwise)
 Rotate every VS region on physicalScreenId through a spatial clockwise ring order.
void setPixelSizeFromKWin (const QString &screenName, int width, int height)
 Record an output's exact size in device pixels as reported by the compositor (the KWin effect reads the output's current mode, already rotated).

Signals

void screenAdded (const QString &screenId)
void screenRemoved (const QString &screenId)
void screenGeometryChanged (const QString &screenId)
 The screen's resolution, position or logical scale changed (the scale through ScreenManager::logicalScaleChanged), or what getScreenInfo answers for its size in device pixels did (through ScreenManager::acceptedPixelSizeChanged), once per effective id.
void virtualScreensChanged (const QString &physicalScreenId)
void availableGeometryChanged (const QString &screenId)
 The screen's available geometry (the work area left by panels) moved while its full rect may not have, once per effective id.

Public Member Functions

 DBusScreenAdaptor (ScreenManager *manager, IConfigStore *store, QObject *parent=nullptr)
 Primary constructor: wires the screen-topology service and the VS config store at construction time.
 ~DBusScreenAdaptor () override
void setCompositorReportGate (CompositorReportGate gate)

Protected Member Functions

ScreenManager * screenManager () const
IConfigStore * configStore () const

Detailed Description

D-Bus adaptor for the org.phosphor_works.Placement.Screen screen-topology surface: screen queries, virtual-screen mutation, the JSON round-trip for setVirtualScreenConfig, caches, and signals.

The D-Bus interface name is declared HERE via Q_CLASSINFO, on the class that declares the signals — not on a host subclass. Qt derives a signal's D-Bus interface from the metaobject that declares the signal: a subclass-only Q_CLASSINFO fixes incoming method dispatch (that walks the whole adaptor hierarchy) but leaves every signal in this class emitting on an auto-generated junk interface name, which no consumer's match rule ever sees. The bus service name and object path — the parts that genuinely vary per host — are still chosen by the host at registerObject time.

Lifetimes: pointers are non-owning. ScreenManager and IConfigStore must outlive this adaptor.

Member Typedef Documentation

◆ CompositorReportGate

using PhosphorScreens::DBusScreenAdaptor::CompositorReportGate = std::function<bool(QLatin1StringView member)>

The admission check for the methods only the compositor may call (setPrimaryScreenFromKWin, setAvailableGeometryFromKWin, setPixelSizeFromKWin), which report what the compositor saw.

Called with the method's name first thing in each; false means the gate has answered the caller and the method returns. Unset, every caller is admitted: the embedder decides who the compositor is.

Constructor & Destructor Documentation

◆ DBusScreenAdaptor()

PhosphorScreens::DBusScreenAdaptor::DBusScreenAdaptor ( ScreenManager * manager,
IConfigStore * store,
QObject * parent = nullptr )
explicit

Primary constructor: wires the screen-topology service and the VS config store at construction time.

manager and store may be null for bring-up paths that don't need either (most methods return empty results / rejection tokens in that case).

◆ ~DBusScreenAdaptor()

PhosphorScreens::DBusScreenAdaptor::~DBusScreenAdaptor ( )
override

Member Function Documentation

◆ availableGeometryChanged

void PhosphorScreens::DBusScreenAdaptor::availableGeometryChanged ( const QString & screenId)
signal

The screen's available geometry (the work area left by panels) moved while its full rect may not have, once per effective id.

Follows ScreenManager::availableGeometryChanged, which fires only on a real change. Appended last among the signals.

◆ configStore()

IConfigStore * PhosphorScreens::DBusScreenAdaptor::configStore ( ) const
protected
Returns
the wired IConfigStore pointer (may be null, QPointer-guarded).

◆ getAvailableGeometry

QRect PhosphorScreens::DBusScreenAdaptor::getAvailableGeometry ( const QString & screenId)
slot

The geometry queries answer the primary screen for an EMPTY id only.

A named screen that does not resolve, and a virtual screen the manager does not know, answer an invalid QRect, never another screen's rect.

◆ getEffectiveScreenAt

QString PhosphorScreens::DBusScreenAdaptor::getEffectiveScreenAt ( int x,
int y )
slot

◆ getPhysicalScreens

QStringList PhosphorScreens::DBusScreenAdaptor::getPhysicalScreens ( )
slot

◆ getPrimaryScreen

QString PhosphorScreens::DBusScreenAdaptor::getPrimaryScreen ( )
slot

◆ getScreenGeometry

QRect PhosphorScreens::DBusScreenAdaptor::getScreenGeometry ( const QString & screenId)
slot

◆ getScreenId

QString PhosphorScreens::DBusScreenAdaptor::getScreenId ( const QString & connectorName)
slot

◆ getScreenInfo

QString PhosphorScreens::DBusScreenAdaptor::getScreenInfo ( const QString & screenId)
slot

JSON object describing screenId.

Besides the identity and geometry keys it carries devicePixelRatio, the compositor's logical scale (see ScreenManager::logicalScale), and pixelSize {width, height}, the screen's size in device pixels, for a virtual screen its own region's share. pixelSize is ScreenManager::pixelSize: the output's mode as the compositor reported it (setPixelSizeFromKWin) once the host accepted the report, or until then the size the host seeded, which is the size last accepted for that monitor, in this session or an earlier one. With neither it is estimated as the logical size times the scale, rounded, which lands on the mode or within a pixel of it once the scale is the real one. pixelSizeSource names which of the three it is: "reported", "seeded" or "estimated". It is absent when there is no size at all. An id that does not resolve, including a virtual screen the manager does not know, answers an empty string and is not cached.

◆ getScreens

QStringList PhosphorScreens::DBusScreenAdaptor::getScreens ( )
slot

◆ getVirtualScreenConfig

QString PhosphorScreens::DBusScreenAdaptor::getVirtualScreenConfig ( const QString & physicalScreenId)
slot

◆ rotateVirtualScreens

QString PhosphorScreens::DBusScreenAdaptor::rotateVirtualScreens ( const QString & physicalScreenId,
bool clockwise )
slot

Rotate every VS region on physicalScreenId through a spatial clockwise ring order.

Returns
Empty string on success, otherwise a stable rejection token from VirtualScreenSwapper::reasonString().

◆ screenAdded

void PhosphorScreens::DBusScreenAdaptor::screenAdded ( const QString & screenId)
signal

◆ screenGeometryChanged

void PhosphorScreens::DBusScreenAdaptor::screenGeometryChanged ( const QString & screenId)
signal

The screen's resolution, position or logical scale changed (the scale through ScreenManager::logicalScaleChanged), or what getScreenInfo answers for its size in device pixels did (through ScreenManager::acceptedPixelSizeChanged), once per effective id.

◆ screenManager()

ScreenManager * PhosphorScreens::DBusScreenAdaptor::screenManager ( ) const
protected
Returns
the wired ScreenManager pointer (may be null, including when the wired manager has since been destroyed — QPointer tracks that). Defined out-of-line so callers don't need the complete ScreenManager / IConfigStore types just to include this header.

◆ screenRemoved

void PhosphorScreens::DBusScreenAdaptor::screenRemoved ( const QString & screenId)
signal

◆ setAvailableGeometryFromKWin

void PhosphorScreens::DBusScreenAdaptor::setAvailableGeometryFromKWin ( const QString & screenName,
int x,
int y,
int width,
int height )
slot

Record the authoritative per-screen available geometry as reported by the compositor (the KWin effect's clientArea(MaximizeArea) query).

Overrides the panel-strut heuristic in ScreenManager. screenName is a connector name (e.g. DP-1); x / y / width / height are the work-area rect. An invalid or zero-size rect clears the override — a defensive contract; the effect itself always reports a valid rect.

◆ setCompositorReportGate()

void PhosphorScreens::DBusScreenAdaptor::setCompositorReportGate ( CompositorReportGate gate)

◆ setPixelSizeFromKWin

void PhosphorScreens::DBusScreenAdaptor::setPixelSizeFromKWin ( const QString & screenName,
int width,
int height )
slot

Record an output's exact size in device pixels as reported by the compositor (the KWin effect reads the output's current mode, already rotated).

screenName is a connector name. A 0x0 size clears the record, which is what the effect sends when the output goes away. A negative size, a size with only one side zero, or one past any real output's is dropped and leaves the record as it was. Forwards to ScreenManager::setCompositorPixelSize, where the report is pending until the host accepts it (ScreenManager::acceptCompositorPixelSize), and getScreenInfo answers it only from then. Appended last among the slots.

◆ setPrimaryScreenFromKWin

void PhosphorScreens::DBusScreenAdaptor::setPrimaryScreenFromKWin ( const QString & connectorName)
slot

◆ setVirtualScreenConfig

QString PhosphorScreens::DBusScreenAdaptor::setVirtualScreenConfig ( const QString & physicalScreenId,
const QString & configJson )
slot

Set the virtual screen subdivision configuration for a physical screen.

Returns
Empty string on success, otherwise a stable rejection token (e.g. parse_error, missing_screens, bad_index, store_rejected) so D-Bus callers can distinguish failure modes without parsing logs. Matches the pattern used by swapVirtualScreenInDirection / rotateVirtualScreens.

◆ swapVirtualScreenInDirection

QString PhosphorScreens::DBusScreenAdaptor::swapVirtualScreenInDirection ( const QString & currentVirtualScreenId,
const QString & direction )
slot

Swap the region of currentVirtualScreenId with the adjacent sibling VS in the given direction (left/right/up/down) within the same physical monitor.

No-op if the current id is not virtual or no sibling lies in that direction. All per-VS state (windows, layout, autotile) follows the new geometry automatically.

Returns
Empty string on success, otherwise a stable rejection token from VirtualScreenSwapper::reasonString() so callers can distinguish failure modes without parsing logs.

◆ virtualScreensChanged

void PhosphorScreens::DBusScreenAdaptor::virtualScreensChanged ( const QString & physicalScreenId)
signal

The documentation for this class was generated from the following file: