import Quickshell import Quickshell.Io import QtQuick import qs.modules.settings import qs.services ShellRoot { DisplayIdentify {} QtObject { id: fixtureService property var monitors: [ { name: "DP-2", description: "Primary display", width: 4500, height: 3000, refreshRate: 60, mode: "4500x3000@60.00", scale: 1.5, transform: 0, x: 0, y: 0, primary: true }, { name: "HDMI-A-1", description: "Second display", width: 2560, height: 1440, refreshRate: 60, mode: "2560x1440@60.00", scale: 1, transform: 0, x: 3000, y: 0, primary: false } ] property var applied: [] function currentLayout(): var { return monitors.map(record => Object.assign({}, record)); } function applyLayout(layout: var): bool { applied = layout.map(record => Object.assign({}, record)); return true; } } DisplayArrangement { id: arrangement width: 800 displayService: fixtureService selectedOutput: "HDMI-A-1" } IpcHandler { target: "display-arrangement-test" function status(width: int): string { arrangement.width = width; arrangement.resetDraft(); return JSON.stringify(arrangement.canvasSnapshot()); } function dragFixture(): string { arrangement.resetDraft(); arrangement.setDraftPosition("HDMI-A-1", 3016, 0, true); arrangement.applyDraft(); return JSON.stringify(fixtureService.applied); } function keyboardFixture(): string { arrangement.resetDraft(); arrangement.nudge("HDMI-A-1", -10, 0); const afterArrow = arrangement.draftLayout.find(record => record.name === "HDMI-A-1").x; arrangement.nudge("HDMI-A-1", -100, 0); const afterShiftArrow = arrangement.draftLayout.find(record => record.name === "HDMI-A-1").x; return JSON.stringify({ afterArrow, afterShiftArrow }); } function primaryFixture(): string { arrangement.resetDraft(); arrangement.makePrimary("HDMI-A-1"); return JSON.stringify(fixtureService.applied.map(record => ({ name: record.name, x: record.x, y: record.y, primary: record.primary }))); } // One display is the common case on a laptop, and the canvas is the // page's hero now: it renders that display rather than disappearing and // leaving a picker for a list of one. Only dragging goes away, because // there is nothing to arrange it against. function soloFixture(): string { const previous = fixtureService.monitors; fixtureService.monitors = [previous[0]]; arrangement.resetDraft(); const snapshot = arrangement.canvasSnapshot(); fixtureService.monitors = previous; arrangement.resetDraft(); return JSON.stringify(snapshot); } // A mirrored display has no position of its own -- the compositor puts // it on top of its target -- so the canvas stacks it there and says so // rather than drawing it wherever its stale coordinates point. function mirrorFixture(): string { const previous = fixtureService.monitors; fixtureService.monitors = [ previous[0], Object.assign({}, previous[1], { mirrorOf: "DP-2" }) ]; arrangement.resetDraft(); const snapshot = arrangement.canvasSnapshot(); fixtureService.monitors = previous; arrangement.resetDraft(); return JSON.stringify(snapshot); } function identify(): void { Displays.identify(); } function identifying(): bool { return Displays.identifying; } } }