import Quickshell import Quickshell.Wayland import QtQuick import qs.config import qs.services // Middle section: one button per open window. // // Two sources, because no one protocol does the job everywhere: // // - wlr-foreign-toplevel-management, which works on any wlroots-based // compositor without talking to a single window manager's IPC. // - attwm's socket, whenever it answers. Under river 0.4 the foreign-toplevel // protocol can list windows but cannot focus one — see services/Attwm.qml — // and its window ids are what make the click land on the right window. Item { id: root required property var bar readonly property bool attwm: Attwm.available readonly property string screenName: root.bar.screen ? root.bar.screen.name : "" readonly property var windows: { if (root.attwm) { if (!Config.windowsPerScreen) return Attwm.allWindows; // attwm reports windows under the output they are on, so no // filtering is needed — and none of them is screenless. const out = Attwm.outputFor(root.screenName); return out ? out.windows : []; } const all = [...ToplevelManager.toplevels.values]; if (!Config.windowsPerScreen) return all; // A toplevel with no reported screens yet is still shown, otherwise // freshly mapped windows would flicker in late. return all.filter(t => t.screens.length === 0 || t.screens.some(s => s && s.name === root.screenName)); } ListView { id: list anchors.fill: parent orientation: ListView.Horizontal spacing: Theme.spacing clip: true boundsBehavior: Flickable.StopAtBounds model: ScriptModel { values: root.windows // Toplevels are long-lived objects and diff by identity. attwm's // are plain objects re-parsed on every state change, so they need a // key, or each title change would rebuild every delegate. objectProp: root.attwm ? "id" : "" } delegate: WindowButton { required property var modelData win: modelData attwm: root.attwm height: list.height - Theme.spacing anchors.verticalCenter: parent ? parent.verticalCenter : undefined } } }