Files
glassMxrph/quickshell/testing/TrayDriver.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

66 lines
3.5 KiB
QML

import QtQuick
import QtTest
import Quickshell
import Quickshell.Io
import "../core"
import "../services"
Item {
id: root
parent: TrayService.windows.length ? TrayService.windows[0].contentItem : null
function icon(id, monitor) { return TrayService.icons.find(i => i.trayItem.id === id && (!monitor || i.barScreen.name === monitor)); }
function menu(depth) { return TrayService.windows.find(w => w.visible && w.depth === depth); }
TestCase { id: input; name: "TrayInputDriver"; when: false }
IpcHandler {
target: "trayTest"
function screens(): string { return JSON.stringify(Quickshell.screens.map(s => s.name)); }
function hover(id: string, monitor: string): bool {
const icon = root.icon(id, monitor); if (!icon) return false;
input.mouseMove(icon, icon.width / 2, icon.height / 2); return true;
}
function leave(id: string, monitor: string): bool {
const icon = root.icon(id, monitor); if (!icon) return false;
input.mouseMove(icon.containingWindow.contentItem, 2, 2); return true;
}
function click(id: string, button: int): bool {
const icon = root.icon(id, ""); if (!icon) return false;
input.mouseClick(icon, icon.width / 2, icon.height / 2, button); return true;
}
function row(depth: int, index: int, click: bool): bool {
const menu = root.menu(depth); if (!menu) return false;
// Rows of a drawer are only clickable once revealed.
const surface = input.findChild(menu.contentItem, "trayMenuSurface");
for (let i = 0; i < 40 && surface && surface.settled === false; i++) input.wait(25);
const list = input.findChild(menu.contentItem, "trayMenuList");
list.positionViewAtIndex(index, ListView.Contain);
const item = list.itemAtIndex(index); if (!item) return false;
if (click) input.mouseClick(item, item.width / 2, item.height / 2);
else input.mouseMove(item, item.width / 2, item.height / 2);
return true;
}
// Bar modules by objectName, e.g. the active window pill.
function hoverModule(name: string): bool {
const bar = TrayService.barWindows[0]; if (!bar) return false;
const item = input.findChild(bar.contentItem, name); if (!item) return false;
input.mouseMove(item, item.width / 2, item.height / 2); return true;
}
function leaveBar(): bool {
for (const bar of TrayService.barWindows) input.mouseMove(bar.contentItem, 2, 2);
return TrayService.barWindows.length > 0;
}
function popoutScreenshot(path: string): bool {
if (!PopoutState.window) return false;
return input.findChild(PopoutState.window.contentItem, "barPopoutSurface").grabToImage(result => result.saveToFile(path));
}
function probe(id: string): string {
const icon = root.icon(id, "");
const w = icon ? icon.containingWindow : null;
return JSON.stringify({inside: !!icon && icon.pointerInside, screen: icon ? icon.barScreen.name : "", active: !!w && w.active, grabber: !!w && !!w.mouseGrabberItem});
}
function pressEscape(): void { input.keyClick(Qt.Key_Escape); }
function screenshot(path: string): bool {
const menu = root.menu(0); if (!menu) return false;
return input.findChild(menu.contentItem, "trayMenuSurface").grabToImage(result => result.saveToFile(path));
}
}
}