QML singleton exposing the live list of toplevel windows for taskbars. More...
#include <phosphor-shell/include/PhosphorShell/Toplevels.h>
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 Toplevels * | create (QQmlEngine *engine, QJSEngine *scriptEngine) |
| QML-singleton factory hook. | |
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.
|
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 }.
|
override |
|
static |
QML-singleton factory hook.
| bool PhosphorShell::Toplevels::isSupported | ( | ) | const |
| QAbstractListModel * PhosphorShell::Toplevels::model | ( | ) | const |
| QList< PhosphorWayland::ForeignToplevel * > PhosphorShell::Toplevels::toplevels | ( | ) | const |
|
signal |