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; shells should hide their taskbar UI in that case rather than showing an empty placeholder. The wlroots family (sway, Hyprland, Niri, river, labwc) supports it. Mutter does not, and neither does KWin (6.8 offers org_kde_plasma_window_management instead), so on both supported stays false.
| 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 }. The toplevel the compositor currently reports as activated, or null when nothing is (the bare desktop, or a compositor that does not advertise the protocol).
The protocol has no "which one is active" event — activation is a per-toplevel state flag — so anything that wants the focused window must watch every toplevel's stateChanged and re-scan. Doing that in QML costs a hidden delegate per window in every consuming widget; doing it once here costs one connection per toplevel for the whole process.