Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/omamobile-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 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 |
Expand Down
65 changes: 64 additions & 1 deletion packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ 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.
//
// 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.
//
Expand Down Expand Up @@ -49,6 +54,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
Expand Down Expand Up @@ -339,6 +356,39 @@ Item {
width: cards.cardWidth
height: cards.height

// 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 {
interval: 1000
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
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
Expand Down Expand Up @@ -372,11 +422,24 @@ 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
captureSource: root.opened && !slot.resting ? slot.modelData : null
live: true
onHasContentChanged: if (hasContent) Qt.callLater(slot.keepStill)
}

// Tap to switch; hold for "Show with…" and "Move to its own screen".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Original file line number Diff line number Diff line change
@@ -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
// 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++
Rectangle {
anchors.fill: parent
visible: parent.hasContent
color: parent.captureSource && parent.captureSource.colour !== undefined ? parent.captureSource.colour : "grey"
}
}
17 changes: 17 additions & 0 deletions packages/omamobile-shell/test/switcher-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }
Expand Down
77 changes: 77 additions & 0 deletions packages/omamobile-shell/test/switcher-touch.qml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,83 @@ 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
}

// 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
var cards = cardsList()
tryVerify(function() { return cards.count === 2 && captures().length === 2 })
var caps = captures()
compare(caps[0].captureSource, b)
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 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
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.
function test_centred_after_a_resize() {
var a = fakeWindow.createObject(top), b = fakeWindow.createObject(top, { appId: "chromium" })
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-shell/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.118
0.2.120