QML singleton exposing the compositor's workspaces. More...
#include <PhosphorShell/Workspaces.h>
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. | |
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.
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.
|
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.
|
explicit |
Over backend, which must outlive this object or be destroyed with it.
Null: always unsupported and empty.
|
override |
|
signal |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
signal |
|
staticnodiscard |
QML-singleton factory hook.
|
nodiscard |
|
nodiscard |
|
signal |
| 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.