Files
glassMxrph/quickshell/dock/DockState.qml
T
mxandClaude Opus 5.5 9aa61559eb Fix stray dock items and orphaned Cava
Windows whose class is a respelling of their desktop entry's
StartupWMClass (YouTube Music: "youtube-music-desktop-app" vs
"YouTube Music Desktop App") showed as separate unknown dock items.
Matching now falls back to comparing names with case and space, dash
and underscore runs normalized; ambiguous or partial names still never
match.

Quickshell fills a toplevel's IPC data only at startup, so windows
opened later lacked their initial class, mapped/hidden state and
floating flag. HyprlandService now runs one `hyprctl -j clients` query
per burst of window open/close/move/float/fullscreen/group events
(none for title changes, none while idle). Windows with neither IPC
data nor a foreign-toplevel handle are treated as unmapped. dock status
reports each item's window classes for diagnosis.

The Cava helper sets a parent-death signal before exec: Cava writes
nothing during silence, so it outlived a killed or crashed shell.

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

115 lines
3.6 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,
// Diagnoses unmatched items: what each window reported.
classes: i.windows.map(w => w.appId + (w.initialClass && w.initialClass !== w.appId ? " (" + w.initialClass + ")" : ""))
})),
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");
}
}
}