diff --git a/packages/omamobile-shell/LICENSE.omarchy b/packages/omamobile-shell/LICENSE.omarchy new file mode 100644 index 000000000..f12cfa766 --- /dev/null +++ b/packages/omamobile-shell/LICENSE.omarchy @@ -0,0 +1,20 @@ +Copyright (c) David Heinemeier Hansson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index 71f4ac874..0bf06489d 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -6,7 +6,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.launcher` | Home bar: a separate native app-search view on tap; App Library and the existing optional agent flow on swipe; 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.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 | @@ -103,3 +103,46 @@ Open, save and choose-a-folder requests through the portal (Qt, GTK, Electron an The package contract follows omarchy-mac's: `./install DESTDIR` stages files and enables nothing, `test/all` runs the package's own tests, and `version` holds the version. Develop on a desktop with `phone/dev/run-desktop` from the repo root. + +## Native app Search + +Set the launcher's `nativeSearch` setting to `true` to open app Search +when tapping the dock. The default tap and swipe up open the App Library +and its existing optional agent flow. +Search uses Omarchy's application library and normal app-launch command. It +does not index files, select an agent or access accounts. + +The view follows Commons palette, font, spacing, controls and corner settings; +its animation follows `Style.duration` when available. A full-screen background +takes no input, the content respects the status/keyboard reservations, and the +existing Home strip remains visible even after manually hiding the keyboard. +Home and app activation release Search input before changing screens. + +Native focus is briefly primed with Exclusive, then released to OnDemand, using +the focus lifecycle from Omarchy's MIT-licensed `shell/Ui/KeyboardPanel.qml`. +That component is present in both supported Omarchy package families. Its +David Heinemeier Hansson copyright and license are retained in +`LICENSE.omarchy`. Offscreen component tests verify cancellation and focus +intent; a phone acceptance must separately verify first-tap OSK activation, +keyboard touches, Back/Home, immediate reopen and lock interaction. + +Native Search cancels pending focus and closes when the launcher's existing session-lock observation reports locked. Unlocking never reopens it without a new explicit tap. This observation is asynchronous and is not a security boundary or a replacement for the compositor lock protocol. Existing fullscreen exclusion of Home/Back gesture strips remains in force; a Search opened over fullscreen can still close using its visible close button or Escape. The Search panels currently use Quickshell's default output; multi-output active-screen routing is not qualified by the offscreen tests. + +### Search presentation + +Search retains the phone layout: the query row stays at the top, followed by +three suggested apps, or matching results while typing. App rows have icons, +names and descriptions without an enclosing border. Colors, font family and +size, spacing, control borders, corner rounding and motion follow Commons. +The view uses the drawer's `Commons.Color.menu.background` surface over its +`Commons.Color.menu.scrim`. Secondary text and glyphs use the launcher's +`Qt.darker(foreground, 1.3)` ink. Close, search and chevron use the shell icon +font at `Style.font.iconLarge`; Search adds no theme keys or custom alpha +values. Rounding follows the configured Hyprland/theme value. + +Search registers with the shared Back surface client while open. Back first +dismisses the keyboard, then closes Search. Back has no dependency on the +launcher plugin. +The home screen pauses widgets and yields Back while Search is open. The +strip uses the existing lock rule when the keyboard is up. Physical lock, +keyboard and gesture acceptance still requires this package on a phone. diff --git a/packages/omamobile-shell/install b/packages/omamobile-shell/install index f886a7c8d..da960f519 100755 --- a/packages/omamobile-shell/install +++ b/packages/omamobile-shell/install @@ -70,6 +70,7 @@ install -Dm644 applications/omamobile-agent.desktop "$destination/usr/share/appl install -Dm644 applications/omamobile-open-intent.desktop "$destination/usr/share/applications/omamobile-open-intent.desktop" install -Dm644 applications/omamobile-update.desktop "$destination/usr/share/applications/omamobile-update.desktop" install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-shell/LICENSE" +install -Dm644 LICENSE.omarchy "$destination/usr/share/licenses/omamobile-shell/LICENSE.omarchy" # OWL.md is Simon Schubert's OWL guide (MIT). The built-in widgets themselves # come from omamobile-owl-widgets, which ships the store's licence. install -Dm644 widgets/LICENSE-owl-guide "$destination/usr/share/licenses/omamobile-shell/LICENSE-owl-guide" diff --git a/packages/omamobile-shell/plugins/README.md b/packages/omamobile-shell/plugins/README.md index 2ca67f2de..98fbedf3a 100644 --- a/packages/omamobile-shell/plugins/README.md +++ b/packages/omamobile-shell/plugins/README.md @@ -874,6 +874,7 @@ back instead; start it further in. | Fingerprint setup (`omamobile.fingerprint`) | Its Cancel (stops a running enrollment), or Done after one. Not while polkit asks | | Voice settings; the voice bar's check before Ask, and its error (`omamobile.voice`) | Closes; the check's text is discarded, as its Discard | | Home screen (`omamobile.home`), only while it shows with nothing open over it | A sheet goes back one sheet or closes (a widget's unsaved settings are asked about first: Save, or Discard changes), then edit mode ends, then the pages go to the home page | + | App search (`omamobile.launcher`) | Closes Search after the keyboard has been dismissed | | A widget's opened screen (`OwlCell.qml`) | Closes, as a tap on its title | 3. **Escape, to whatever has the keyboard focus**: an app, or a shell sheet diff --git a/packages/omamobile-shell/plugins/omamobile.home/Home.qml b/packages/omamobile-shell/plugins/omamobile.home/Home.qml index fd8ace549..665fc010d 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/Home.qml +++ b/packages/omamobile-shell/plugins/omamobile.home/Home.qml @@ -628,9 +628,9 @@ Item { } } } - // The app drawer covers it once fully open (its surface is always mapped, - // so it has no openlayer event to go by; drawerProgress below). - readonly property bool homeShown: HomeModel.homeShown(owlPanelOff, appOnScreen, coveringLayers) && drawerProgress < 1 + // The drawer and Search surfaces stay mapped. Use their launcher state + // to pause widgets and leave Back to the visible surface. + readonly property bool homeShown: HomeModel.homeShown(owlPanelOff, appOnScreen, coveringLayers) && drawerProgress < 1 && !searchOpened readonly property bool owlPaused: !homeShown // The app drawer (omamobile.launcher's root, through its DrawerLink.js, // which DrawerLinkClient.qml beside it imports), for the swipe up and for @@ -641,6 +641,7 @@ Item { source: Qt.resolvedUrl("../omamobile.launcher/DrawerLinkClient.qml") } readonly property var drawer: drawerLink.item ? drawerLink.item.drawer : null + readonly property bool searchOpened: !!drawer && drawer.searchOpened === true readonly property real drawerProgress: drawer && drawer.progress !== undefined ? Number(drawer.progress) || 0 : 0 // The dock (omamobile.launcher) reserves no space, so that no window // changes size as the drawer opens over it; the home screen keeps its diff --git a/packages/omamobile-shell/plugins/omamobile.home/HomeModel.js b/packages/omamobile-shell/plugins/omamobile.home/HomeModel.js index f46ae9ee4..75ce45177 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/HomeModel.js +++ b/packages/omamobile-shell/plugins/omamobile.home/HomeModel.js @@ -1048,6 +1048,7 @@ function drawerFallbackOpens(travel, speed) { // volume display and the on-screen keyboard (Back's own first stop). var BACK_FURNITURE = ["omarchy-background", "omarchy-bar", "omarchy-notifications", "omarchy-osd", "omamobile-home", "omamobile-dock", "omamobile-home-strip", "omamobile-back", "omamobile-launcher", + "omamobile-app-search", "omamobile-app-search-background", "omamobile-fingerprint", "omamobile-fingerprint-guard", "omamobile-call-top", "omamobile-voice-bar", "osk"] // Everything else mapped over the home screen after one Hyprland event diff --git a/packages/omamobile-shell/plugins/omamobile.launcher/AppsSearch.qml b/packages/omamobile-shell/plugins/omamobile.launcher/AppsSearch.qml new file mode 100644 index 000000000..7df2901aa --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.launcher/AppsSearch.qml @@ -0,0 +1,339 @@ +// SPDX-License-Identifier: MIT +import QtQuick +import QtQuick.Window +import QtQuick.Layouts +import qs.Commons +import qs.Commons as Commons +import qs.Ui + +// App search only. The application library and launch path remain Omarchy's; +// this component neither indexes files nor selects an agent or account. +Item { + id: root + objectName: "appsSearch" + + property var appLibrary: null + property bool paintBackground: true + property bool opened: false + property bool sessionLocked: false + onSessionLockedChanged: if (sessionLocked) dismiss() + property string query: "" + property var entries: [] + property bool surfaceActive: root.Window.active + property bool inputReady: true + property int focusGeneration: 0 + property bool focusPending: false + property bool hadFocus: false + property int transitionDuration: typeof Style.duration === "function" ? Style.duration(140) : 140 + readonly property color foreground: Commons.Color.menu.text + readonly property int touch: Math.max(44, Style.space(44)) + signal dismissed() + signal activated(var entry) + // Also useful to the offscreen harness: this observes the production input + // context request, not a pretend keyboard or a global visibility policy. + signal inputRequested(bool visible) + + opacity: opened ? 1 : 0 + enabled: opened + Behavior on opacity { NumberAnimation { duration: root.transitionDuration; easing.type: Easing.OutCubic } } + + function refreshEntries() { + if (!opened) return + var ranked = appLibrary ? appLibrary.sortedEntries(query) : [] + var next = [] + var limit = query.trim() ? 40 : 3 + for (var i = 0; i < ranked.length && next.length < limit; i++) + if (ranked[i] && ranked[i].entry) next.push(ranked[i].entry) + var same = next.length === entries.length + for (var j = 0; same && j < next.length; j++) same = next[j] === entries[j] + if (!same) entries = next + } + function name(entry) { + return appLibrary && typeof appLibrary.entryName === "function" + ? appLibrary.entryName(entry) : String(entry && entry.name || "") + } + function icon(entry) { + return appLibrary && typeof appLibrary.iconSource === "function" + ? appLibrary.iconSource(entry.icon) : "" + } + function queueFocus() { + if (sessionLocked || !opened || !focusPending || !surfaceActive || !inputReady) return + var generation = focusGeneration + Qt.callLater(function() { + if (root.sessionLocked || !root.opened || !root.focusPending || !root.surfaceActive || !root.inputReady || generation !== root.focusGeneration) return + root.focusPending = false + input.forceActiveFocus() + root.hadFocus = true + Qt.inputMethod.show() + root.inputRequested(true) + }) + } + function open(text) { + if (sessionLocked) { close(); return } + ++focusGeneration + query = String(text || "").slice(0, 256) + opened = true + hadFocus = false + focusPending = true + refreshEntries() + queueFocus() + } + function close() { + ++focusGeneration + focusPending = false + // Never hide a different app's or the lock screen's input context after + // focus has already moved there. Clearing our field still releases it. + if (input.activeFocus && surfaceActive) { + Qt.inputMethod.hide() + inputRequested(false) + } + input.focus = false + if (surfaceActive) root.forceActiveFocus() + hadFocus = false + opened = false + } + function dismiss() { close(); dismissed() } + function activate(entry) { + if (!entry || !entry.id) return + close() // release our input context before an app can take focus + activated(entry) + } + function activateFirst() { if (entries.length) activate(entries[0]) } + onQueryChanged: refreshEntries() + onAppLibraryChanged: refreshEntries() + onInputReadyChanged: queueFocus() + onSurfaceActiveChanged: { + if (!opened) return + if (surfaceActive) queueFocus() + else if (hadFocus) dismiss() + } + Connections { + target: root.appLibrary + ignoreUnknownSignals: true + function onAppsChanged() { root.refreshEntries() } + } + + onOpacityChanged: if (opacity === 0 && !opened) { query = ""; entries = [] } + // The search field and compact app rows share the drawer palette. + readonly property color backgroundTone: Commons.Color.menu.background + readonly property color backdropColor: Commons.Color.menu.scrim + readonly property color secondary: Qt.darker(root.foreground, 1.3) + readonly property color muted: root.secondary + readonly property color cardColor: Commons.Color.menu.background + Rectangle { anchors.fill: parent; visible: root.paintBackground; color: root.backgroundTone } + ColumnLayout { + anchors.fill: parent + anchors.leftMargin: Math.min(Style.space(24), root.width / 8) + anchors.rightMargin: anchors.leftMargin + anchors.topMargin: Math.min(Style.space(12), Math.max(0, (root.height - root.touch) / 4)) + anchors.bottomMargin: Math.min(Style.space(16), Math.max(0, (root.height - root.touch) / 4)) + spacing: 0 + + RowLayout { + objectName: "searchHeader" + Layout.fillWidth: true + Layout.minimumHeight: Math.min(root.touch, root.height) + Layout.maximumHeight: Layout.preferredHeight + Layout.preferredHeight: Math.min(Style.space(56), Math.max(root.touch, root.height)) + spacing: Style.spacing.lg + Item { + objectName: "searchClose" + Layout.preferredWidth: root.touch + Layout.fillHeight: true + Accessible.name: "Close search" + Accessible.role: Accessible.Button + Text { + anchors.centerIn: parent + text: "󰅖" + textFormat: Text.PlainText + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.iconLarge + } + MouseArea { anchors.fill: parent; onClicked: root.dismiss() } + } + BorderSurface { + objectName: "searchInputSurface" + Layout.fillWidth: true + Layout.fillHeight: true + radius: Style.cornerRadius + color: root.cardColor + borderSpec: Border.controlSpec(input.activeFocus ? "focus" : "normal", root.foreground, Commons.Color.accent) + RowLayout { + anchors.fill: parent + anchors.leftMargin: Style.space(16) + anchors.rightMargin: Style.spacing.sm + spacing: Style.spacing.xxl + Text { + Layout.preferredWidth: Style.space(20) + Layout.preferredHeight: implicitHeight + text: "󰍉" + textFormat: Text.PlainText + color: root.secondary + font.family: Style.font.family + font.pixelSize: Style.font.iconLarge + horizontalAlignment: Text.AlignHCenter + } + TextField { + id: input + objectName: "appsSearchInput" + Layout.fillWidth: true + Layout.fillHeight: true + background: null + padding: 0 + text: root.query + placeholderText: "Search apps" + foreground: root.foreground + placeholderTextColor: root.muted + font.family: Style.font.family + font.pixelSize: Style.font.title + maximumLength: 256 + selectByMouse: true + Accessible.name: "Search apps" + onTextEdited: root.query = text + Keys.onReturnPressed: root.activateFirst() + Keys.onEnterPressed: root.activateFirst() + Keys.onEscapePressed: root.dismiss() + } + Item { + objectName: "searchClear" + visible: root.query.length > 0 + Layout.preferredWidth: root.touch + Layout.fillHeight: true + Accessible.name: "Clear search" + Accessible.role: Accessible.Button + Text { + anchors.centerIn: parent + text: "󰅖" + textFormat: Text.PlainText + color: root.secondary + font.family: Style.font.family + font.pixelSize: Style.font.iconLarge + } + MouseArea { anchors.fill: parent; onClicked: { root.query = ""; input.forceActiveFocus() } } + } + } + } + } + + Item { Layout.fillWidth: true; Layout.preferredHeight: root.height >= Style.space(180) ? Style.space(28) : 0 } + Text { + visible: root.entries.length > 0 && root.height >= Style.space(180) + Layout.fillWidth: true + Layout.bottomMargin: Style.spacing.xxl + text: "Apps" + color: root.secondary + font.family: Style.font.family + font.pixelSize: Style.font.body + font.bold: true + } + ListView { + id: results + objectName: "searchResults" + visible: root.height >= Style.space(180) + Layout.fillWidth: true + Layout.fillHeight: true + Layout.minimumHeight: 0 + clip: true + spacing: 0 + model: root.entries + boundsBehavior: Flickable.StopAtBounds + delegate: Item { + required property var modelData + required property int index + objectName: "searchResult" + index + width: results.width + height: Math.max(root.touch, Style.space(68)) + Accessible.name: root.name(modelData) + Accessible.role: Accessible.Button + Rectangle { anchors.fill: parent; radius: Style.cornerRadius; color: rowTouch.pressed ? Style.pressedFillFor(root.foreground, Commons.Color.accent) : "transparent" } + RowLayout { + anchors.fill: parent + spacing: Style.space(14) + Rectangle { + Layout.preferredWidth: root.touch + Layout.preferredHeight: root.touch + radius: Style.cornerRadius + color: root.cardColor + Image { id: appIcon; anchors.centerIn: parent; width: Style.space(32); height: width; source: root.icon(modelData); fillMode: Image.PreserveAspectFit } + Text { anchors.centerIn: parent; visible: appIcon.status !== Image.Ready; text: root.name(modelData).slice(0, 1); textFormat: Text.PlainText; color: Commons.Color.accent; font.family: Style.font.family; font.pixelSize: Style.font.title } + } + ColumnLayout { + Layout.fillWidth: true + spacing: Style.spacing.xs + Text { + Layout.fillWidth: true + text: root.name(modelData) + textFormat: Text.PlainText + color: root.foreground + font.family: Style.font.family + font.pixelSize: (typeof Style.font.heading === "number" ? Style.font.heading : Style.font.title) + font.bold: true + elide: Text.ElideRight + } + Text { + Layout.fillWidth: true + text: String(modelData.genericName || modelData.comment || "Application") + textFormat: Text.PlainText + color: root.muted + font.family: Style.font.family + font.pixelSize: Style.font.body + elide: Text.ElideRight + } + } + Text { + Layout.preferredWidth: Style.space(18) + Layout.preferredHeight: implicitHeight + text: "󰅂" + textFormat: Text.PlainText + color: root.secondary + font.family: Style.font.family + font.pixelSize: Style.font.iconLarge + horizontalAlignment: Text.AlignHCenter + } + } + MouseArea { id: rowTouch; anchors.fill: parent; onClicked: root.activate(modelData) } + } + // Moving rows fade into the same menu surface as the drawer. + Rectangle { + parent: results + anchors { left: parent.left; right: parent.right; top: parent.top } + height: Math.min(Style.spacing.lg, results.height) + visible: !results.atYBeginning + z: 1 + gradient: Gradient { + GradientStop { position: 0; color: root.backgroundTone } + GradientStop { position: 1; color: Qt.rgba(root.backgroundTone.r, root.backgroundTone.g, root.backgroundTone.b, 0) } + } + } + Rectangle { + parent: results + anchors { left: parent.left; right: parent.right; bottom: parent.bottom } + height: Math.min(Style.spacing.lg, results.height) + visible: !results.atYEnd + z: 1 + gradient: Gradient { + GradientStop { position: 0; color: Qt.rgba(root.backgroundTone.r, root.backgroundTone.g, root.backgroundTone.b, 0) } + GradientStop { position: 1; color: root.backgroundTone } + } + } + Text { + parent: results + objectName: "searchEmpty" + anchors.centerIn: parent + width: parent.width + visible: root.entries.length === 0 + text: root.appLibrary ? "No apps found" : "Loading apps…" + textFormat: Text.PlainText + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.Wrap + color: root.secondary + font.family: Style.font.family + font.pixelSize: Style.font.body + } + } + Item { visible: !results.visible; Layout.fillHeight: true } + } + Keys.onEscapePressed: root.dismiss() + Keys.onBackPressed: root.dismiss() +} diff --git a/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml b/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml index 8ccbb3505..d780d6114 100644 --- a/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml @@ -13,10 +13,10 @@ import "Readable.js" as Readable import "DrawerLink.js" as DrawerLink // The phone's home surface, after Omalauncher: one bar at the bottom of the -// screen that is app search, app grid and coding-agent prompt at once. +// screen. Dock tap opens native app Search; swiping opens the App Library. // -// Collapsed, it is a dock holding a single search pill. Tapping it raises the -// app drawer with the input focused. Typing filters the grid; text that reads +// The App Library retains its existing search and optional agent flow. +// Typing there filters the grid; text that reads // like a sentence (or matches no app) offers "Ask " (the user's // Omarchy default agent) instead, and Enter // takes whichever is on top: the first app, or a terminal running the agent @@ -50,6 +50,7 @@ Item { } // `opened` is the drawer; the dock is always on screen. + readonly property bool searchOpened: appsSearch.opened property bool opened: false property string query: "" property var apps: [] @@ -194,6 +195,13 @@ Item { function open(payloadJson) { var payload = ({}) try { payload = JSON.parse(payloadJson || "{}") } catch (e) { payload = ({}) } + if (payload.view === "apps-search") { + if (sessionLocked) { appsSearch.close(); return } + if (opened) close() + appsSearch.open(payload.query) + return + } + appsSearch.close() var gesture = payload.gesture === true query = typeof payload.query === "string" ? payload.query : "" refreshApps() @@ -209,6 +217,7 @@ Item { // A closing drawer never holds a focused text field: the field gives the // focus back first, so nothing asks for the keyboard as the drawer goes. function close() { + appsSearch.close() if (input.activeFocus) sheet.forceActiveFocus() opened = false query = "" @@ -224,6 +233,22 @@ Item { else close() } + // Explicit dock activation is distinct from the swipe App Library. + function activateDock() { + if (settings.nativeSearch === true) openSearch("") + else expand() + } + function openSearch(text) { + if (sessionLocked) return + var payload = JSON.stringify({ view: "apps-search", query: String(text || "") }) + if (shell && typeof shell.summon === "function") shell.summon(pluginId, payload) + else open(payload) + } + function closeSearch() { + appsSearch.close() + dismiss(0) + } + function expand() { if (shell && typeof shell.summon === "function") shell.summon(pluginId, "{}") else open("{}") @@ -240,10 +265,12 @@ Item { function state() { return JSON.stringify({ + searchOpened: searchOpened, opened: opened, - query: query, - mode: hasQuery ? (promptMode ? "agent" : "apps") : "idle", - apps: apps.length, + view: searchOpened ? "search" : opened ? "library" : "home", + query: searchOpened ? appsSearch.query : query, + mode: searchOpened ? "apps" : hasQuery ? (promptMode ? "agent" : "apps") : "idle", + apps: searchOpened ? appsSearch.entries.length : apps.length, library: shell && shell.appLibrary ? "host" : (appLibrary ? "local" : "none"), agent: agentId, command: hasAgent ? LauncherModel.promptArgv("") : LauncherModel.PICK_AGENT_ARGV @@ -255,7 +282,7 @@ Item { Connections { target: Hyprland function onRawEvent(event) { - if (root.opened && event && event.name === "openwindow") root.dismiss() + if ((root.opened || root.searchOpened) && event && event.name === "openwindow") root.dismiss() } } @@ -373,7 +400,7 @@ Item { // decides there whether it opens (LauncherModel.drawerEndsOpen: a fling, // or a quarter of the way) and then opens through the host, as a tap does. function gestureBegin() { - if (opened) return false + if (opened || searchOpened) return false settle.stop() pulling = false homeSwipe = true @@ -449,8 +476,8 @@ Item { SearchPill { anchors.fill: parent anchors.margins: Style.spacing.xxl - placeholder: (root.hasAgent ? "Search apps or ask " + root.agentName + "…" : "Search apps…") - onTapped: root.expand() + placeholder: (root.settings.nativeSearch !== true && root.hasAgent ? "Search apps or ask " + root.agentName + "…" : "Search apps…") + onTapped: root.activateDock() // Hold: the voice bar, as a hold on the pill over an app. onHeld: root.voiceHold() } @@ -567,6 +594,8 @@ Item { } function goHome() { + if (searchOpened) closeSearch() + // As the switcher's Home: an empty workspace, then the home page. Quickshell.execDetached(["hyprctl", "dispatch", "hl.dsp.focus({ workspace = \"empty\" })"]) Quickshell.execDetached(["qs", "ipc", "-p", Quickshell.shellDir, "call", "shell", "call", "omamobile.home", "goHome", ""]) @@ -637,6 +666,7 @@ Item { } function showRecents() { + if (searchOpened) closeSearch() // Through the CLI, like the dock's swipe: a plugin may only summon // panels it owns, and the switcher is its own plugin. Quickshell.execDetached(["omarchy-shell", "shell", "summon", "omamobile.switcher", "{}"]) @@ -671,7 +701,7 @@ Item { // While the keyboard is up the strip shows on the home screen too, and // over the open drawer (its search field): the keyboard covers the dock // there, and with it the swipe up to the drawer. - readonly property bool stripShown: (appOnScreen || oskOpen) && (!opened || oskOpen) && !fullscreenOnScreen && !(oskOpen && sessionLocked) + readonly property bool stripShown: (appOnScreen || oskOpen || searchOpened) && (!opened || oskOpen) && !fullscreenOnScreen && !(oskOpen && sessionLocked) readonly property bool keyboardStripShown: stripShown && oskOpen Process { @@ -1094,6 +1124,67 @@ Item { } } + // Both surfaces remain mapped: opening does not wait for a new Wayland + // configure or expose the drawer for a frame. Only content takes input. + PanelWindow { + visible: true + anchors { top: true; bottom: true; left: true; right: true } + exclusionMode: ExclusionMode.Ignore + color: "transparent" + mask: Region { item: null } + Rectangle { + anchors.fill: parent + // Keep the existing Home strip visible and reachable, even after the + // keyboard is manually hidden. The content window respects its zone. + anchors.bottomMargin: root.stripHeight + color: appsSearch.backdropColor + visible: appsSearch.opacity > 0 + opacity: appsSearch.opacity + } + WlrLayershell.namespace: "omamobile-app-search-background" + WlrLayershell.layer: WlrLayer.Top + WlrLayershell.keyboardFocus: WlrKeyboardFocus.None + } + PanelWindow { + visible: true + anchors { top: true; bottom: true; left: true; right: true } + exclusionMode: ExclusionMode.Normal + color: "transparent" + mask: Region { item: root.searchOpened ? appsSearch : null } + id: searchWindow + WlrLayershell.namespace: "omamobile-app-search" + WlrLayershell.layer: WlrLayer.Top + // Prime native focus briefly, then release exclusive pointer routing so + // the OSK and the existing Home/Back surfaces receive their own touches. + WlrLayershell.keyboardFocus: searchFocus.mode === "none" ? WlrKeyboardFocus.None + : searchFocus.mode === "exclusive" ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.OnDemand + SearchFocus { + id: searchFocus + opened: root.searchOpened + requestGeneration: appsSearch.focusGeneration + backingWindowVisible: searchWindow.backingWindowVisible + } + AppsSearch { + id: appsSearch + anchors.fill: parent + appLibrary: root.appLibrary + sessionLocked: root.sessionLocked + paintBackground: true // menu surface over the same menu scrim as the drawer + inputReady: searchFocus.inputReady + onDismissed: root.dismiss(0) + onActivated: function(entry) { root.launchApp(entry) } + } + } + + Loader { + source: Qt.resolvedUrl("../omamobile.back/BackLinkClient.qml") + onLoaded: { + item.name = "app search" + item.handler = function() { root.closeSearch() } + item.active = Qt.binding(function() { return root.searchOpened }) + } + } + // ---------------------------------------------------------------- parts // The collapsed bar: looks like the input it turns into. diff --git a/packages/omamobile-shell/plugins/omamobile.launcher/SearchFocus.qml b/packages/omamobile-shell/plugins/omamobile.launcher/SearchFocus.qml new file mode 100644 index 000000000..892d976cd --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.launcher/SearchFocus.qml @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) David Heinemeier Hansson +import QtQuick + +// Focus prime adapted from Omarchy's Ui/KeyboardPanel.qml (MIT), present in +// both supported Omarchy families. See LICENSE.omarchy. OnDemand alone cannot +// acquire focus when an already-mapped Search window is opened again. +QtObject { + id: root + property bool opened: false + property bool backingWindowVisible: false + property bool focusPrimed: false + property int requestGeneration: 0 + onRequestGenerationChanged: { + if (opened) { focusPrimed = false; beginFocusPrime() } + } + readonly property string mode: !opened ? "none" : focusPrimed ? "on-demand" : "exclusive" + readonly property bool inputReady: opened && backingWindowVisible && focusPrimed + function beginFocusPrime() { + if (opened && backingWindowVisible) focusPrimeTimer.restart() + } + onBackingWindowVisibleChanged: beginFocusPrime() + onOpenedChanged: { + focusPrimed = false + if (opened) beginFocusPrime() + else focusPrimeTimer.stop() + } + property Timer focusPrimeTimer: Timer { + interval: 75 + onTriggered: if (root.opened) root.focusPrimed = true + } +} diff --git a/packages/omamobile-shell/plugins/omamobile.launcher/manifest.json b/packages/omamobile-shell/plugins/omamobile.launcher/manifest.json index 99fac63c4..3cc975b7d 100644 --- a/packages/omamobile-shell/plugins/omamobile.launcher/manifest.json +++ b/packages/omamobile-shell/plugins/omamobile.launcher/manifest.json @@ -5,7 +5,7 @@ "version": "0.1.0", "author": "Omarchy Mobile", "license": "MIT", - "description": "The phone's home bar: one input at the bottom of the screen that searches apps, opens the app grid and sends a prompt to your coding agent.", + "description": "The phone home bar: native app search on tap, App Library on swipe, and the Home indicator.", "kinds": [ "panel" ], @@ -16,7 +16,8 @@ "settings": { "defaults": { "columns": 4, - "sentenceWords": 3 + "sentenceWords": 3, + "nativeSearch": false }, "schema": [ { @@ -32,6 +33,11 @@ "label": "Words that make a prompt", "min": 2, "max": 8 + }, + { + "key": "nativeSearch", + "type": "boolean", + "label": "Use separate app search on dock tap" } ] } diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 8d9ee7fbd..2d043eb88 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -184,7 +184,7 @@ def vis(w): v = re.sub(r"(^|[^.\w])(\w+)", lambda x: x.group(1) + ("root." + x.group(2) if x.group(2) not in ("true", "false") else x.group(2)), d) return v v = vis(strip) -for need in ("(root.appOnScreen || root.oskOpen)", "(!root.opened || root.oskOpen)", "!root.fullscreenOnScreen", "!(root.oskOpen && root.sessionLocked)"): +for need in ("(root.appOnScreen || root.oskOpen || root.searchOpened)", "(!root.opened || root.oskOpen)", "!root.fullscreenOnScreen", "!(root.oskOpen && root.sessionLocked)"): assert need in v, (need, v) assert "!root.oskOpen" not in v, "the keyboard doesn't unmap the strip: " + v assert "!root.appOnScreen" in vis(dock), "the dock and the strip never reserve together" @@ -267,6 +267,15 @@ elif [[ $rc != 0 ]]; then else pass "the drawer under touch: the handle taps and drags, a pull or a flick closes, a scrolled grid scrolls first, the home screen's swipe opens it" fi +node test/apps-search-routing.js || fail "native Search Back routing" +rc=0; out=$(bash test/apps-search 2>&1) || rc=$? +if [[ $rc == 77 ]]; then + pass "native app Search # SKIP no qmltestrunner" +elif [[ $rc != 0 ]]; then + printf '%s\n' "$out" >&2; fail "native app Search" +else + pass "native app Search: app-library filtering, explicit input focus, Back and foreground lifetime" +fi rc=0; out=$(bash test/home-gestures 2>&1) || rc=$? if [[ $rc == 77 ]]; then pass "the home screen's swipes # SKIP no qmltestrunner" diff --git a/packages/omamobile-shell/test/apps-search b/packages/omamobile-shell/test/apps-search new file mode 100755 index 000000000..ba37cf577 --- /dev/null +++ b/packages/omamobile-shell/test/apps-search @@ -0,0 +1,15 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# The actual apps-only Search component and its input context lifecycle, +# under Qt Quick Test with inert desktop entries. No shell, OSK, app launch, +# session bus, user files or compositor is contacted. +set -euo pipefail +here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) +runner=$(command -v qmltestrunner6 || command -v /usr/lib/qt6/bin/qmltestrunner || command -v qmltestrunner || true) +[[ -n $runner ]] || { echo "apps-search: no qmltestrunner"; exit 77; } +work=$(mktemp -d); trap 'rm -rf "$work"' EXIT +mkdir -p "$work/launcher" +cp "$here/../plugins/omamobile.launcher/AppsSearch.qml" "$here/../plugins/omamobile.launcher/SearchFocus.qml" "$work/launcher/" +cp "$here/apps-search.qml" "$work/tst_apps_search.qml" +export QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software QML_DISABLE_DISK_CACHE=1 +"$runner" -import "$here/qml-stubs" -input "$work/tst_apps_search.qml" diff --git a/packages/omamobile-shell/test/apps-search-routing.js b/packages/omamobile-shell/test/apps-search-routing.js new file mode 100644 index 000000000..2d02281b7 --- /dev/null +++ b/packages/omamobile-shell/test/apps-search-routing.js @@ -0,0 +1,33 @@ +#!/usr/bin/env node +// SPDX-License-Identifier: MIT +const fs = require('node:fs'); +const vm = require('node:vm'); +const assert = require('node:assert/strict'); +const path = require('node:path'); +const plugin = path.join(__dirname, '../plugins/omamobile.launcher'); +const launcher = fs.readFileSync(path.join(plugin, 'Launcher.qml'), 'utf8'); +function body(name) { + const match = launcher.match(new RegExp('function ' + name + '\\([^)]*\\) \\{([\\s\\S]*?)\\n \\}')); + assert.ok(match, 'actual ' + name + ' function'); + return match[1]; +} +let actions = []; +const native = vm.createContext({settings: {}, openSearch(text) { actions.push('search:' + text); }, expand() { actions.push('library'); }}); +vm.runInContext('function activateDock() {' + body('activateDock') + '}', native); +native.activateDock(); assert.deepEqual(actions, ['library']); +native.settings.nativeSearch = false; native.activateDock(); assert.deepEqual(actions, ['library', 'library']); +native.settings.nativeSearch = true; native.activateDock(); assert.deepEqual(actions, ['library', 'library', 'search:']); +actions = []; +const home = vm.createContext({searchOpened: true, closeSearch() { actions.push('close'); }, Quickshell: {execDetached() { actions.push('home'); }}}); +vm.runInContext('function goHome() {' + body('goHome') + '}', home); +home.goHome(); assert.equal(actions[0], 'close'); assert.equal(actions.filter(x => x === 'home').length, 2); +console.log('ok - dock preference retains App Library; Home closes native Search before screen changes'); + +let summoned = 0; +const lockOpen = vm.createContext({sessionLocked: true, pluginId: 'fixture', shell: {summon() { summoned++; }}}); +vm.runInContext('function openSearch(text) {' + body('openSearch') + '}', lockOpen); +lockOpen.openSearch('blocked'); assert.equal(summoned, 0); +lockOpen.sessionLocked = false; lockOpen.openSearch('fresh'); assert.equal(summoned, 1); +assert.match(launcher, /sessionLocked: root.sessionLocked/); +assert.match(body('open'), /if \(sessionLocked\) \{ appsSearch.close\(\); return \}/); +console.log('ok - known lock blocks launcher requests and is bound into native Search'); diff --git a/packages/omamobile-shell/test/apps-search-visual.py b/packages/omamobile-shell/test/apps-search-visual.py new file mode 100755 index 000000000..8b7364302 --- /dev/null +++ b/packages/omamobile-shell/test/apps-search-visual.py @@ -0,0 +1,247 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Actual Search component, genuine Omarchy UI tokens, neutral offscreen data. + +This is a component preview: no native layer-shell/OSK or phone is exercised. +Frames carry capture timestamps; their rate is not a device performance claim. +""" +import argparse +import json +import os +from pathlib import Path +import re +import shutil +import stat +import subprocess +import tempfile + +HERE = Path(__file__).resolve().parent +PLUGIN = HERE.parent / 'plugins/omamobile.launcher' +p = argparse.ArgumentParser(description=__doc__) +p.add_argument('--theme', choices=('light', 'dark'), required=True) +p.add_argument('--output', type=Path, required=True) +p.add_argument('--record', action='store_true') +p.add_argument('--width', type=int, default=420) +p.add_argument('--height', type=int, default=900) +p.add_argument('--omarchy-shell', type=Path, default=Path('/usr/share/omarchy/shell')) +a = p.parse_args() +assert 320 <= a.width <= 1440 and 320 <= a.height <= 1440 +out = a.output.resolve() +out.mkdir(parents=True, exist_ok=False) +frames = out / 'frames' +if a.record: + frames.mkdir() +short = Path(tempfile.gettempdir()) / 'omamobile-search-preview' +short.mkdir(mode=0o700, exist_ok=True) +s = short.lstat() +assert stat.S_ISDIR(s.st_mode) and s.st_uid == os.geteuid() and stat.S_IMODE(s.st_mode) == 0o700 +palette = {'dark': {'background': '#14171c', 'foreground': '#e5e9f0', 'accent': '#8ec5ff', 'red': '#ff99a5'}, + 'light': {'background': '#f7f5ef', 'foreground': '#20252d', 'accent': '#2355a4', 'red': '#9d253a'}}[a.theme] +with tempfile.TemporaryDirectory(prefix='search-preview-', dir=short) as directory: + root = Path(directory) + app = root / 'app' + app.mkdir() + (app / 'launcher').mkdir() + shutil.copytree(HERE / 'fixtures/apps-search-icons', app / 'icons') + for name in ('AppsSearch.qml', 'SearchFocus.qml'): + shutil.copyfile(PLUGIN / name, app / 'launcher' / name) + for name in ('Commons', 'Ui'): + target = a.omarchy_shell.resolve() / name + assert target.is_dir(), f'Genuine Omarchy {name} is required' + (app / name).symlink_to(target, target_is_directory=True) + home = root / 'home' + theme = home / '.local/state/omarchy/current/theme' + theme.mkdir(parents=True) + (theme / 'colors.toml').write_text(''.join(f'{key} = "{value}"\n' for key, value in palette.items())) + (theme / 'shell.toml').write_text('[font]\nbase-size = 12\n') + runtime = root / 'run' + runtime.mkdir(mode=0o700) + bindir = root / 'bin' + bindir.mkdir() + stub = bindir / 'hyprctl' + stub.write_text('#!/usr/bin/python3\nimport sys,json\nvalues={"decoration:rounding":{"int":12},"animations:enabled":{"bool":True},"general:gaps_out":{"custom":"10 10 10 10"}}\nassert sys.argv[-1] in values\nprint(json.dumps(values[sys.argv[-1]]))\n') + stub.chmod(0o700) + qml = r''' +import QtQuick +import QtQuick.Window +import QtTest +import Quickshell +import qs.Commons as Commons +import "launcher" +ShellRoot { + id: root + property bool capturing: false + property bool captureBusy: false + property int frame: 0 + property double captureStart: Date.now() + property string launched: "" + QtObject { + id: library + property var entries: [({id:"example.calendar",name:"Calendar",comment:"Your plans at a glance",icon:"calendar"}),({id:"example.files",name:"Files",comment:"Browse and organise files",icon:"files"}),({id:"example.notes",name:"Notes",comment:"Ideas, lists and reminders",icon:"notes"}),({id:"example.photos",name:"Photos",comment:"Browse your pictures",icon:"photos"}),({id:"example.weather",name:"Weather",comment:"Today and the days ahead",icon:"weather"})] + function sortedEntries(query) { return entries.filter(function(entry){return entry.name.toLowerCase().indexOf(query.toLowerCase())>=0}).map(function(entry){return {entry:entry}}) } + function entryName(entry) { return entry.name } + function iconSource(icon) { return Qt.resolvedUrl("icons/"+icon+".svg") } + } + FloatingWindow { + id: window + visible: true + implicitWidth: WIDTH + implicitHeight: HEIGHT + color: Commons.Color.menu.background + Item { + id: screen + anchors.fill: parent + // Neutral fixture scenery behind the themed component. This is + // neither a compositor blur nor a private wallpaper capture. + Rectangle { + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0; color: SCENERYTOP } + GradientStop { position: 1; color: SCENERYBOTTOM } + } + Rectangle { x: -parent.width*.3; y: parent.height*.4; width: parent.width*1.8; height: parent.height; rotation: -23; radius: width*.4; color: SCENERYHILL } + } + SearchFocus { id: prime; opened: search.opened; backingWindowVisible: true; requestGeneration: search.focusGeneration } + AppsSearch { + id: search + anchors.fill: parent + anchors.bottomMargin: caption.height + appLibrary: library + // Offscreen fixtures cannot grant native layer-shell focus. Observe + // component intent only; the phone must qualify that integration. + surfaceActive: true + inputReady: prime.inputReady + onActivated: function(entry) { root.launched=entry.id } + } + Rectangle { + id: caption + anchors.bottom: parent.bottom + width: parent.width + height: 28 + color: Commons.Color.menu.background + Text { + anchors.fill: parent + text: "Offscreen component · neutral fixtures" + textFormat: Text.PlainText + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: Commons.Color.menu.text + font.family: Commons.Style.font.family + font.pixelSize: 11 + } + } + SignalSpy { id: inputSpy; target: search; signalName: "inputRequested" } + TestCase { + name: "SearchPreview" + when: true + property bool captured: false + function shot(path) { captured=false;screen.grabToImage(function(image){verify(image.saveToFile(path));captured=true});tryCompare(this,"captured",true,2000) } + function initTestCase() { + qtest_results.startLogging() + tryVerify(function(){return Commons.Color.menu.background.toString()===Quickshell.env("SEARCH_EXPECTED_BG")},3000) + tryCompare(Commons.Style,"cornerRadius",12,3000) + } + function test_flow_and_theme() { + root.capturing=Quickshell.env("SEARCH_RECORD")==="1" + search.open("") + tryCompare(inputSpy,"count",1,3000) + tryCompare(prime,"mode","on-demand",1000) + compare(search.entries.length,3) + wait(220) + var header=findChild(search,"searchHeader") + verify(header.height <= Commons.Style.space(56)) + var inputField=findChild(search,"appsSearchInput") + verify(inputField.mapToItem(search,0,0).y < Commons.Style.space(80)) + verify(inputField.height >= 44) + verify(findChild(search,"searchResults").height > 100) + shot(OPENSHOT) + var field=findChild(search,"appsSearchInput") + keyClick(Qt.Key_N);wait(170);keyClick(Qt.Key_O);wait(170) + compare(search.query,"no") + compare(search.entries.length,1) + compare(search.entries[0].id,"example.notes") + wait(300) + shot(FILTERSHOT) + keyClick(Qt.Key_A,Qt.ControlModifier);keyClick(Qt.Key_Z);keyClick(Qt.Key_Z) + compare(search.entries.length,0) + wait(120) + shot(EMPTYSHOT) + keyClick(Qt.Key_Return);compare(root.launched,"") + keyClick(Qt.Key_A,Qt.ControlModifier);keyClick(Qt.Key_N);keyClick(Qt.Key_O) + keyClick(Qt.Key_Return) + compare(root.launched,"example.notes") + verify(!search.opened) + wait(220) + search.open("") + tryCompare(prime,"mode","on-demand",1000) + tryVerify(function(){return field.activeFocus},1000) + wait(250) + var close=findChild(search,"searchClose") + mouseClick(close,close.width/2,close.height/2) + verify(!search.opened) + search.open("") + tryCompare(prime,"mode","on-demand",1000) + wait(150) + compare(field.font.family,Commons.Style.font.family) + var inputSurface=findChild(search,"searchInputSurface") + compare(inputSurface.radius,Commons.Style.cornerRadius) + Commons.Style.applyRoundingJson('{"int":0}');compare(inputSurface.radius,0) + Commons.Style.applyRoundingJson('{"int":12}');compare(inputSurface.radius,12) + compare(search.backdropColor,Commons.Color.menu.scrim) + compare(search.cardColor,Commons.Color.menu.background) + compare(search.secondary,Qt.darker(search.foreground,1.3)) + if (typeof Commons.Style.duration === "function") { + Commons.Style.reduceMotion=true;compare(search.transitionDuration,0) + Commons.Style.reduceMotion=false + } else compare(search.transitionDuration,140) + wait(160) + } + function cleanupTestCase() { + root.capturing=false + tryCompare(root,"captureBusy",false,2000) + console.log("SEARCH_PREVIEW_RESULT",qtest_results.failCount,qtest_results.passCount) + qtest_results.stopLogging() + Qt.quit() + } + } + } + } + Timer { + interval:33;repeat:true;running:root.capturing + onTriggered: { + if(root.captureBusy||root.frame>=300)return + root.captureBusy=true + var index=root.frame++ + screen.grabToImage(function(image){image.saveToFile(Quickshell.env("SEARCH_FRAME_DIR")+"/frame"+String(index).padStart(4,"0")+".png");console.log("SEARCH_FRAME",index,Date.now()-root.captureStart);root.captureBusy=false}) + } + } + Timer { interval:20000;running:true;onTriggered:Qt.quit() } +} +''' + qml = qml.replace('WIDTH', str(a.width)).replace('HEIGHT', str(a.height)) + scenery = ('#283248', '#51415b', '#71647e') if a.theme == 'dark' else ('#d4e0e5', '#c7b8c8', '#afbdcc') + for token, color in zip(('SCENERYTOP', 'SCENERYBOTTOM', 'SCENERYHILL'), scenery): + qml = qml.replace(token, json.dumps(color)) + qml = qml.replace('OPENSHOT', json.dumps(str(out / 'search-open.png'))).replace('FILTERSHOT', json.dumps(str(out / 'search-filtered.png'))).replace('EMPTYSHOT', json.dumps(str(out / 'search-empty.png'))) + (app / 'shell.qml').write_text(qml) + env = os.environ | {'HOME': str(home), 'XDG_CONFIG_HOME': str(home / '.config'), 'XDG_DATA_HOME': str(root / 'data'), + 'XDG_CACHE_HOME': str(root / 'cache'), 'XDG_RUNTIME_DIR': str(runtime), 'QT_QPA_PLATFORM': 'offscreen', + 'QT_QPA_PLATFORMTHEME': '', 'QT_QUICK_CONTROLS_STYLE': 'Basic', 'QT_QUICK_BACKEND': 'software', + 'QML_DISABLE_DISK_CACHE': '1', 'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/nonexistent', + 'DBUS_SYSTEM_BUS_ADDRESS': 'unix:path=/nonexistent', 'PATH': str(bindir) + ':/usr/bin:/bin', + 'SEARCH_RECORD': '1' if a.record else '0', 'SEARCH_EXPECTED_BG': palette['background'], 'SEARCH_FRAME_DIR': str(frames)} + for name in ('WAYLAND_DISPLAY', 'DISPLAY', 'HYPRLAND_INSTANCE_SIGNATURE'): + env.pop(name, None) + result = subprocess.run(['/usr/bin/quickshell', '--path', str(app / 'shell.qml'), '--no-color'], env=env, capture_output=True, text=True, timeout=25) + log = result.stdout + result.stderr + (out / 'qml-ui.log').write_text(log) + print(log[-10000:]) + assert result.returncode == 0 and 'SEARCH_PREVIEW_RESULT 0 2' in log + assert not any(word in log for word in ('ReferenceError:', 'TypeError:', 'Failed to load configuration')) + captured = [(int(i), int(t)) for i, t in re.findall(r'SEARCH_FRAME (\d+) (\d+)', log)] + if a.record: + assert len(captured) > 15 and len(list(frames.glob('frame*.png'))) == len(captured) + assert all(b[1] > a[1] for a, b in zip(captured, captured[1:])) + (out / 'frames.json').write_text(json.dumps(captured) + '\n') + (out / 'RESULT.json').write_text(json.dumps({'result': 'PASS', 'theme': a.theme, 'palette': palette, 'viewport': [a.width, a.height], + 'frames': len(captured), 'offscreen': True, 'phoneCapture': False, 'nativeLayerFocusQualified': False}, indent=2) + '\n') diff --git a/packages/omamobile-shell/test/apps-search.qml b/packages/omamobile-shell/test/apps-search.qml new file mode 100644 index 000000000..e2fce0587 --- /dev/null +++ b/packages/omamobile-shell/test/apps-search.qml @@ -0,0 +1,237 @@ +// SPDX-License-Identifier: MIT +import QtQuick +import QtTest +import "launcher" + +Item { + id: view + width: 420 + height: 900 + QtObject { + id: library + property var all: [({ id: "example.calendar", name: "Calendar", icon: "" }), + ({ id: "example.notes", name: "Notes", icon: "" }), + ({ id: "example.files", name: "Files", icon: "" })] + property string lastQuery: "" + function sortedEntries(query) { + lastQuery = query + return all.filter(function(entry) { return entry.name.toLowerCase().indexOf(query.toLowerCase()) >= 0 }) + .map(function(entry) { return {entry: entry} }) + } + function entryName(entry) { return entry.name } + function iconSource(icon) { return "" } + } + SearchFocus { id: focus; opened: search.opened; requestGeneration: search.focusGeneration; backingWindowVisible: true } + AppsSearch { inputReady: focus.inputReady; id: search; anchors.fill: parent; appLibrary: library; surfaceActive: true; transitionDuration: 0 } + SignalSpy { id: inputSpy; target: search; signalName: "inputRequested" } + SignalSpy { id: closeSpy; target: search; signalName: "dismissed" } + SignalSpy { id: appSpy; target: search; signalName: "activated" } + TestCase { + name: "AppsSearch" + when: windowShown + property Item field: null + function initTestCase() { field = findChild(search, "appsSearchInput"); verify(field) } + function init() { + search.close() + search.sessionLocked = false + search.surfaceActive = true + focus.backingWindowVisible = true + view.width = 420; view.height = 900 + inputSpy.clear(); closeSpy.clear(); appSpy.clear() + } + function test_known_lock_cancels_initial_prime_and_requires_new_tap() { + search.surfaceActive = false + search.open("") + var generation = search.focusGeneration + compare(focus.mode, "exclusive") + search.sessionLocked = true + verify(!search.opened) + verify(search.focusGeneration > generation) + compare(focus.mode, "none") + verify(!search.focusPending) + search.open("ignored") + verify(!search.opened) + search.sessionLocked = false + search.surfaceActive = true + wait(110) + compare(inputSpy.count, 0) + verify(!search.opened) + search.open("fresh") + tryCompare(inputSpy, "count", 1) + } + function test_known_lock_cancels_actual_queued_input_callback() { + search.surfaceActive = false + search.open("") + tryCompare(focus, "mode", "on-demand") + search.surfaceActive = true // actual callback queued, not yet delivered + search.sessionLocked = true + search.sessionLocked = false + wait(100) + compare(inputSpy.count, 0) + verify(!search.opened) + verify(!field.activeFocus) + compare(focus.mode, "none") + } + function test_known_lock_closes_after_input_focus() { + search.open("") + tryCompare(inputSpy, "count", 1) + search.sessionLocked = true + verify(!search.opened) + compare(focus.mode, "none") + verify(!field.activeFocus) + search.sessionLocked = false + wait(100) + verify(!search.opened) + compare(inputSpy.count, 2) // one show, one release; no unlock show + } + function test_mapped_surface_is_primed_on_each_open_and_releases_on_close() { + search.open("") + compare(focus.mode, "exclusive") + tryCompare(focus, "mode", "on-demand") + tryCompare(inputSpy, "count", 1) + search.close() + compare(focus.mode, "none") + search.open("") + compare(focus.mode, "exclusive") + tryCompare(focus, "mode", "on-demand") + tryVerify(function() { return inputSpy.count >= 3 }) + } + function test_prime_waits_for_the_actual_backing_window() { + focus.backingWindowVisible = false + search.open("") + wait(100) + compare(focus.mode, "exclusive") + verify(!focus.inputReady) + compare(inputSpy.count, 0) + focus.backingWindowVisible = true + tryCompare(focus, "mode", "on-demand") + tryCompare(inputSpy, "count", 1) + } + function test_explicit_open_waits_for_its_surface_focus() { + search.surfaceActive = false + search.open("") + wait(30) + compare(inputSpy.count, 0) + verify(search.focusPending) + search.surfaceActive = true + tryCompare(inputSpy, "count", 1) + verify(field.activeFocus) + compare(inputSpy.signalArguments[0][0], true) + } + function test_close_cancels_deferred_focus() { + search.surfaceActive = false + search.open("") + tryCompare(focus, "mode", "on-demand") + search.surfaceActive = true // queues the real deferred focus callback + search.close() // closes before that callback can execute + wait(30) + compare(inputSpy.count, 0) + verify(!search.opened) + verify(!field.activeFocus) + } + function test_manual_hide_is_not_reopened_by_a_late_focus_callback() { + search.open("") + tryCompare(inputSpy, "count", 1) + // The user can hide the OSK while the text field retains focus. + // Further queued callbacks must not issue another show request. + Qt.inputMethod.hide() + search.queueFocus(); search.queueFocus() + wait(30) + compare(inputSpy.count, 1) + verify(!search.focusPending) + } + function test_close_reopen_does_not_adopt_the_previous_focus_request() { + search.open("Notes"); search.close(); search.open("Files") + tryCompare(inputSpy, "count", 1) + compare(search.query, "Files") + compare(library.lastQuery, "Files") + compare(search.entries.length, 1) + } + function test_keyboard_query_uses_the_shared_app_library() { + search.open("") + tryCompare(inputSpy, "count", 1) + keyClick(Qt.Key_N) + keyClick(Qt.Key_O); keyClick(Qt.Key_T); keyClick(Qt.Key_E); keyClick(Qt.Key_S) + tryCompare(search, "query", "notes") + compare(library.lastQuery, "notes") + compare(search.entries[0].id, "example.notes") + } + function test_clear_returns_to_suggestions_without_a_new_focus_request() { + search.open("Notes") + tryCompare(inputSpy, "count", 1) + var clear = findChild(search, "searchClear") + verify(clear.visible) + mouseClick(clear, clear.width / 2, clear.height / 2) + compare(search.query, "") + compare(search.entries.length, 3) + verify(field.activeFocus) + wait(100) + compare(inputSpy.count, 1) + verify(!clear.visible) + } + function test_no_match_stays_in_search_without_an_agent_action() { + search.open("No matching application") + tryCompare(inputSpy, "count", 1) + compare(search.entries.length, 0) + var empty = findChild(search, "searchEmpty") + verify(empty.visible) + compare(empty.text, "No apps found") + keyClick(Qt.Key_Return) + compare(appSpy.count, 0) + verify(search.opened) + } + function test_enter_releases_input_before_the_launch_signal() { + search.open("Notes") + tryCompare(inputSpy, "count", 1) + keyClick(Qt.Key_Return) + compare(appSpy.count, 1) + compare(appSpy.signalArguments[0][0].id, "example.notes") + verify(!search.opened) + verify(!field.activeFocus) + compare(inputSpy.signalArguments[inputSpy.count - 1][0], false) + } + function test_escape_closes_the_native_panel() { + search.open("") + tryCompare(inputSpy, "count", 1) + keyClick(Qt.Key_Escape) + compare(closeSpy.count, 1) + verify(!search.opened) + } + function test_foreground_change_releases_without_hiding_foreign_input() { + search.open("") + tryCompare(inputSpy, "count", 1) + search.surfaceActive = false + compare(closeSpy.count, 1) + compare(inputSpy.count, 1, "no hide request after another window took focus") + verify(!search.opened) + verify(!field.activeFocus) + } + function test_short_keyboard_viewport_keeps_the_input_in_bounds() { + search.open("") + tryCompare(inputSpy, "count", 1) + view.width = 740; view.height = 88 + waitForPolish(search) + tryVerify(function() { + var at = field.mapToItem(search, 0, 0) + return field.height >= 44 && at.y >= 0 && at.y + field.height <= search.height + }, 1000) + verify(!findChild(search, "searchResults").visible) + } + function test_layout_tracks_the_actual_available_viewport() { + search.open("") + tryCompare(inputSpy, "count", 1) + view.width = 740; view.height = 320 + waitForPolish(search) + verify(field.height >= 44) + verify(field.y + field.height <= search.height) + var list = findChild(search, "searchResults") + verify(list.height > 0) + var inputAt = field.mapToItem(search, 0, 0) + var listAt = list.mapToItem(search, 0, 0) + verify(listAt.y >= inputAt.y + field.height) + verify(listAt.y + list.height <= search.height) + var close = findChild(search, "searchClose") + verify(close.width >= 44 && close.height >= 44) + } + } +} diff --git a/packages/omamobile-shell/test/back-surfaces.py b/packages/omamobile-shell/test/back-surfaces.py index 39258735e..63eec8214 100755 --- a/packages/omamobile-shell/test/back-surfaces.py +++ b/packages/omamobile-shell/test/back-surfaces.py @@ -25,6 +25,7 @@ # file -> the names its blocks register under, in file order EXPECT = { + "omamobile.launcher/Launcher.qml": ["app search"], "omamobile.keyboard/Keyboard.qml": ["keyboard languages", "keyboard"], "omamobile.access/Access.qml": ["permission sheet"], "omamobile.fingerprint/Fingerprint.qml": ["fingerprint setup"], @@ -83,6 +84,8 @@ def body_of(text, head): property alias cell: owlCell QtObject { id: root + property bool searchOpened: false + function closeSearch() { note("closeSearch"); searchOpened = false } property bool oskOpen: false property bool languagesOpen: false property bool opened: false @@ -138,6 +141,7 @@ def body_of(text, head): function names() { return BackLink.names().join(",") } function sent() { return Quickshell.executed.length } + Component { id: search; SurfAppSearch {} } Component { id: kb; SurfKeyboard {} } Component { id: lang; SurfKeyboardLanguages {} } Component { id: perm; SurfPermissionSheet {} } @@ -167,6 +171,20 @@ def body_of(text, head): compare(JSON.stringify(Quickshell.executed[0]), JSON.stringify(BackModel.ESCAPE_ARGV)) } + function test_searchKeyboardFirst() { + var keys = make(kb) + var view = make(search) + view.fake.searchOpened = true + keys.fake.oskOpen = true + compare(back(), "keyboard") + verify(view.fake.searchOpened) + compare(sent(), 0) + compare(back(), "app search") + verify(!view.fake.searchOpened) + compare(names(), "") + compare(sent(), 0) + } + function test_keyboard() { alone(make(kb), "keyboard", function(o) { o.fake.oskOpen = true }, "hideKeyboard") } function test_permissionSheet() { alone(make(perm), "permission sheet", function(o) { o.fake.opened = true }, "back") } function test_fingerprintSetup() { alone(make(finger), "fingerprint setup", function(o) { o.fake.screenOpen = true }, "back") } diff --git a/packages/omamobile-shell/test/drawer-touch b/packages/omamobile-shell/test/drawer-touch index a763b6b42..1a385896c 100755 --- a/packages/omamobile-shell/test/drawer-touch +++ b/packages/omamobile-shell/test/drawer-touch @@ -68,6 +68,9 @@ Item { hide: function(id) { root.calls = root.calls.concat(["hide"]); root.close(); return true } }) readonly property string pluginId: "omamobile.launcher" + // Search is tested separately; these are the drawer's lifecycle calls. + property QtObject appsSearch: QtObject { function close() {} } + property bool searchOpened: false property bool opened: false property string query: "" property var apps: [] diff --git a/packages/omamobile-shell/test/drawer-touch.qml b/packages/omamobile-shell/test/drawer-touch.qml index 95b40b69b..a4f9c65ed 100644 --- a/packages/omamobile-shell/test/drawer-touch.qml +++ b/packages/omamobile-shell/test/drawer-touch.qml @@ -38,6 +38,7 @@ Item { } function init() { + harness.searchOpened = false harness.close() tryCompare(harness, "progress", 0, 3000) harness.calls = [] @@ -265,6 +266,13 @@ Item { compare(layoutOf(), closed, "closed again") } + function test_no_home_swipe_while_native_search_is_open() { + harness.searchOpened = true + verify(!harness.gestureBegin()) + compare(harness.progress, 0) + harness.searchOpened = false + } + function test_no_home_swipe_while_open() { openSettled() verify(!harness.gestureBegin(), "an open drawer ignores the home screen's swipe") diff --git a/packages/omamobile-shell/test/fixtures/apps-search-icons/calendar.svg b/packages/omamobile-shell/test/fixtures/apps-search-icons/calendar.svg new file mode 100644 index 000000000..63f458ea9 --- /dev/null +++ b/packages/omamobile-shell/test/fixtures/apps-search-icons/calendar.svg @@ -0,0 +1,2 @@ + + diff --git a/packages/omamobile-shell/test/fixtures/apps-search-icons/files.svg b/packages/omamobile-shell/test/fixtures/apps-search-icons/files.svg new file mode 100644 index 000000000..f890fbd6d --- /dev/null +++ b/packages/omamobile-shell/test/fixtures/apps-search-icons/files.svg @@ -0,0 +1,2 @@ + + diff --git a/packages/omamobile-shell/test/fixtures/apps-search-icons/notes.svg b/packages/omamobile-shell/test/fixtures/apps-search-icons/notes.svg new file mode 100644 index 000000000..f51547e3b --- /dev/null +++ b/packages/omamobile-shell/test/fixtures/apps-search-icons/notes.svg @@ -0,0 +1,2 @@ + + diff --git a/packages/omamobile-shell/test/fixtures/apps-search-icons/photos.svg b/packages/omamobile-shell/test/fixtures/apps-search-icons/photos.svg new file mode 100644 index 000000000..b6e82d0d1 --- /dev/null +++ b/packages/omamobile-shell/test/fixtures/apps-search-icons/photos.svg @@ -0,0 +1,2 @@ + + diff --git a/packages/omamobile-shell/test/fixtures/apps-search-icons/weather.svg b/packages/omamobile-shell/test/fixtures/apps-search-icons/weather.svg new file mode 100644 index 000000000..e5e967e2b --- /dev/null +++ b/packages/omamobile-shell/test/fixtures/apps-search-icons/weather.svg @@ -0,0 +1,2 @@ + + diff --git a/packages/omamobile-shell/test/home-model.js b/packages/omamobile-shell/test/home-model.js index 4bfb9bf77..b4db33473 100644 --- a/packages/omamobile-shell/test/home-model.js +++ b/packages/omamobile-shell/test/home-model.js @@ -733,6 +733,10 @@ test("Back is the home screen's only with nothing open over it", () => { let over = {} for (const ns of M.BACK_FURNITURE) over = M.overAfter(over, "openlayer", ns) assert.deepStrictEqual(over, {}, "the bar, the dock, the pill, toasts and the keyboard are part of the screen") + for (const ns of ["omamobile-app-search", "omamobile-app-search-background"]) { + assert.deepStrictEqual(M.overAfter({}, "openlayer", ns), {}, + "the always-mapped Search layer must not permanently disable Home Back") + } over = M.overAfter(over, "openlayer", "omamobile-quicksettings") assert.deepStrictEqual(over, { "omamobile-quicksettings": 1 }) over = M.overAfter(over, "openlayer", "omarchy-menu") diff --git a/packages/omamobile-shell/test/pill-touch b/packages/omamobile-shell/test/pill-touch index 494d2d6cc..18de8bc02 100755 --- a/packages/omamobile-shell/test/pill-touch +++ b/packages/omamobile-shell/test/pill-touch @@ -95,6 +95,9 @@ Item { readonly property int dockHeight: 96 property bool appOnScreen: false property bool opened: false + property bool searchOpened: false + property var settings: ({nativeSearch:false}) + function closeSearch() { root.searchOpened = false } property bool oskOpen: false property bool fullscreenOnScreen: false property bool sessionLocked: false @@ -115,6 +118,7 @@ Item { readonly property string agentName: "" readonly property color foreground: "#c0caf5" function expand() { Quickshell.execDetached(["expand"]) } + function openSearch(text) { root.searchOpened=true; Quickshell.execDetached(["native-search",text]) } function dismiss(speed) { Quickshell.execDetached(["dismiss"]) } %s @@ -169,7 +173,7 @@ Item { """ % ("root." + strip_height if not strip_height.isdigit() else strip_height, definition("stripShown"), definition("keyboardStripShown"), definition("dockShown"), zone("omamobile-dock"), zone("omamobile-home-strip"), - function("goHome"), function("showRecents"), function("keyboardCall"), function("voiceHold") + "\n\n" + function("voiceCall"), + function("activateDock") + "\n\n" + function("goHome"), function("showRecents"), function("keyboardCall"), function("voiceHold") + "\n\n" + function("voiceCall"), content.replace("root.oskOpen", "false"), window_content("omamobile-dock"), content.replace("root.oskOpen", "true"), component("SearchPill"), component("HomePill"), component("HomeSwipe")) open(sys.argv[2], "w").write(out) @@ -177,4 +181,4 @@ PY cp "$here/pill-touch.qml" "$work/tst_pill_touch.qml" export QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software QML_DISABLE_DISK_CACHE=1 -exec "$runner" -import "$here/qml-stubs" -input "$work/tst_pill_touch.qml" +exec "$runner" -import "$here/qml-stubs" -input "$work/tst_pill_touch.qml" "$@" diff --git a/packages/omamobile-shell/test/pill-touch.qml b/packages/omamobile-shell/test/pill-touch.qml index 6c34f5422..50d5e973e 100644 --- a/packages/omamobile-shell/test/pill-touch.qml +++ b/packages/omamobile-shell/test/pill-touch.qml @@ -34,6 +34,8 @@ Item { // towards the next one's. wait(600) Quickshell.executed = [] + harness.searchOpened = false + harness.settings = ({nativeSearch:false}) } function calls(fragment) { @@ -99,6 +101,32 @@ Item { return Quickshell.executed.filter(function(argv) { return argv.join(" ").indexOf("fbcli -E button-pressed") >= 0 }).length } + function test_native_search_keeps_home_reachable_after_manual_keyboard_hide() { + harness.appOnScreen = false + harness.opened = false + harness.fullscreenOnScreen = false + harness.sessionLocked = false + harness.searchOpened = true + harness.oskOpen = false + compare(harness.stripZone, harness.stripHeight) + compare(harness.dockZone, 0) + harness.goHome() + verify(!harness.searchOpened) + } + + function test_stale_lock_does_not_hide_strip_over_an_app_with_keyboard_hidden() { + harness.appOnScreen = true + harness.opened = false + harness.fullscreenOnScreen = false + harness.searchOpened = false + harness.oskOpen = false + harness.sessionLocked = true + compare(harness.stripZone, harness.stripHeight) + harness.oskOpen = true + compare(harness.stripZone, 0) + verify(!harness.keyboardStripShown) + } + function test_holding_the_pill_opens_the_voice_bar_with_a_tick() { var strips = ["pillStrip", "keyboardStrip"] for (var i = 0; i < strips.length; i++) { @@ -178,6 +206,17 @@ Item { // The dock's search pill on the home screen: a tap opens the drawer // (with the keyboard), a hold opens the voice bar, a swipe recent apps. + function test_a_tap_on_the_search_pill_selects_native_search_when_enabled() { + harness.settings = ({nativeSearch:true}) + var dock = find(harness, "dock") + tap(dock, dock.width / 2, dock.height / 2) + wait(600) + compare(calls("native-search"), 1) + compare(calls("expand"), 0) + verify(harness.searchOpened) + compare(voiceCalls("start"), 0) + } + function test_a_tap_on_the_search_pill_opens_the_drawer() { var dock = find(harness, "dock") tap(dock, dock.width / 2, dock.height / 2)