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

QML singleton exposing the compositor's workspaces. More...

#include <PhosphorShell/Workspaces.h>

Inheritance diagram for PhosphorShell::Workspaces:
[legend]

Signals

void activeChanged ()
void countChanged ()
void supportedChanged ()

Public Member Functions

 Workspaces (QObject *parent=nullptr)
 Bind Repeater { model: Workspaces.model }.
 Workspaces (WorkspaceBackend *backend, QObject *parent=nullptr)
 Over backend, which must outlive this object or be destroyed with it.
 ~Workspaces () override
QAbstractListModel * model () const
QString activeId () const
QString activeName () const
int activeIndex () const
int count () const
bool isSupported () const
void switchTo (const QString &id)
 Switch to the workspace with this identifier.

Static Public Member Functions

static Workspaces * create (QQmlEngine *engine, QJSEngine *scriptEngine)
 QML-singleton factory hook.

Detailed Description

QML singleton exposing the compositor's workspaces.

Usage:

import Phosphor.Shell

Repeater {
    model: Workspaces.model
    delegate: Rectangle {
        required property string workspaceId
        required property string name
        required property bool isActive
        TapHandler { onTapped: Workspaces.switchTo(workspaceId) }
    }
}

The workspaces come from the compositor over ext-workspace-v1 (staging in wayland-protocols). Every workspace group is listed, groups in the order the compositor announced them, each ordered by its coordinates; hidden workspaces are left out. When several groups (one per output, say) each have an active workspace, activeId is the first of them in that order.

Identifiers, not indices

The model's workspaceId role and switchTo(id) are the whole interface for addressing a workspace. Positions renumber whenever a workspace is created or removed, so anything holding a workspace across such an event — a pager delegate mid-animation, a rule, a shortcut — must key on the id.

supported is true while the compositor advertises ext_workspace_manager_v1, and follows the global as it appears and disappears. The global arrives asynchronously, so a shell reading it at startup sees false first and then true. Without it everything is empty: count is 0 and activeId is empty.

Constructor & Destructor Documentation

◆ Workspaces() [1/2]

PhosphorShell::Workspaces::Workspaces ( QObject * parent = nullptr)
explicit

Bind Repeater { model: Workspaces.model }.

Identifier of the current workspace, or empty when there is none. 1-based position of the current workspace, for a plain numeric readout, 0 when there is none. Do NOT use it to address a workspace — see the class docs. Over the process-wide ext-workspace client on Qt's Wayland connection.

◆ Workspaces() [2/2]

PhosphorShell::Workspaces::Workspaces ( WorkspaceBackend * backend,
QObject * parent = nullptr )
explicit

Over backend, which must outlive this object or be destroyed with it.

Null: always unsupported and empty.

◆ ~Workspaces()

PhosphorShell::Workspaces::~Workspaces ( )
override

Member Function Documentation

◆ activeChanged

void PhosphorShell::Workspaces::activeChanged ( )
signal

◆ activeId()

QString PhosphorShell::Workspaces::activeId ( ) const
nodiscard

◆ activeIndex()

int PhosphorShell::Workspaces::activeIndex ( ) const
nodiscard

◆ activeName()

QString PhosphorShell::Workspaces::activeName ( ) const
nodiscard

◆ count()

int PhosphorShell::Workspaces::count ( ) const
nodiscard

◆ countChanged

void PhosphorShell::Workspaces::countChanged ( )
signal

◆ create()

Workspaces * PhosphorShell::Workspaces::create ( QQmlEngine * engine,
QJSEngine * scriptEngine )
staticnodiscard

QML-singleton factory hook.

◆ isSupported()

bool PhosphorShell::Workspaces::isSupported ( ) const
nodiscard

◆ model()

QAbstractListModel * PhosphorShell::Workspaces::model ( ) const
nodiscard

◆ supportedChanged

void PhosphorShell::Workspaces::supportedChanged ( )
signal

◆ switchTo()

void PhosphorShell::Workspaces::switchTo ( const QString & id)

Switch to the workspace with this identifier.

Unknown or empty ids are ignored. Asynchronous: the compositor confirms by way of the change signals, so activeId does not update on return.


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