pragma Singleton import QtQuick import Quickshell import Quickshell.Hyprland Singleton { id: root readonly property var visibleWorkspaces: Hyprland.workspaces.values.filter(w => w.active).map(w => w.id) readonly property var windows: Hyprland.toplevels.values.map(t => { const info = t.lastIpcObject || {}; return { address: t.address, handle: t.wayland, appId: t.wayland ? t.wayland.appId : info.class || "", initialClass: info.initialClass || "", title: t.title, active: t.activated, monitor: t.monitor ? t.monitor.name : "", workspace: t.workspace ? t.workspace.id : 0, x: info.at ? info.at[0] : 0, y: info.at ? info.at[1] : 0, width: info.size ? info.size[0] : 0, height: info.size ? info.size[1] : 0, hidden: info.hidden === true || info.mapped === false, fullscreen: info.fullscreen === 2, floating: info.floating === true }; }).filter(w => !w.hidden) // Monitors whose desktop is hidden: a tiled or fullscreen window sits on // their active workspace. Desktop widgets pause animation and sampling there. readonly property var coveredMonitors: windows.filter(w => visibleWorkspaces.includes(w.workspace) && (!w.floating || w.fullscreen)).map(w => w.monitor) readonly property bool needsGeometry: ConfigService.ready && ConfigService.data.dock.enabled && ConfigService.data.dock.visibility === "intelligent" function focusWindow(address) { const window = windows.find(w => w.address === address); if (!window) return false; if (window.handle) window.handle.activate(); else if (/^(0x)?[0-9a-f]+$/i.test(address)) Hyprland.dispatch("focuswindow address:" + (address.startsWith("0x") ? address : "0x" + address)); else return false; return true; } function closeWindow(address) { const window = windows.find(w => w.address === address); if (!window) return false; if (window.handle) window.handle.close(); else if (/^(0x)?[0-9a-f]+$/i.test(address)) Hyprland.dispatch("closewindow address:" + (address.startsWith("0x") ? address : "0x" + address)); else return false; return true; } // Native IPC, not subprocess polling. Hyprland emits no continuous resize event. Timer { interval: 500 repeat: true running: root.needsGeometry triggeredOnStart: true onTriggered: Hyprland.refreshToplevels() } }