diff --git a/packages/omamobile-shell/plugins/README.md b/packages/omamobile-shell/plugins/README.md index 6209a381d..c4067d3ce 100644 --- a/packages/omamobile-shell/plugins/README.md +++ b/packages/omamobile-shell/plugins/README.md @@ -333,8 +333,9 @@ The home surface, after Omalauncher: one bar along the bottom of the screen. * **Home pill (over an app, where the dock is hidden).** A light bar with a dark outline, centred in a 44 px bar-coloured strip along the bottom edge (`omamobile-home-strip`, bottom layer). Swipe up from anywhere along it to - go home; swipe up and hold, or further, for recent apps; double-tap it for - the keyboard. + go home, however far; swipe up and hold still for recent apps, as on iOS + and Android (up to 0.2.133 a swipe past 120 px opened recent apps too, and + an ordinary swipe is longer than that); double-tap it for the keyboard. The strip reserves its height (an exclusive zone), as Android's gesture-nav inset does, so windows end above it and nothing of the app is under the diff --git a/packages/omamobile-shell/plugins/omamobile.keyboard/Keyboard.qml b/packages/omamobile-shell/plugins/omamobile.keyboard/Keyboard.qml index 1dd9a961a..012e09cbb 100644 --- a/packages/omamobile-shell/plugins/omamobile.keyboard/Keyboard.qml +++ b/packages/omamobile-shell/plugins/omamobile.keyboard/Keyboard.qml @@ -202,7 +202,18 @@ Item { shownByHand = KeyboardModel.shownByHandAfter(shownByHand, oskOpen) checkHome() } - onHomeOnScreenChanged: checkHome() + // Any keyboard still up as the home screen comes up goes too + // (KeyboardModel.js has why): the application under it may have kept its + // text field. + property bool wasHome: false + onHomeOnScreenChanged: { + if (KeyboardModel.hideAsHomeComesUp(wasHome, homeOnScreen, oskOpen)) { + console.log("omamobile.keyboard: home screen up, hiding the keyboard") + setVisible(false) + } + wasHome = homeOnScreen + checkHome() + } Process { id: oskWatch diff --git a/packages/omamobile-shell/plugins/omamobile.keyboard/KeyboardModel.js b/packages/omamobile-shell/plugins/omamobile.keyboard/KeyboardModel.js index b84741f6a..bdb8f9bdc 100644 --- a/packages/omamobile-shell/plugins/omamobile.keyboard/KeyboardModel.js +++ b/packages/omamobile-shell/plugins/omamobile.keyboard/KeyboardModel.js @@ -10,8 +10,17 @@ // changes no input method, so the keyboard stayed up over the home screen // (and a second double tap could re-show it on the way: "random"). So the // plugin remembers that it showed the keyboard, and puts such a keyboard -// away when the home screen comes up. A keyboard squeekboard showed on its -// own is left to squeekboard, which hides it when the field goes away. +// away when the home screen comes up. +// +// A keyboard that came up for a text field mostly goes by itself: GTK and +// the browser give their text field up when their window loses the keyboard +// focus, and the input method deactivates. An application that keeps it (a +// GPUI one did, on a Pixel 9a with Hyprland 0.57) leaves the input method +// active when an empty workspace takes the focus, and the keyboard stayed up +// over the home screen after a swipe home. So whatever keyboard is up at +// the moment the home screen comes up is put away too (hideAsHomeComesUp). +// One that comes up later, for the drawer's search field, is not touched: +// the home screen was up already. // Whether the keyboard is still one shown by hand after a visibility report // from omamobile-osk-watch: hiding ends it, showing keeps what we knew. @@ -34,6 +43,12 @@ function shouldHide(shownByHand, visible, home) { return !!(shownByHand && visible && home) } +// Hide now: the home screen has just come up (it was not up before) and a +// keyboard is still showing, whoever showed it. +function hideAsHomeComesUp(wasHome, home, visible) { + return !!(!wasHome && home && visible) +} + // The pill's double tap: show the keyboard when it is down, hide it when // it is up. Its visibility reaches the plugin a moment after a show or a // hide (omamobile-osk-watch, on the session bus), so a second double tap @@ -97,6 +112,7 @@ function addRows(listing) { if (typeof module !== "undefined") { module.exports = { shownByHandAfter: shownByHandAfter, homeOnScreen: homeOnScreen, shouldHide: shouldHide, + hideAsHomeComesUp: hideAsHomeComesUp, TOGGLE_SETTLE_MS: TOGGLE_SETTLE_MS, toggleTarget: toggleTarget, parseListing: parseListing, languageRows: languageRows, addRows: addRows } } diff --git a/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml b/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml index 8ccbb3505..87046a7f7 100644 --- a/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml @@ -462,8 +462,8 @@ Item { // Over an app, where the dock is hidden: a thin bar-coloured strip with a // pill, as on iOS. Swipe up on it to go home (the empty workspace, where - // the dock is back); swipe up and hold (or a long swipe) for recent apps, - // as on Android. + // the dock is back); swipe up and hold for recent apps, as on iOS and + // Android. // // It reserves its height (an exclusive zone), as Android's gesture-nav // inset does, so windows end above it: with no zone, the pill covered the @@ -1169,15 +1169,21 @@ Item { } } - // Where a home swipe starts. Swipe up and let go: home. Swipe up and hold - // still for a moment (or swipe far up): recent apps, while the finger is - // still down, as Android's gesture navigation does. Double-tap: show or - // hide the on-screen keyboard. Hold still: ask the agent by voice - // (omamobile.voice) until the finger lets go. strip names the surface in - // the log: "pill" over an app, "keyboard" under the keyboard. + // Where a home swipe starts. Swipe up and let go: home, however far the + // finger went. Swipe up and hold still for a moment: recent apps, while + // the finger is still down, as iOS's and Android's gesture navigation do. + // Up to 0.2.133 a swipe further than 120 px opened recent apps too, and an + // ordinary swipe is longer than that, so going home took a deliberately + // short flick. Double-tap: show or hide the on-screen keyboard. Hold still: + // ask the agent by voice (omamobile.voice) until the finger lets go. strip + // names the surface in the log: "pill" over an app, "keyboard" under the + // keyboard. component HomeSwipe: Item { id: swipeArea property string strip: "pill" + // A resting finger still shifts a little: the hold's wait starts again + // only when the finger has moved on by more than this. + readonly property int holdSlop: 8 // Items over the strip whose taps are their own: a tap there is never // half of a double tap, and a hold there isn't the pill's. None since // 0.2.61 (the pill is the whole bar), kept for keys a layout may add. @@ -1226,21 +1232,22 @@ Item { xAxis.enabled: false property real swipeY: 0 property bool recents: false + // Where the finger was when the hold's wait last began + property real restY: 0 onActiveTranslationChanged: { swipeY = activeTranslation.y // Over the open drawer a swipe only closes it: recent apps from // there left the drawer half open over the next app. if (recents || root.opened) return - if (swipeY < -120) { - recents = true + if (swipeY >= -24) { hold.stop() - root.showRecents() - } else if (swipeY < -24) { + } else if (!hold.running || Math.abs(swipeY - restY) > swipeArea.holdSlop) { + restY = swipeY hold.restart() } } onActiveChanged: { - if (active) { swipeY = 0; recents = false; return } + if (active) { swipeY = 0; restY = 0; recents = false; return } hold.stop() console.log("omamobile-home-indicator: swipe", Math.round(swipeY), recents ? "recents" : "", "(" + swipeArea.strip + ")") if (!recents && swipeY < -24 && root.opened) { diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 0b80220d4..981087055 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -211,11 +211,14 @@ if [[ $rc == 77 ]]; then elif [[ $rc != 0 ]]; then printf '%s\n' "$out" | grep -vE '^(PASS|QDEBUG)' >&2; fail "the home pill under touch (test/pill-touch)" else - pass "the home pill under touch: a double tap toggles the keyboard, a tap does nothing, swipes go home, the hide key, the reserved strip, the search pill, the hold for voice" + pass "the home pill under touch: a double tap toggles the keyboard, a tap does nothing, swipes of any length go home, a swipe held still opens recent apps, the hide key, the reserved strip, the search pill, the hold for voice" fi grep -c '} else if (!recents && swipeY < -24) root.goHome()' "$l" >/dev/null || fail "a short swipe goes home" grep -c 'if (recents || root.opened) return' "$l" >/dev/null || fail "over the drawer a swipe opens no recent apps" -grep -c 'if (swipeY < -120) {' "$l" >/dev/null || fail "a long swipe opens recent apps" +# A swipe goes home however long it is; only a finger held still opens recent +# apps (up to 0.2.133 a swipe past 120 px did too, and an ordinary one is longer). +grep -c 'swipeY < -120' "$l" >/dev/null && fail "a long swipe goes home, not to recent apps" +grep -c '} else if (!hold.running || Math.abs(swipeY - restY) > swipeArea.holdSlop) {' "$l" >/dev/null || fail "the hold waits for a finger at rest, whatever small shifts it makes" # Drawer: pull down to close, and a pull is not also a tap on an app. grep -c 'if (LauncherModel.drawerEndsOpen(root.progress, speed, true)) root.settleTo(true, speed)' "$l" >/dev/null || fail "pulling the drawer down closes it" grep -c 'onClicked: if (!root.pullMoved) cell.tapped()' "$l" >/dev/null || fail "a pull doesn't launch the app under it" @@ -450,19 +453,23 @@ grep -c '"sm.puri.OSK0", "SetVisible", "b", visible ? "true" : "false"' plugins/ pass "on-screen keyboard watcher and calls" # A keyboard shown by hand (the pill's double tap) is put away when the home -# screen comes up; one squeekboard showed for a text field is left alone. +# screen comes up, and so is any keyboard still up at that moment (its +# application may have kept its text field). k=plugins/omamobile.keyboard/Keyboard.qml grep -c 'import "KeyboardModel.js" as KeyboardModel' "$k" >/dev/null || fail "the keyboard plugin imports its model" grep -c 'readonly property bool homeOnScreen: KeyboardModel.homeOnScreen(Hyprland.focusedWorkspace)' "$k" >/dev/null || fail "the keyboard plugin follows the home screen" grep -c 'if (!KeyboardModel.shouldHide(shownByHand, oskOpen, homeOnScreen)) return' "$k" >/dev/null || fail "the keyboard plugin hides by the model's rule" -grep -c 'onHomeOnScreenChanged: checkHome()' "$k" >/dev/null && grep -c 'shownByHand = KeyboardModel.shownByHandAfter(shownByHand, oskOpen)' "$k" >/dev/null \ +grep -A8 'onHomeOnScreenChanged: {' "$k" | grep -c 'checkHome()' >/dev/null && grep -c 'shownByHand = KeyboardModel.shownByHandAfter(shownByHand, oskOpen)' "$k" >/dev/null \ || fail "the rule is checked when the home screen or the keyboard changes" +grep -A3 'onHomeOnScreenChanged: {' "$k" | grep -c 'if (KeyboardModel.hideAsHomeComesUp(wasHome, homeOnScreen, oskOpen)) {' >/dev/null \ + && grep -A8 'onHomeOnScreenChanged: {' "$k" | grep -c 'wasHome = homeOnScreen' >/dev/null \ + || fail "a keyboard still up as the home screen comes up is put away" grep -A3 'function setVisible(visible) {' "$k" | grep -c 'shownByHand = visible' >/dev/null || fail "showing by hand is remembered" grep -c 'var show = KeyboardModel.toggleTarget(oskOpen, lastRequest, Date.now() - lastRequestAt)' "$k" >/dev/null || fail "a second double tap hides the keyboard, even before the first show is reported" if command -v node >/dev/null; then node test/keyboard-model.js >/dev/null || { node test/keyboard-model.js; fail "keyboard model"; } fi -pass "a keyboard shown by hand goes away on the home screen" +pass "a keyboard shown by hand, or still up for an app, goes away as the home screen comes up" # The keyboard in the Omarchy theme and its action row (Mic, Paste, Emoji, # Hide): the stylesheet from a sample theme, the layouts as diff --git a/packages/omamobile-shell/test/keyboard-model.js b/packages/omamobile-shell/test/keyboard-model.js index b632b6df4..0010145d0 100644 --- a/packages/omamobile-shell/test/keyboard-model.js +++ b/packages/omamobile-shell/test/keyboard-model.js @@ -14,7 +14,11 @@ function plugin() { p.check = () => { if (M.shouldHide(p.shownByHand, p.oskOpen, p.home)) p.setVisible(false) } p.setVisible = (v) => { p.shownByHand = v; p.calls.push(v) } p.report = (v) => { p.oskOpen = v; p.shownByHand = M.shownByHandAfter(p.shownByHand, v); p.check() } - p.goHome = (h) => { p.home = h; p.check() } + p.goHome = (h) => { + if (M.hideAsHomeComesUp(p.home, h, p.oskOpen)) p.setVisible(false) + p.home = h + p.check() + } return p } @@ -41,13 +45,29 @@ test("the order doesn't matter: shown by hand just after home came up", () => { assert.deepStrictEqual(p.calls, [true, false]) }) -test("a keyboard squeekboard showed for a text field is left to squeekboard", () => { +test("a keyboard up for a text field is put away too as the home screen comes up", () => { + const p = plugin() + p.report(true) // a field took focus, and its application keeps it + p.goHome(true) + assert.deepStrictEqual(p.calls, [false]) +}) + +test("one that comes up on the home screen, for the drawer's search field, stays", () => { const p = plugin() - p.report(true) // a field took focus p.goHome(true) + p.report(true) + assert.deepStrictEqual(p.calls, []) + p.goHome(true) // still home: nothing came up assert.deepStrictEqual(p.calls, []) }) +test("the home screen coming up is the moment: not staying home, not leaving it", () => { + assert.strictEqual(M.hideAsHomeComesUp(false, true, true), true) + assert.strictEqual(M.hideAsHomeComesUp(true, true, true), false) + assert.strictEqual(M.hideAsHomeComesUp(true, false, true), false) + assert.strictEqual(M.hideAsHomeComesUp(false, true, false), false) +}) + test("hiding ends 'shown by hand': a later automatic keyboard on home stays", () => { const p = plugin() p.setVisible(true); p.report(true) diff --git a/packages/omamobile-shell/test/pill-touch.qml b/packages/omamobile-shell/test/pill-touch.qml index 6c34f5422..5eea1dcd0 100644 --- a/packages/omamobile-shell/test/pill-touch.qml +++ b/packages/omamobile-shell/test/pill-touch.qml @@ -296,6 +296,83 @@ Item { compare(keyboardCalls("Keyboard"), 0, "a swipe is no tap") } + // Home however far the finger went: an ordinary swipe is longer than the + // 120 px that opened recent apps up to 0.2.133. + function test_a_long_swipe_goes_home_too() { + var strip = find(harness, "pillStrip") + var x = strip.width / 2, y = strip.height / 2 + var t = touchEvent(strip) + t.press(0, strip, x, y).commit() + for (var dy = 12; dy <= 360; dy += 12) { + t.move(0, strip, x, y - dy).commit() + wait(5) + } + t.release(0, strip, x, y - 360).commit() + wait(30) + compare(calls("omamobile.switcher"), 0, "no recent apps: " + JSON.stringify(Quickshell.executed)) + compare(calls("hl.dsp.focus"), 1, "home") + } + + // Recent apps while the finger is still down, as on iOS and Android. A + // finger at rest shifts by a pixel or two, which must not start the wait + // again. + function test_a_swipe_held_still_opens_recent_apps() { + var strip = find(harness, "pillStrip") + var x = strip.width / 2, y = strip.height / 2 + var t = touchEvent(strip) + t.press(0, strip, x, y).commit() + for (var dy = 12; dy <= 180; dy += 12) { + t.move(0, strip, x, y - dy).commit() + wait(5) + } + compare(calls("omamobile.switcher"), 0, "not yet: " + JSON.stringify(Quickshell.executed)) + for (var i = 0; i < 12; i++) { + t.move(0, strip, x + (i % 2), y - 180 - (i % 3)).commit() + wait(50) + } + compare(calls("omamobile.switcher"), 1, "recent apps, the finger still down: " + JSON.stringify(Quickshell.executed)) + t.release(0, strip, x, y - 181).commit() + wait(30) + compare(calls("omamobile.switcher"), 1, "once") + compare(calls("hl.dsp.focus"), 0, "and not home as well") + } + + function test_a_slow_swipe_is_no_hold() { + var strip = find(harness, "pillStrip") + var x = strip.width / 2, y = strip.height / 2 + var t = touchEvent(strip) + t.press(0, strip, x, y).commit() + for (var dy = 12; dy <= 144; dy += 12) { + t.move(0, strip, x, y - dy).commit() + wait(100) + } + t.release(0, strip, x, y - 144).commit() + wait(30) + compare(calls("omamobile.switcher"), 0, "it kept moving: " + JSON.stringify(Quickshell.executed)) + compare(calls("hl.dsp.focus"), 1, "home") + } + + // Back down to where it began before it rests: neither. + function test_a_swipe_taken_back_does_nothing() { + var strip = find(harness, "pillStrip") + var x = strip.width / 2, y = strip.height / 2 + var t = touchEvent(strip) + t.press(0, strip, x, y).commit() + for (var dy = 12; dy <= 96; dy += 12) { + t.move(0, strip, x, y - dy).commit() + wait(5) + } + for (dy = 84; dy >= 12; dy -= 12) { + t.move(0, strip, x, y - dy).commit() + wait(5) + } + wait(500) + t.release(0, strip, x, y - 12).commit() + wait(30) + compare(calls("omamobile.switcher"), 0, JSON.stringify(Quickshell.executed)) + compare(calls("hl.dsp.focus"), 0) + } + function test_double_tap_in_the_keyboard_strip_toggles_the_keyboard() { var strip = find(harness, "keyboardStrip") tap(strip, strip.width / 2, strip.height / 2) diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index 89bb7cae3..3abec2f78 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.133 +0.2.134