Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorWorkspaces::IVirtualDesktopBackend Class Referenceabstract

Where a VirtualDesktopManager's desktops come from: the transport to the compositor that owns them. More...

#include <PhosphorWorkspaces/IVirtualDesktopBackend.h>

Inheritance diagram for PhosphorWorkspaces::IVirtualDesktopBackend:
[legend]

Classes

struct  Snapshot
 One whole desktop list, with the current desktop and the grid's rows. More...

Public Types

using SnapshotCallback = std::function<void(std::optional<Snapshot> snapshot)>
using AnswerCallback = std::function<void(bool answered)>
 answered is false for an error or a timeout: a stall, not a refusal.

Signals

void currentChanged (const QString &desktopId)
void countChanged (int count)
 The desktop count, which closes a create, a remove or a resize: every desktop signal of the change went out before it.
void desktopCreated (const QString &desktopId, int position, const QString &name)
void desktopCreatedUnreadable (const QString &desktopId)
 A desktop was created but its data could not be read.
void desktopDataChanged (const QString &desktopId, int position, const QString &name)
 A desktop was renamed or moved; position is its new one.
void desktopDataChangedUnreadable ()
 A desktop's data changed but could not be read.
void desktopRemoved (const QString &desktopId)
void rowsChanged (int rows)
 The grid's row count changed (a reshape moves no desktop).

Public Member Functions

 IVirtualDesktopBackend (QObject *parent=nullptr)
 ~IVirtualDesktopBackend () override=default
virtual bool connectToSource ()=0
 Reach the compositor's desktops.
virtual bool isReachable () const =0
 Whether a read can reach the desktops right now.
virtual void subscribe ()=0
 Start and stop emitting the change signals.
virtual void unsubscribe ()=0
virtual std::optional< Snapshot > readSnapshot ()=0
 Read the whole list now, blocking the caller.
virtual void readSnapshotAsync (SnapshotCallback done)=0
 Read the whole list without blocking.
virtual void setCurrentDesktop (const QString &desktopId)=0
 Switch to the desktop with this id, without waiting for the switch: it arrives as currentChanged.
virtual void createDesktop (uint position, const QString &name, AnswerCallback done)=0
 Create a desktop at a 0-based position.
virtual void removeDesktop (const QString &desktopId, AnswerCallback done)=0
 Remove a desktop. done as for createDesktop.
virtual void setDesktopName (const QString &desktopId, const QString &name)=0
 Rename a desktop. The new name arrives as desktopDataChanged.

Detailed Description

Where a VirtualDesktopManager's desktops come from: the transport to the compositor that owns them.

The manager keeps every rule about the desktops (validating a list, the list built from the change signals, renumbering, the per-screen desktops, one read in flight, retrying a failed read). A backend only reads, writes and reports what the compositor says, in the order the compositor says it.

KWin's backend talks to org.kde.KWin.VirtualDesktopManager on the session bus (PhosphorWorkspaces::Plasma). A compositor that owns its desktops in process implements this directly.

Signals go out only between subscribe() and unsubscribe(), and in the order the compositor produced the changes. A read answers with the compositor's state after every change signal emitted before the answer.

Member Typedef Documentation

◆ AnswerCallback

using PhosphorWorkspaces::IVirtualDesktopBackend::AnswerCallback = std::function<void(bool answered)>

answered is false for an error or a timeout: a stall, not a refusal.

◆ SnapshotCallback

using PhosphorWorkspaces::IVirtualDesktopBackend::SnapshotCallback = std::function<void(std::optional<Snapshot> snapshot)>

Constructor & Destructor Documentation

◆ IVirtualDesktopBackend()

PhosphorWorkspaces::IVirtualDesktopBackend::IVirtualDesktopBackend ( QObject * parent = nullptr)
inlineexplicit

◆ ~IVirtualDesktopBackend()

PhosphorWorkspaces::IVirtualDesktopBackend::~IVirtualDesktopBackend ( )
overridedefault

Member Function Documentation

◆ connectToSource()

virtual bool PhosphorWorkspaces::IVirtualDesktopBackend::connectToSource ( )
pure virtual

Reach the compositor's desktops.

False when there are none to reach; the manager then stays unavailable. Called once.

Implemented in PhosphorWorkspaces::KWinVirtualDesktopBackend.

◆ countChanged

void PhosphorWorkspaces::IVirtualDesktopBackend::countChanged ( int count)
signal

The desktop count, which closes a create, a remove or a resize: every desktop signal of the change went out before it.

◆ createDesktop()

virtual void PhosphorWorkspaces::IVirtualDesktopBackend::createDesktop ( uint position,
const QString & name,
AnswerCallback done )
pure virtual

Create a desktop at a 0-based position.

done runs once the compositor answered, after any desktopCreated the call caused, and never after this backend is destroyed.

Implemented in PhosphorWorkspaces::KWinVirtualDesktopBackend.

◆ currentChanged

void PhosphorWorkspaces::IVirtualDesktopBackend::currentChanged ( const QString & desktopId)
signal

◆ desktopCreated

void PhosphorWorkspaces::IVirtualDesktopBackend::desktopCreated ( const QString & desktopId,
int position,
const QString & name )
signal

◆ desktopCreatedUnreadable

void PhosphorWorkspaces::IVirtualDesktopBackend::desktopCreatedUnreadable ( const QString & desktopId)
signal

A desktop was created but its data could not be read.

desktopId is the id when that much was readable, else empty.

◆ desktopDataChanged

void PhosphorWorkspaces::IVirtualDesktopBackend::desktopDataChanged ( const QString & desktopId,
int position,
const QString & name )
signal

A desktop was renamed or moved; position is its new one.

◆ desktopDataChangedUnreadable

void PhosphorWorkspaces::IVirtualDesktopBackend::desktopDataChangedUnreadable ( )
signal

A desktop's data changed but could not be read.

◆ desktopRemoved

void PhosphorWorkspaces::IVirtualDesktopBackend::desktopRemoved ( const QString & desktopId)
signal

◆ isReachable()

virtual bool PhosphorWorkspaces::IVirtualDesktopBackend::isReachable ( ) const
pure virtual

Whether a read can reach the desktops right now.

KWin's backend says no while KWin is off the bus (a restart). The manager reads nothing then, and commits a count change as reported instead of reading the list.

Implemented in PhosphorWorkspaces::KWinVirtualDesktopBackend.

◆ readSnapshot()

virtual std::optional< Snapshot > PhosphorWorkspaces::IVirtualDesktopBackend::readSnapshot ( )
pure virtual

Read the whole list now, blocking the caller.

nullopt when the read failed. Used only while the manager is not running (before start(), after stop()).

Implemented in PhosphorWorkspaces::KWinVirtualDesktopBackend.

◆ readSnapshotAsync()

virtual void PhosphorWorkspaces::IVirtualDesktopBackend::readSnapshotAsync ( SnapshotCallback done)
pure virtual

Read the whole list without blocking.

done runs once, with nullopt when the read failed, and never after this backend is destroyed.

Implemented in PhosphorWorkspaces::KWinVirtualDesktopBackend.

◆ removeDesktop()

virtual void PhosphorWorkspaces::IVirtualDesktopBackend::removeDesktop ( const QString & desktopId,
AnswerCallback done )
pure virtual

Remove a desktop. done as for createDesktop.

Implemented in PhosphorWorkspaces::KWinVirtualDesktopBackend.

◆ rowsChanged

void PhosphorWorkspaces::IVirtualDesktopBackend::rowsChanged ( int rows)
signal

The grid's row count changed (a reshape moves no desktop).

◆ setCurrentDesktop()

virtual void PhosphorWorkspaces::IVirtualDesktopBackend::setCurrentDesktop ( const QString & desktopId)
pure virtual

Switch to the desktop with this id, without waiting for the switch: it arrives as currentChanged.

Implemented in PhosphorWorkspaces::KWinVirtualDesktopBackend.

◆ setDesktopName()

virtual void PhosphorWorkspaces::IVirtualDesktopBackend::setDesktopName ( const QString & desktopId,
const QString & name )
pure virtual

Rename a desktop. The new name arrives as desktopDataChanged.

Implemented in PhosphorWorkspaces::KWinVirtualDesktopBackend.

◆ subscribe()

virtual void PhosphorWorkspaces::IVirtualDesktopBackend::subscribe ( )
pure virtual

Start and stop emitting the change signals.

Each is called only when the other was last, so neither needs to guard against doubling.

Implemented in PhosphorWorkspaces::KWinVirtualDesktopBackend.

◆ unsubscribe()

virtual void PhosphorWorkspaces::IVirtualDesktopBackend::unsubscribe ( )
pure virtual

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