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

QML singleton exposing the live list of toplevel windows for taskbars. More...

#include <phosphor-shell/include/PhosphorShell/Toplevels.h>

Inheritance diagram for PhosphorShell::Toplevels:
[legend]

Signals

void toplevelsChanged ()
 

Public Member Functions

 Toplevels (QObject *parent=nullptr)
 Snapshot list of currently-live toplevels.
 
 ~Toplevels () override
 
QList< PhosphorWayland::ForeignToplevel * > toplevels () const
 
QAbstractListModel * model () const
 
bool isSupported () const
 

Static Public Member Functions

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

Detailed Description

QML singleton exposing the live list of toplevel windows for taskbars.

Wraps PhosphorWayland::ForeignToplevelManager and turns the imperative toplevelAdded/toplevelRemoved signals into a notifying toplevels Q_PROPERTY suitable for Repeater { model: Toplevels.toplevels }.

Usage from QML:

import Phosphor.Shell

Repeater {
    model: Toplevels.toplevels
    delegate: Rectangle {
        required property var modelData  // ForeignToplevel*
        Text { text: modelData.title }
        MouseArea {
            anchors.fill: parent
            onClicked: modelData.activate()
        }
    }
}

The supported property is false on compositors that don't advertise zwlr_foreign_toplevel_manager_v1 (e.g. plain Mutter without extensions); shells should hide their taskbar UI in that case rather than showing an empty placeholder. KWin and the wlroots family (sway, Hyprland, Niri, river, labwc) all support it.

Constructor & Destructor Documentation

◆ Toplevels()

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

Snapshot list of currently-live toplevels.

Useful for one-shot reads (const list = Toplevels.toplevels). DO NOT bind a Repeater or ListView's model: to this property — every change re-evaluates the QList and resets every delegate, including hover state, scroll position, and any per-delegate state. Bind model: Toplevels.model for incremental add/remove updates. Incrementally-updating model — emits begin/endInsertRows and begin/endRemoveRows so consumers patch the delta instead of rebuilding. Bind Repeater { model: Toplevels.model }.

◆ ~Toplevels()

PhosphorShell::Toplevels::~Toplevels ( )
override

Member Function Documentation

◆ create()

static Toplevels * PhosphorShell::Toplevels::create ( QQmlEngine *  engine,
QJSEngine *  scriptEngine 
)
static

QML-singleton factory hook.

◆ isSupported()

bool PhosphorShell::Toplevels::isSupported ( ) const

◆ model()

QAbstractListModel * PhosphorShell::Toplevels::model ( ) const

◆ toplevels()

QList< PhosphorWayland::ForeignToplevel * > PhosphorShell::Toplevels::toplevels ( ) const

◆ toplevelsChanged

void PhosphorShell::Toplevels::toplevelsChanged ( )
signal

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