pragma Singleton import QtQuick import Quickshell import Quickshell.Io import "../services" import "../core" Singleton { id: root property bool opened: false property bool chooser: false property string appId: "" property Item anchorItem: null property var docks: [] property var icons: [] property var menuWindow: null property string draggingId: "" readonly property var group: DockModel.find(appId) onGroupChanged: if (!group) close() function open(id, item, windowsOnly) { if (!DockModel.find(id)) return; TrayService.close(); ShellState.controlCenterOpen = false; ShellState.launcherOpen = false; ShellState.settingsOpen = false; appId = id; anchorItem = item; chooser = windowsOnly; opened = true; } function close() { opened = false; } function click(id, item) { const group = DockModel.find(id); if (!group) return; if (!group.windows.length) { if (!ApplicationsService.launch(group.entry, null)) ShellState.openSettings("dock"); } else if (group.windows.length === 1) HyprlandService.focusWindow(group.windows[0].address); else open(id, item, true); } function removeIcon(icon) { if (anchorItem === icon) close(); icons = icons.filter(i => i !== icon); } Connections { target: ShellState function onControlCenterOpenChanged() { if (ShellState.controlCenterOpen) root.close(); } function onLauncherOpenChanged() { if (ShellState.launcherOpen) root.close(); } function onSettingsOpenChanged() { if (ShellState.settingsOpen) root.close(); } } Connections { target: TrayService function onOpenedChanged() { if (TrayService.opened) root.close(); } } IpcHandler { target: "dock" function status(): string { return JSON.stringify({ items: DockModel.items.map(i => ({ id: i.id, pinned: i.pinned, running: i.windows.length, focused: i.focused, matched: !!i.entry })), opened: root.opened, chooser: root.chooser, docks: root.docks.map(d => ({ screen: d.screen.name, shown: d.shown, position: d.position, overlap: d.overlap, width: d.width, height: d.height })), error: ApplicationsService.error }); } function pin(id: string): bool { return DockModel.pin(id); } function unpin(id: string): bool { return DockModel.unpin(id); } function move(source: string, target: string): bool { return DockModel.reorder(source, target); } function settings(): void { ShellState.openSettings("dock"); } } }