From d49ea0d0a6325fd0e8e4957962c7f97c30286cff Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 23 Sep 2026 20:38:19 -0400 Subject: [PATCH] faster render & hyprland support --- workspace-manager/Compositor.qml | 14 +++++++--- workspace-manager/Glass.qml | 46 +++++++++++++------------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/workspace-manager/Compositor.qml b/workspace-manager/Compositor.qml index 1cad2c4..c72407a 100644 --- a/workspace-manager/Compositor.qml +++ b/workspace-manager/Compositor.qml @@ -157,6 +157,14 @@ Item { return Number.isFinite(number) ? number : fallback; } + // Some Hyprland releases report a numeric "id", newer ones only a + // string "address" (numeric for ordinary workspaces). Accept either. + function hyprWorkspaceId(ws): int { + if (!ws) + return -1; + return root.asNumber(ws.id ?? ws.address, -1); + } + function parseOutputs(parsed): void { const layout = {}; if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) { @@ -217,7 +225,7 @@ Item { x: root.asNumber(mon.x, 0), y: root.asNumber(mon.y, 0), known: known, - activeId: root.asNumber(active.id, -1), + activeId: root.hyprWorkspaceId(active), monitorFocused: mon.focused === true }; } @@ -256,7 +264,7 @@ Item { continue; title = root.asString(w.title); app = root.asString(w.class); - id = root.asNumber(w.workspace?.id, -1); + id = root.hyprWorkspaceId(w.workspace); key = root.asString(w.address); captureId = root.asString(w.stableId); focused = root.asNumber(w.focusHistoryID, -1) === 0; @@ -302,7 +310,7 @@ Item { for (let i = 0; i < list.length; i++) { const ws = list[i]; - const id = root.asNumber(ws.id, -1); + const id = root.kind === "hyprland" ? root.hyprWorkspaceId(ws) : root.asNumber(ws.id, -1); if (root.kind === "hyprland" && id < 0) continue; diff --git a/workspace-manager/Glass.qml b/workspace-manager/Glass.qml index ff8e497..0a717cd 100644 --- a/workspace-manager/Glass.qml +++ b/workspace-manager/Glass.qml @@ -1,4 +1,5 @@ import QtQuick +import QtQuick.Effects // A see-through glass panel: a light tint, a soft shine over the top half, // a rim that catches the light along the top and a shadow underneath. @@ -19,6 +20,17 @@ Item { radius: root.radius color: root.selected ? root.theme.glassSelectedTint : root.tint antialiasing: true + + // A GPU shadow instead of a hand-drawn one, so it stays cheap even + // with many glass panels on screen and animating at once. + layer.enabled: root.shadow + layer.effect: MultiEffect { + shadowEnabled: true + shadowColor: root.theme.glassShadow + shadowVerticalOffset: root.theme.glassShadowOffset + shadowBlur: 1.0 + blurMax: root.theme.glassShadowBlur + } } // Shine over the top half, like light on curved glass. @@ -38,18 +50,16 @@ Item { } } - // The rim, bright at the top and fading down, and the shadow around - // the outside. Bigger than the panel so the shadow has room. + // The rim, bright at the top and fading down. No blur here, so this + // stays a small, cheap stroke. Canvas { id: edge - readonly property real margin: root.shadow ? root.theme.glassShadowBlur + root.theme.glassShadowOffset : 0 readonly property color rimTop: root.selected ? root.theme.fieldBorder : root.theme.glassRimTop readonly property color rimBottom: root.selected ? root.theme.glassSelectedRimBottom : root.theme.glassRimBottom readonly property real rimWidth: root.selected ? 2 : 1 anchors.fill: parent - anchors.margins: -edge.margin onWidthChanged: edge.requestPaint() onHeightChanged: edge.requestPaint() @@ -60,40 +70,20 @@ Item { onPaint: { const ctx = edge.getContext("2d"); ctx.reset(); - const m = edge.margin; - const w = root.width; - const h = root.height; + const w = edge.width; + const h = edge.height; const r = Math.min(root.radius, w / 2, h / 2); if (w <= 0 || h <= 0) return; - if (root.shadow) { - ctx.save(); - ctx.shadowColor = root.theme.glassShadow; - ctx.shadowBlur = root.theme.glassShadowBlur; - ctx.shadowOffsetY = root.theme.glassShadowOffset; - ctx.fillStyle = "black"; - ctx.beginPath(); - ctx.roundedRect(m, m, w, h, r, r); - ctx.fill(); - ctx.restore(); - // Clear the panel itself, so the shadow only shows outside - // and the glass stays see-through. - ctx.globalCompositeOperation = "destination-out"; - ctx.beginPath(); - ctx.roundedRect(m, m, w, h, r, r); - ctx.fill(); - ctx.globalCompositeOperation = "source-over"; - } - const half = edge.rimWidth / 2; - const rim = ctx.createLinearGradient(0, m, 0, m + h); + const rim = ctx.createLinearGradient(0, 0, 0, h); rim.addColorStop(0, edge.rimTop); rim.addColorStop(1, edge.rimBottom); ctx.strokeStyle = rim; ctx.lineWidth = edge.rimWidth; ctx.beginPath(); - ctx.roundedRect(m + half, m + half, w - edge.rimWidth, h - edge.rimWidth, r - half, r - half); + ctx.roundedRect(half, half, w - edge.rimWidth, h - edge.rimWidth, r - half, r - half); ctx.stroke(); } }