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

Resolve a global cursor position to the effective screen ID. More...

#include <phosphor-screens/include/PhosphorScreens/Resolver.h>

Public Types

using Endpoint = ResolverEndpoint
 

Static Public Member Functions

static QString effectiveScreenAt (const QPoint &pos, const ResolverEndpoint &endpoint=ResolverEndpoint{}, int timeoutMs=PhosphorProtocol::Service::SyncCallTimeoutMs)
 Resolve a screen coordinate to an effective screen ID.
 
static QString effectiveScreenAtCursor (const ResolverEndpoint &endpoint=ResolverEndpoint{}, int timeoutMs=PhosphorProtocol::Service::SyncCallTimeoutMs)
 Convenience wrapper: resolve at the current QCursor::pos().
 

Detailed Description

Resolve a global cursor position to the effective screen ID.

On a plain single-monitor setup "effective screen ID" is just the physical QScreen::name(). On multi-monitor or virtual-screen setups, a Phosphor daemon (or any compatible host) tracks a richer mapping (virtual-screen regions carved out of physical outputs, duplicate-connector disambiguation) that Qt itself doesn't know about — so we ask the daemon over D-Bus.

The resolver is a thin static-method facade over a single D-Bus call with a Qt-native fallback. No state, no lifetime; the caller decides which service / object / interface to ask.

Member Typedef Documentation

◆ Endpoint

Member Function Documentation

◆ effectiveScreenAt()

static QString Phosphor::Screens::ScreenResolver::effectiveScreenAt ( const QPoint &  pos,
const ResolverEndpoint endpoint = ResolverEndpoint{},
int  timeoutMs = PhosphorProtocol::Service::SyncCallTimeoutMs 
)
static

Resolve a screen coordinate to an effective screen ID.

Tries the daemon's virtual-screen-aware lookup first (skipped entirely if the daemon isn't already on the bus, so the call never triggers D-Bus auto-activation). Falls back to QGuiApplication::screenAt(pos), then to QGuiApplication::primaryScreen(). Returns an empty string only if Qt reports no screens at all (headless / test environments).

Note
Reentrancy: while waiting for the daemon's reply, this method spins a local QEventLoop. Queued signals, posted events, and pending UI paints continue to run during the wait (that's the whole point — QDBus::Block would freeze the thread). Callers MUST NOT hold mutable state across the call that another slot could invalidate; treat the return as a snapshot taken after arbitrary event-loop activity.
Parameters
posPosition in global screen coordinates.
endpointD-Bus endpoint to query. Defaults to the PlasmaZones daemon.
timeoutMsD-Bus call timeout in milliseconds. Keep this short — the caller is typically blocking the user's shortcut keypress.

◆ effectiveScreenAtCursor()

static QString Phosphor::Screens::ScreenResolver::effectiveScreenAtCursor ( const ResolverEndpoint endpoint = ResolverEndpoint{},
int  timeoutMs = PhosphorProtocol::Service::SyncCallTimeoutMs 
)
static

Convenience wrapper: resolve at the current QCursor::pos().


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