Files
glassMxrph/quickshell/dock/DockState.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

113 lines
3.3 KiB
QML

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");
}
}
}