From a05bf99210e6c4d131a21b200b52e88fe7586a37 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 16 Nov 2026 13:33:07 +0100 Subject: [PATCH] Show the launcher on outputs scaled below 1 --- tests/content-ready.test.js | 44 +++++++++++++++++++++++++++++++++++++ ui/LauncherWindow.qml | 4 +++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/content-ready.test.js diff --git a/tests/content-ready.test.js b/tests/content-ready.test.js new file mode 100644 index 0000000..d5123e3 --- /dev/null +++ b/tests/content-ready.test.js @@ -0,0 +1,44 @@ +const test = require("node:test") +const assert = require("node:assert/strict") +const fs = require("node:fs") +const path = require("node:path") + +const source = fs.readFileSync(path.join(__dirname, "../ui/LauncherWindow.qml"), "utf8") + +// The binding is plain JavaScript over `window`, so node can evaluate it as is. +// Sample: "readonly property bool contentReady: window.shown && …\n property bool contentRevealed". +function contentReady(window) { + const match = source.match(/readonly property bool contentReady: ([\s\S]*?)\n property bool contentRevealed/) + assert.ok(match, "missing contentReady binding") + const expression = match[1].split("\n").filter(line => !line.trim().startsWith("//")).join("\n") + return new Function("window", "return " + expression)(window) +} + +function shownOn(scale, devicePixelRatio) { + const screen = { name: "HDMI-A-1", width: 2400, height: 1350 } + return { + shown: true, + screen, + targetMonitor: { name: screen.name, scale }, + width: screen.width, + height: screen.height, + devicePixelRatio, + } +} + +test("content is revealed once Qt has the output's scale", () => { + assert.equal(contentReady(shownOn(1.6, 1)), false) + assert.equal(contentReady(shownOn(1.6, 1.6)), true) + assert.equal(contentReady(shownOn(1.25, 1.25)), true) +}) + +// Seen on a 1920x1080 output at scale 0.8: Qt keeps devicePixelRatio at 1. +test("content is revealed on an output scaled below 1", () => { + assert.equal(contentReady(shownOn(0.8, 1)), true) + assert.equal(contentReady(shownOn(0.5, 1)), true) +}) + +test("content stays hidden until the surface has the output's size", () => { + assert.equal(contentReady({ ...shownOn(0.8, 1), width: 1920 }), false) + assert.equal(contentReady({ ...shownOn(1, 1), shown: false }), false) +}) diff --git a/ui/LauncherWindow.qml b/ui/LauncherWindow.qml index 1071842..58feb78 100644 --- a/ui/LauncherWindow.qml +++ b/ui/LauncherWindow.qml @@ -217,7 +217,9 @@ PanelWindow { } readonly property bool contentReady: window.shown && !!window.screen && !!window.targetMonitor && window.width === window.screen.width && window.height === window.screen.height - && Math.round(window.devicePixelRatio * 120) === Math.round(window.targetMonitor.scale * 120) + // Qt keeps devicePixelRatio at 1 on an output scaled below 1 (0.8 here), so + // the plain comparison never held there and the card stayed invisible. + && Math.round(window.devicePixelRatio * 120) === Math.round(Math.max(1, window.targetMonitor.scale) * 120) property bool contentRevealed: false onContentReadyChanged: { window.contentRevealed = false