From 6d260ab4bdc55a7be6a0759702800e7d34dd8cc3 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Wed, 11 Nov 2026 09:55:59 +0100 Subject: [PATCH 1/3] omamobile-shell 0.2.120: recent apps keep each window's last picture, and copy live only the middle card A recent-apps card copied its window live through Hyprland's toplevel capture, and showed nothing until the window gave a frame. Every app sits on a screen of its own, and Hyprland hands a frame over only when the window draws: a still page (the Settings app's About list) gave none, so its card stayed empty until something on the page changed. A capture Hyprland fails ends for good ("Ending recording due to screencopy failure", eight times in one morning on the 9a), and the card stays empty until recent apps are opened again. And every card was rebuilt, empty, when another window closed. - Each card keeps its window's last frame as a still, at the card's size (grabToImage, so a few hundred kilobytes each), and shows it until its capture has a frame. The stills live on the switcher, not on the cards, so a rebuilt card has its picture at once; a window that closes takes its still with it (SwitcherModel.js: stillOf, withStill, prunedStills). - Only the card in the middle copies live; the others copy one frame each. Before, every open window was captured live at the screen's size while recent apps were open. - A capture that stops is started again a second later, three times at most while recent apps are open. Tests: test/switcher-model.js (the stills), and in test/switcher-touch the middle card live and its neighbours not, the still shown while the capture has no frame and gone with its window, and the retries. The ScreencopyView stub gains hasContent, a stopped signal and a colour. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-shell/README.md | 2 +- .../plugins/omamobile.switcher/Switcher.qml | 68 ++++++++++++++++++- .../omamobile.switcher/SwitcherModel.js | 23 ++++++- .../Quickshell/Wayland/ScreencopyView.qml | 14 ++++ .../omamobile-shell/test/switcher-model.js | 17 +++++ .../omamobile-shell/test/switcher-touch.qml | 68 +++++++++++++++++++ packages/omamobile-shell/version | 2 +- 7 files changed, 188 insertions(+), 6 deletions(-) diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index 71f4ac874..541518b43 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -7,7 +7,7 @@ Omarchy Mobile's phone profile for Omarchy's own shell. It isn't a fork: these a | `plugins/omamobile.bar` | Phone status bar (a full `bar` plugin) | | `plugins/omamobile.quicksettings` | Pull-down quick settings | | `plugins/omamobile.launcher` | Home bar: app search, app grid and a prompt to the user's Omarchy default agent; over an app, the home pill in a 44 px strip that reserves its height, so apps end above it (as on Android it is just the pill: double-tap for the keyboard, hold for the voice bar) | -| `plugins/omamobile.switcher` | Recent apps: swipe up on the dock, or swipe up and hold on the home pill over an app; hold a card to show the app with another one, or give it its own screen again | +| `plugins/omamobile.switcher` | Recent apps: swipe up on the dock, or swipe up and hold on the home pill over an app; hold a card to show the app with another one, or give it its own screen again. The middle card copies its window live, the others one frame each, and each card keeps its window's last picture for when the capture has none | | `plugins/omamobile.home` | Home screens: pages of apps and widgets on the wallpaper, with an edit mode. The built-ins include every widget in Simon Schubert's [omarchy-widgets](https://github.com/SimonSchubert/omarchy-widgets) `widgets/simonschubert/` (MIT): the OWL originals, from the `omamobile-owl-widgets` package, run by our own OWL runtime (`owl/`, see `owl/SPEC-NOTES.md`). `widgets/OWL.md` is his OWL language guide (MIT, `widgets/LICENSE-owl-guide`) | | `plugins/omamobile.keyboard` | The on-screen keyboard's show and hide calls, for the home pill (double-tap it), the keyboard's Hide key and scripts; a keyboard shown by hand goes away when the home screen comes up; the language sheet for the keyboard's globe key | | `squeekboard/keyboards/` | squeekboard's layouts (GPL-3.0-or-later, portrait and landscape) with an action row of Mic, Paste, Emoji and Hide, XF86 keysyms that `hypr/phone.lua` binds for squeekboard's virtual keyboard only (docs/VOICE-PLAN.md): the US terminal layout by hand, every language's (and the email and URL layouts) made from squeekboard 1.43.1's own by `squeekboard/generate`; `squeekboard/generate --check` (in `test/all`) proves each is upstream's plus the row and the globe key, which sends `XF86MediaLanguageMenu` (the language sheet) instead of opening squeekboard's popover | diff --git a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml index 7a48e2565..1b5556d34 100644 --- a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml @@ -10,7 +10,7 @@ import qs.Ui import "Readable.js" as Readable import "SwitcherModel.js" as SwitcherModel -// Recent apps, after Android: every open window as a card with a live +// Recent apps, after Android: every open window as a card with a // preview. Swipe sideways through them, tap one to switch to it, flick it up // to close it. Home shows the home screen (an empty workspace) and leaves the // apps open. Summoned by swiping up on the dock (omamobile.launcher). @@ -20,6 +20,13 @@ import "SwitcherModel.js" as SwitcherModel // app's screen, where the two tile as Omarchy tiles them, and "Move to its // own screen" gives it one back. // +// The card in the middle copies its window live, the others one frame each. +// Each card also keeps its window's last picture (a still, at the card's +// size) and shows it until its capture has a frame: an app sits on a screen +// of its own, and one that draws nothing there gives Hyprland nothing to +// copy, so its card stayed empty, and so did every card rebuilt after +// another window closed. +// // On its side (TOUCH-PLAN 2.4: 1040x480) a card keeps the screen's shape, // so its preview isn't stretched, and the bottom actions keep their row. // @@ -49,6 +56,18 @@ Item { return list } + // Each open window's last picture (SwitcherModel's stills); a window that + // closed takes its still with it. + property var stills: [] + onWindowsChanged: stills = SwitcherModel.prunedStills(stills, windows) + function keepStill(toplevel, result) { + if (windows.indexOf(toplevel) >= 0) stills = SwitcherModel.withStill(stills, toplevel, result) + } + function stillUrl(toplevel) { + var still = SwitcherModel.stillOf(stills, toplevel) + return still && still.url ? still.url : "" + } + // Host lifecycle (`shell summon` / `shell hide`). function open(payloadJson) { opened = true @@ -339,6 +358,30 @@ Item { width: cards.cardWidth height: cards.height + // A capture Hyprland fails ends for good ("Ending recording due to + // screencopy failure"): start it again a second later, three times + // at most while recent apps are open. + property bool resting: false + property int retries: 0 + Timer { + id: retry + interval: 1000 + onTriggered: slot.resting = false + } + Connections { + target: root + function onOpenedChanged() { slot.retries = 0; slot.resting = false } + } + + // The capture's frame as this window's still, at the card's size. + function keepStill() { + if (!capture.hasContent || capture.width <= 0 || capture.height <= 0) return + var w = slot.modelData + capture.grabToImage(function(result) { root.keepStill(w, result) }, + Qt.size(Math.round(capture.width * Screen.devicePixelRatio), + Math.round(capture.height * Screen.devicePixelRatio))) + } + // The app's name, one line, centred over the card. Text { id: title @@ -372,11 +415,30 @@ Item { border.color: Qt.rgba(root.foreground.r, root.foreground.g, root.foreground.b, 0.25) opacity: 1 - Math.min(0.8, Math.abs(drag.lift) / height) + // The window's still from an earlier frame, until the capture has one. + Image { + objectName: "cardStill" + anchors.fill: parent + anchors.margins: card.border.width + visible: !capture.hasContent && status === Image.Ready + source: root.stillUrl(slot.modelData) + cache: false + } + ScreencopyView { + id: capture + objectName: "cardCapture" anchors.fill: parent anchors.margins: card.border.width - captureSource: root.opened ? slot.modelData : null - live: true + captureSource: root.opened && !slot.resting ? slot.modelData : null + live: slot.ListView.isCurrentItem + onHasContentChanged: if (hasContent) Qt.callLater(slot.keepStill) + onStopped: { + if (!root.opened || slot.resting || slot.retries >= 3) return + slot.retries++ + slot.resting = true + retry.restart() + } } // Tap to switch; hold for "Show with…" and "Move to its own screen". diff --git a/packages/omamobile-shell/plugins/omamobile.switcher/SwitcherModel.js b/packages/omamobile-shell/plugins/omamobile.switcher/SwitcherModel.js index 0caa1f05f..d2eeff343 100644 --- a/packages/omamobile-shell/plugins/omamobile.switcher/SwitcherModel.js +++ b/packages/omamobile-shell/plugins/omamobile.switcher/SwitcherModel.js @@ -127,6 +127,27 @@ function appName(appId, title, entries) { return c || "App" } +// Recent apps' stills: the last picture of each open window, as a list of +// { window, still } pairs (a window is the toplevel object itself, so the +// pair goes when the window does). A card shows its window's still until its +// own capture has a frame. +function stillOf(stills, w) { + for (var i = 0; i < (stills || []).length; i++) + if (stills[i].window === w) return stills[i].still + return null +} + +function withStill(stills, w, still) { + var out = (stills || []).filter(function(s) { return s.window !== w }) + out.push({ window: w, still: still }) + return out +} + +function prunedStills(stills, windows) { + return (stills || []).filter(function(s) { return (windows || []).indexOf(s.window) >= 0 }) +} + if (typeof module !== "undefined") { - module.exports = { entryFor: entryFor, appName: appName, webAppKey: webAppKey, webAppUrl: webAppUrl } + module.exports = { entryFor: entryFor, appName: appName, webAppKey: webAppKey, webAppUrl: webAppUrl, + stillOf: stillOf, withStill: withStill, prunedStills: prunedStills } } diff --git a/packages/omamobile-shell/test/qml-stubs/Quickshell/Wayland/ScreencopyView.qml b/packages/omamobile-shell/test/qml-stubs/Quickshell/Wayland/ScreencopyView.qml index 16ca80990..a3375ae84 100644 --- a/packages/omamobile-shell/test/qml-stubs/Quickshell/Wayland/ScreencopyView.qml +++ b/packages/omamobile-shell/test/qml-stubs/Quickshell/Wayland/ScreencopyView.qml @@ -1,7 +1,21 @@ // SPDX-License-Identifier: MIT import QtQuick +// A capture that never gets a frame until a test says so (hasContent), and +// then paints its window's colour (a test window's `colour`, else grey). +// Without a source it has no frame, as Quickshell's drops its context. Item { property var captureSource: null property bool live: false + property bool hasContent: false + // Quickshell's ends a recording Hyprland fails and says so. + signal stopped() + property int starts: 0 + function captureFrame() {} + onCaptureSourceChanged: if (!captureSource) hasContent = false; else starts++ + Rectangle { + anchors.fill: parent + visible: parent.hasContent + color: parent.captureSource && parent.captureSource.colour !== undefined ? parent.captureSource.colour : "grey" + } } diff --git a/packages/omamobile-shell/test/switcher-model.js b/packages/omamobile-shell/test/switcher-model.js index bd08d31a5..ce335cddd 100644 --- a/packages/omamobile-shell/test/switcher-model.js +++ b/packages/omamobile-shell/test/switcher-model.js @@ -72,6 +72,23 @@ test("no entry: the title, then the class, then App", () => { assert.strictEqual(M.appName("x", "t", [{ id: "x", name: "" }]), "t", "an entry with no name") }) +test("stills: one per window, replaced, and gone with the window", () => { + const a = { title: "a" }, b = { title: "b" } + let stills = [] + assert.strictEqual(M.stillOf(stills, a), null) + stills = M.withStill(stills, a, "a1") + stills = M.withStill(stills, b, "b1") + stills = M.withStill(stills, a, "a2") + assert.strictEqual(stills.length, 2, "a's newer still replaces its older one") + assert.strictEqual(M.stillOf(stills, a), "a2") + assert.strictEqual(M.stillOf(stills, b), "b1") + assert.strictEqual(M.stillOf(stills, { title: "a" }), null, "by the window itself, not by its title") + stills = M.prunedStills(stills, [b]) + assert.deepStrictEqual(stills.map(s => s.still), ["b1"], "a closed window loses its still") + assert.deepStrictEqual(M.prunedStills(null, [a]), []) + assert.strictEqual(M.stillOf(undefined, a), null) +}) + let failed = 0 for (const [name, fn] of tests) { try { fn(); console.log("ok - switcher model: " + name) } catch (e) { failed++; console.log("not ok - switcher model: " + name + "\n " + (e.stack || e)) } diff --git a/packages/omamobile-shell/test/switcher-touch.qml b/packages/omamobile-shell/test/switcher-touch.qml index 0ad4e9f9b..b267bffc4 100644 --- a/packages/omamobile-shell/test/switcher-touch.qml +++ b/packages/omamobile-shell/test/switcher-touch.qml @@ -324,6 +324,74 @@ Item { tryVerify(function() { return test.offCentre(cards) < 1 }, 2000, "centred") } + // Every card's capture, newest window first. + function captures() { + var out = [] + function walk(item) { + if (item.objectName === "cardCapture") out.push(item) + for (var i = 0; i < item.children.length; i++) walk(item.children[i]) + } + walk(cardsList().contentItem) + return out.sort(function(p, q) { return sw.windows.indexOf(p.captureSource) - sw.windows.indexOf(q.captureSource) }) + } + + function stillOf(capture) { + var kids = capture.parent.children + for (var i = 0; i < kids.length; i++) if (kids[i].objectName === "cardStill") return kids[i] + return null + } + + // Only the card in the middle copies live; a card whose window gives no + // frame shows the still from its last frame, and a window that closes + // takes its still with it. + function test_cards_keep_a_still_until_the_capture_has_a_frame() { + var a = fakeWindow.createObject(top, { appId: "a" }), b = fakeWindow.createObject(top, { appId: "b" }) + openWith([a, b]) // newest first: b, a + var cards = cardsList() + tryVerify(function() { return cards.count === 2 && captures().length === 2 }) + var caps = captures() + compare(caps[0].captureSource, b) + verify(caps[0].live, "the centred card is live") + verify(!caps[1].live, "its neighbour copies one frame") + verify(!stillOf(caps[0]).visible, "no still yet") + + caps[0].hasContent = true + tryVerify(function() { return sw.stillUrl(b) !== "" }, 3000, "b's frame kept as its still") + compare(sw.stillUrl(a), "", "a gave no frame") + + // Next time b's window gives nothing (it drew nothing off screen): its still. + sw.close() + tryVerify(function() { return !overlay.visible }) + openWith([a, b]) + tryVerify(function() { return captures().length === 2 }) + var again = captures()[0] + compare(again.captureSource, b) + verify(!again.hasContent) + tryVerify(function() { return stillOf(again).visible }, 3000, "b's still while its capture has no frame") + again.hasContent = true + tryVerify(function() { return !stillOf(again).visible }, 2000, "the live frame once there is one") + + top.drop(b) + tryVerify(function() { return sw.stills.length === 0 }, 2000, "a closed window loses its still") + } + + // A failed capture starts again a second later, three times at most. + function test_a_failed_capture_starts_again() { + var a = fakeWindow.createObject(top, { appId: "a" }) + openWith([a]) + tryVerify(function() { return captures().length === 1 }) + var cap = captures()[0] + var first = cap.starts + cap.stopped() + tryVerify(function() { return cap.captureSource === null }, 1000, "resting after the failure") + tryVerify(function() { return cap.captureSource === a && cap.starts === first + 1 }, 3000, "started again") + cap.stopped(); tryVerify(function() { return cap.starts === first + 2 }, 3000) + cap.stopped(); tryVerify(function() { return cap.starts === first + 3 }, 3000) + cap.stopped(); wait(1500) + compare(cap.starts, first + 3, "no fourth try") + compare(cap.captureSource, a, "and the capture stays on its window") + } + // A window that gets its size after it is shown still opens centred. function test_centred_after_a_resize() { var a = fakeWindow.createObject(top), b = fakeWindow.createObject(top, { appId: "chromium" }) diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index dc67b3691..07c01eb66 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.118 +0.2.120 From b5080fb109f7e92ba8f41c474d3b2e3ea803365f Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Wed, 11 Nov 2026 10:21:59 +0100 Subject: [PATCH 2/3] omamobile-shell 0.2.120: recent apps copy every card live again The first commit copied only the middle card live and its neighbours one frame each, to save work. Measured on the 9a with five windows (recent apps open, swiped through every card, 8 s of CPU time and the dma-buf total from debugfs): the shell's CPU was 31.8 % before and 32.9 % after, and the dma-bufs 239 MB before and 235 MB after. A neighbour that copies one frame still holds its buffer, and an idle window is copied only when it draws, so nothing measurable was saved, and the neighbours lost their live picture. Back to every card live. What stays: a stopped capture starts again (Quickshell ends a recording for good when Hyprland fails one, "Ending recording due to screencopy failure", three times in the second of the owner's empty card), and each card keeps its window's last frame as a still for when its capture has none. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-shell/README.md | 2 +- .../plugins/omamobile.switcher/Switcher.qml | 14 ++++++-------- packages/omamobile-shell/test/switcher-touch.qml | 7 ++----- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index 541518b43..23bb86dff 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -7,7 +7,7 @@ Omarchy Mobile's phone profile for Omarchy's own shell. It isn't a fork: these a | `plugins/omamobile.bar` | Phone status bar (a full `bar` plugin) | | `plugins/omamobile.quicksettings` | Pull-down quick settings | | `plugins/omamobile.launcher` | Home bar: app search, app grid and a prompt to the user's Omarchy default agent; over an app, the home pill in a 44 px strip that reserves its height, so apps end above it (as on Android it is just the pill: double-tap for the keyboard, hold for the voice bar) | -| `plugins/omamobile.switcher` | Recent apps: swipe up on the dock, or swipe up and hold on the home pill over an app; hold a card to show the app with another one, or give it its own screen again. The middle card copies its window live, the others one frame each, and each card keeps its window's last picture for when the capture has none | +| `plugins/omamobile.switcher` | Recent apps: swipe up on the dock, or swipe up and hold on the home pill over an app; hold a card to show the app with another one, or give it its own screen again. Each card keeps its window's last picture for when its capture has none, and starts a failed capture again | | `plugins/omamobile.home` | Home screens: pages of apps and widgets on the wallpaper, with an edit mode. The built-ins include every widget in Simon Schubert's [omarchy-widgets](https://github.com/SimonSchubert/omarchy-widgets) `widgets/simonschubert/` (MIT): the OWL originals, from the `omamobile-owl-widgets` package, run by our own OWL runtime (`owl/`, see `owl/SPEC-NOTES.md`). `widgets/OWL.md` is his OWL language guide (MIT, `widgets/LICENSE-owl-guide`) | | `plugins/omamobile.keyboard` | The on-screen keyboard's show and hide calls, for the home pill (double-tap it), the keyboard's Hide key and scripts; a keyboard shown by hand goes away when the home screen comes up; the language sheet for the keyboard's globe key | | `squeekboard/keyboards/` | squeekboard's layouts (GPL-3.0-or-later, portrait and landscape) with an action row of Mic, Paste, Emoji and Hide, XF86 keysyms that `hypr/phone.lua` binds for squeekboard's virtual keyboard only (docs/VOICE-PLAN.md): the US terminal layout by hand, every language's (and the email and URL layouts) made from squeekboard 1.43.1's own by `squeekboard/generate`; `squeekboard/generate --check` (in `test/all`) proves each is upstream's plus the row and the globe key, which sends `XF86MediaLanguageMenu` (the language sheet) instead of opening squeekboard's popover | diff --git a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml index 1b5556d34..efa9347f7 100644 --- a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml @@ -10,7 +10,7 @@ import qs.Ui import "Readable.js" as Readable import "SwitcherModel.js" as SwitcherModel -// Recent apps, after Android: every open window as a card with a +// Recent apps, after Android: every open window as a card with a live // preview. Swipe sideways through them, tap one to switch to it, flick it up // to close it. Home shows the home screen (an empty workspace) and leaves the // apps open. Summoned by swiping up on the dock (omamobile.launcher). @@ -20,12 +20,10 @@ import "SwitcherModel.js" as SwitcherModel // app's screen, where the two tile as Omarchy tiles them, and "Move to its // own screen" gives it one back. // -// The card in the middle copies its window live, the others one frame each. -// Each card also keeps its window's last picture (a still, at the card's -// size) and shows it until its capture has a frame: an app sits on a screen -// of its own, and one that draws nothing there gives Hyprland nothing to -// copy, so its card stayed empty, and so did every card rebuilt after -// another window closed. +// A capture Hyprland fails ends for good, and the card stayed empty: each +// card starts it again, and keeps its window's last picture (a still, at the +// card's size) to show until its capture has a frame, also when the card is +// rebuilt after another window closed. // // On its side (TOUCH-PLAN 2.4: 1040x480) a card keeps the screen's shape, // so its preview isn't stretched, and the bottom actions keep their row. @@ -431,7 +429,7 @@ Item { anchors.fill: parent anchors.margins: card.border.width captureSource: root.opened && !slot.resting ? slot.modelData : null - live: slot.ListView.isCurrentItem + live: true onHasContentChanged: if (hasContent) Qt.callLater(slot.keepStill) onStopped: { if (!root.opened || slot.resting || slot.retries >= 3) return diff --git a/packages/omamobile-shell/test/switcher-touch.qml b/packages/omamobile-shell/test/switcher-touch.qml index b267bffc4..b01ebb042 100644 --- a/packages/omamobile-shell/test/switcher-touch.qml +++ b/packages/omamobile-shell/test/switcher-touch.qml @@ -341,9 +341,8 @@ Item { return null } - // Only the card in the middle copies live; a card whose window gives no - // frame shows the still from its last frame, and a window that closes - // takes its still with it. + // A card whose capture has no frame shows the still from its window's + // last one, and a window that closes takes its still with it. function test_cards_keep_a_still_until_the_capture_has_a_frame() { var a = fakeWindow.createObject(top, { appId: "a" }), b = fakeWindow.createObject(top, { appId: "b" }) openWith([a, b]) // newest first: b, a @@ -351,8 +350,6 @@ Item { tryVerify(function() { return cards.count === 2 && captures().length === 2 }) var caps = captures() compare(caps[0].captureSource, b) - verify(caps[0].live, "the centred card is live") - verify(!caps[1].live, "its neighbour copies one frame") verify(!stillOf(caps[0]).visible, "no still yet") caps[0].hasContent = true From db2d0d19a40e5fd5e9eaf2d2133170e16421d0ed Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Wed, 11 Nov 2026 12:53:31 +0100 Subject: [PATCH 3/3] omamobile-shell 0.2.120: recent apps start a capture again when its card has no frame The restart in the first commit waited for ScreencopyView's stopped signal, but Quickshell 0.3.2 declares that signal and never emits it: when Hyprland fails a capture, the view only drops its context. So on a phone the restart never ran; test/switcher-touch passed only because its stub emitted the signal. Now a card that has no frame a second after recent apps open, or that loses its frame, drops its capture and starts a new one, three times at most while recent apps are open. The stub no longer has the signal, and the test leaves the capture without a frame, as Hyprland's failure does. Reproduced on the 9a: with the on-screen keyboard up, opening recent apps closes the keyboard, the window grows from 579 to 821 points, and Hyprland fails the capture that was sized for the old window. Before: the card stayed empty. After: the first frame, the failure, and a second later the window at its new size. The measurement in the previous commit is void: the shell's local-plugin reload keeps the component it compiled first, so both runs ran the same switcher. Measured again with a shell restart before each run (two foot terminals redrawing ten times a second, recent apps open, 12 s, three rounds): every card live, shell 26.6-27.3 % and Hyprland 46.4-49.2 %; only the middle card live, shell 30.3-31.0 % and Hyprland 39.9-42.0 %. Hyprland saves about 7 points, the shell spends about 4 more, and the neighbours would lose their live picture, so every card stays live. Co-Authored-By: Claude Opus 5.5 --- .../plugins/omamobile.switcher/Switcher.qml | 25 ++++++++++-------- .../Quickshell/Wayland/ScreencopyView.qml | 4 +-- .../omamobile-shell/test/switcher-touch.qml | 26 ++++++++++++++----- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml index efa9347f7..09888014f 100644 --- a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml @@ -356,15 +356,24 @@ Item { width: cards.cardWidth height: cards.height - // A capture Hyprland fails ends for good ("Ending recording due to - // screencopy failure"): start it again a second later, three times - // at most while recent apps are open. + // Hyprland fails a capture now and then, most often while its window + // changes size (the keyboard closing as recent apps open), and + // Quickshell then just ends it ("Ending recording due to screencopy + // failure"): no frame, and no stopped signal either, which 0.3.2 + // declares but never emits. So a card still without a frame a second + // on starts its capture again, three times at most while recent apps + // are open. property bool resting: false property int retries: 0 Timer { - id: retry interval: 1000 - onTriggered: slot.resting = false + repeat: true + running: root.opened && !capture.hasContent && slot.retries < 3 + onTriggered: { + slot.retries++ + slot.resting = true // the capture drops its context + slot.resting = false // and makes a new one + } } Connections { target: root @@ -431,12 +440,6 @@ Item { captureSource: root.opened && !slot.resting ? slot.modelData : null live: true onHasContentChanged: if (hasContent) Qt.callLater(slot.keepStill) - onStopped: { - if (!root.opened || slot.resting || slot.retries >= 3) return - slot.retries++ - slot.resting = true - retry.restart() - } } // Tap to switch; hold for "Show with…" and "Move to its own screen". diff --git a/packages/omamobile-shell/test/qml-stubs/Quickshell/Wayland/ScreencopyView.qml b/packages/omamobile-shell/test/qml-stubs/Quickshell/Wayland/ScreencopyView.qml index a3375ae84..93f70c774 100644 --- a/packages/omamobile-shell/test/qml-stubs/Quickshell/Wayland/ScreencopyView.qml +++ b/packages/omamobile-shell/test/qml-stubs/Quickshell/Wayland/ScreencopyView.qml @@ -8,8 +8,8 @@ Item { property var captureSource: null property bool live: false property bool hasContent: false - // Quickshell's ends a recording Hyprland fails and says so. - signal stopped() + // A recording Hyprland fails just never gets a frame, as Quickshell's + // (0.3.2) ends it without emitting its stopped signal. property int starts: 0 function captureFrame() {} onCaptureSourceChanged: if (!captureSource) hasContent = false; else starts++ diff --git a/packages/omamobile-shell/test/switcher-touch.qml b/packages/omamobile-shell/test/switcher-touch.qml index b01ebb042..74c99138d 100644 --- a/packages/omamobile-shell/test/switcher-touch.qml +++ b/packages/omamobile-shell/test/switcher-touch.qml @@ -372,21 +372,33 @@ Item { tryVerify(function() { return sw.stills.length === 0 }, 2000, "a closed window loses its still") } - // A failed capture starts again a second later, three times at most. + // A capture with no frame a second on (Hyprland failed it) starts again, + // three times at most while recent apps are open; one with a frame stays. function test_a_failed_capture_starts_again() { var a = fakeWindow.createObject(top, { appId: "a" }) openWith([a]) tryVerify(function() { return captures().length === 1 }) var cap = captures()[0] var first = cap.starts - cap.stopped() - tryVerify(function() { return cap.captureSource === null }, 1000, "resting after the failure") - tryVerify(function() { return cap.captureSource === a && cap.starts === first + 1 }, 3000, "started again") - cap.stopped(); tryVerify(function() { return cap.starts === first + 2 }, 3000) - cap.stopped(); tryVerify(function() { return cap.starts === first + 3 }, 3000) - cap.stopped(); wait(1500) + tryVerify(function() { return cap.starts === first + 1 }, 2000, "started again after a second") + compare(cap.captureSource, a, "on its window") + tryVerify(function() { return cap.starts === first + 3 }, 3000, "and twice more") + wait(1500) compare(cap.starts, first + 3, "no fourth try") compare(cap.captureSource, a, "and the capture stays on its window") + + // A frame stops the retries; losing it later starts them again. + sw.close() + tryVerify(function() { return !overlay.visible }) + openWith([a]) + tryVerify(function() { return captures().length === 1 }) + cap = captures()[0] + cap.hasContent = true + first = cap.starts + wait(1500) + compare(cap.starts, first, "a capture with a frame is left alone") + cap.hasContent = false + tryVerify(function() { return cap.starts === first + 1 }, 2000, "a lost frame starts it again") } // A window that gets its size after it is shown still opens centred.