pragma ComponentBehavior: Bound import QtQuick import QtQuick.Window import Quickshell import Quickshell.Io import Quickshell.Services.Notifications import Quickshell.Wayland import "../.." as N Scope { id: root property var readiness: [] property var completions: [] property string opened: "" property string vaultFocusedApp: "" property int vaultOpens: 0 property bool pasteFixtureVisible: false function recordReadiness(): void { root.readiness = root.readiness.concat([ { ready: niri.ready, windows: niri.windows.length, title: niri.focusedTitle } ]); } function tree(item: var): var { let items = [item]; for (const child of item.children || []) items = items.concat(tree(child)); return items; } function rect(item: var): var { const point = item.mapToItem(bar.contentItem, 0, 0); return { x: point.x, y: point.y, width: item.width, height: item.height }; } NotificationServer {} N.Theme { id: palette } N.Niri { id: niri onReadyChanged: Qt.callLater(root.recordReadiness) onScreenshotCaptured: path => root.completions = root.completions.concat([path]) } N.Clipboard { id: clipboard surfaces: surfaces niriService: niri } FloatingWindow { id: pasteWindow visible: root.pasteFixtureVisible title: "paste destination" implicitWidth: 480 implicitHeight: 240 color: palette.content.backdrop TextInput { id: pasteInput anchors.fill: parent anchors.margins: 20 color: palette.content.normal focus: true wrapMode: TextInput.Wrap } } N.Screenshots { id: captures niriService: niri } N.Vault { id: vault clipboardService: null function prepareOpen(appId) { root.vaultFocusedApp = String(appId); root.vaultOpens++; } } N.Time { id: clock } N.Format { id: format } N.Usage { id: usage snapshotted: true layoutOrder: ["vault", "clipboard"] } N.SurfaceManager { id: surfaces niriService: niri // Vault ends at its safe sink; clipboard exercises the real popup. function openRegisteredPopout(name) { root.opened = String(name); if (name === "clipboard") openPopout(name, "0,0,34,34", ""); } } N.Bar { id: bar theme: palette niriService: niri timeService: clock formatService: format usageService: usage surfaces: surfaces vaultService: vault orientation: "horizontal" resourceService: null notificationService: null trayService: null mediaService: null clipboardService: clipboard launcherService: null audioService: null brightnessService: null networkService: null bluetoothService: null powerService: null privilegeService: null idleService: null lockService: null nokoService: null caldavService: null } PanelWindow { id: history anchors { bottom: true left: true right: true } implicitHeight: 260 color: palette.content.backdrop WlrLayershell.layer: WlrLayer.Top WlrLayershell.keyboardFocus: WlrKeyboardFocus.None WlrLayershell.namespace: "niri-integration-history" Column { id: rows x: 18 y: 12 spacing: 6 Text { text: "native niri integration · " + (niri.ready ? "ready" : "disconnected") color: palette.ui.accent font.pixelSize: 18 } Text { text: "focus: " + niri.focusedTitle + " · " + niri.focusedAppId color: palette.content.normal } Text { text: "vault context: " + root.vaultFocusedApp color: palette.content.normal } Text { text: "saved: " + captures.recent.length + " · unconfirmed: " + captures.pending.length color: palette.content.normal } Repeater { model: captures.recent Text { required property var modelData text: modelData.kind + " · " + modelData.path color: palette.content.normal } } } } IpcHandler { target: "uiTest" function snapshot(): string { const subscription = Array.from(niri.data).find(child => child.command !== undefined && Array.from(child.command).includes("event-stream")); const pills = root.tree(bar.contentItem).filter(child => child.visible && child.idxStr !== undefined).map(child => ({ index: child.idxStr, name: child.nameStr, active: child.active, rect: root.rect(child) })); const vaultChip = root.tree(bar.contentItem).find(child => child.visible && child.popoutName === "vault"); const clipChip = root.tree(bar.contentItem).find(child => child.visible && child.popoutName === "clipboard"); const popup = Array.from(bar.data).find(child => child.activeName !== undefined); const popupItems = popup ? root.tree(popup.contentItem) : []; const search = popupItems.find(item => item.objectName === "searchField"); const paste = popupItems.find(item => item.objectName === "clipboardPaste"); let pasteRect = null; if (paste) { const point = paste.mapToItem(popup.contentItem, 0, 0); pasteRect = { x: point.x, y: point.y, width: paste.width, height: paste.height }; } return JSON.stringify({ niri: JSON.parse(niri.stateJson()), captures: captures.currentState(), subscriptionPid: subscription ? subscription.processId : null, qmlPid: Quickshell.processId, readiness: root.readiness, completions: root.completions, pills: pills, vault: { app: root.vaultFocusedApp, opens: root.vaultOpens, rect: vaultChip ? root.rect(vaultChip) : null, opened: root.opened }, paste: { chip: clipChip ? root.rect(clipChip) : null, button: pasteRect, open: surfaces.popoutOpen, target: surfaces.returnWindowId, searchFocused: !!search && search.input.activeFocus && !!popup.contentItem.Window.window && popup.contentItem.Window.window.active, queryPreserved: surfaces.panelStates.clipboard.query === "focus-safe", destinationMatches: pasteInput.text === "focus-safe paste", destinationEmpty: pasteInput.text.length === 0, destinationFocused: pasteInput.activeFocus, pending: clipboard.pendingPasteId.length > 0, focusAttempts: clipboard.pasteAttempts, focusReplyPresent: clipboard.focusReply.length > 0, error: clipboard.lastAction.error || "" }, text: root.tree(rows).filter(child => child.visible && child.text !== undefined).map(child => child.text) }); } function pasteFixture(): void { clipboard.captureClipboard("focus-safe paste"); root.pasteFixtureVisible = true; } function capture(kind: string, path: string): string { return captures.capture(kind, path); } function burst(): string { captures.capture("focused-screen", "/evidence/native-burst-screen.png"); captures.capture("focused-window", "/evidence/native-burst-window.png"); return captures.stateJson(); } function completeSelection(path: string): string { captures.beginSelection(100, 100); captures.updateSelection(500, 300); return captures.completeSelection(path); } function unavailable(): string { captures.niriService = null; const result = captures.capture("focused-screen", "/evidence/unavailable.png"); captures.niriService = niri; return result; } function fixtureOutputs(enabled: bool): bool { const query = Array.from(niri.data).find(child => child.command !== undefined && Array.from(child.command).includes("outputs")); if (!query) return false; query.environment = { NIRI_SOCKET: enabled ? Quickshell.env("XDG_RUNTIME_DIR") + "/niri.integration.sock" : Quickshell.env("NIRI_SOCKET") }; return true; } function clear(): void { captures.clear(); } } }