From 71e2f5ef4e4dd03b0933a27197e69f768675f65c Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 19 Nov 2026 04:06:44 +0800 Subject: [PATCH 1/2] On-screen keyboard: a tap that focuses a field opens it, in any app With Qt's text-input focus fix, a field going off closes the keyboard, but Qt still believes the keyboard is up and asks nothing when the same field is tapped again, so it stayed closed. A field that takes focus while the finger is down was tapped: it opens the keyboard whatever its text-input version. Focus moved by an app on its own or after the finger lifted still does not, and a keyboard already up is not shown twice. Assisted-by: LLM --- desktop/shell/bin/omarchy-keyboard | 12 ++++++++++-- tests/test_keyboard_policy.py | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/desktop/shell/bin/omarchy-keyboard b/desktop/shell/bin/omarchy-keyboard index a57ba61f..5d9de2c5 100644 --- a/desktop/shell/bin/omarchy-keyboard +++ b/desktop/shell/bin/omarchy-keyboard @@ -114,6 +114,7 @@ class Policy: self.asked_until = 0.0 # an app asked before its field came on self.hide_at = None self.hide_asked = False # the app asked to hide; held back like a field going off + self.pressing = False # a finger is down on the focused surface self.opened_here = False self.hardware = False # typing on a physical keyboard self.keyboards = 0 @@ -124,7 +125,8 @@ class Policy: if self.hardware: return self.opened_here = True - self._show() + if not self._visible(): # a field taking focus and the app asking are one tap + self._show() def _close(self): self.hide_at, self.hide_asked = None, False @@ -137,7 +139,11 @@ class Policy: words = line.split() if words[:2] == ["field", "on"] and len(words) == 3 and words[2].isdigit(): self.field, self.hide_at = int(words[2]), None - if now < self.asked_until or (self.field < 2 and now < self.tapped_until): + # A field that takes focus while the finger is down was tapped, + # whatever version: Qt does not ask again for a keyboard it + # thinks is still up, after one that closed on its own. + if now < self.asked_until or (self.pressing and now < self.touched_until) \ + or (self.field < 2 and now < self.tapped_until): self._open() elif words == ["field", "off"]: self.field = 0 @@ -157,7 +163,9 @@ class Policy: self.hide_at, self.hide_asked = now + self.HIDE_DELAY, True elif words == ["press"]: self.touched_until = now + self.TOUCH_WINDOW + self.pressing = True elif words[:1] == ["release"] and len(words) == 3 and words[1].isdigit() and words[2].isdigit(): + self.pressing = False if int(words[1]) <= self.TAP_MS and int(words[2]) <= self.TAP_PX: self.touched_until = self.tapped_until = now + self.TOUCH_WINDOW if 0 < self.field < 2: diff --git a/tests/test_keyboard_policy.py b/tests/test_keyboard_policy.py index 536ae081..3f69ce99 100644 --- a/tests/test_keyboard_policy.py +++ b/tests/test_keyboard_policy.py @@ -142,17 +142,33 @@ def test_a_tap_after_the_person_put_it_away_opens_it_again(self): # Qt is not told of the swipe; the field asks hide-then-show to be heard. self.facts('field on 2', 'press', 'show') self.policy.person('hide') + self.shown = False # the swipe put it away self.calls.clear() self.wait(1) self.facts('press', 'hide', 'show') self.wait(1) self.assertEqual(self.calls, ['show']) + def test_tapping_the_same_field_again_after_it_closed_on_its_own_opens_it(self): + # Qt with the focus fix: tapping outside turns the field off; Qt still + # thinks the keyboard is up and asks nothing on the next tap. + self.facts('press', 'field on 2', TAP, 'show') + self.facts('press', 'field off', TAP) + self.wait(1) + self.facts('press', 'field on 2', TAP) + self.wait(1) + self.assertEqual(self.calls, ['show', 'hide', 'show']) + + def test_a_field_focused_after_the_finger_lifts_does_not_open_it(self): + self.facts('press', TAP, 'field on 2') # a click handler focusing a field + self.wait(1) + self.assertEqual(self.calls, []) + def test_hide_then_show_at_once_does_not_blink_an_open_keyboard(self): self.facts('field on 2', 'press', 'show') self.facts('press', 'hide', 'show') self.wait(1) - self.assertEqual(self.calls, ['show', 'show']) + self.assertEqual(self.calls, ['show']) # still up, not shown twice def test_one_the_person_opened_stays_when_the_field_goes(self): self.facts('field on 2') @@ -165,6 +181,7 @@ def test_one_the_person_opened_stays_when_the_field_goes(self): def test_one_the_person_put_away_stays_away_until_the_next_tap(self): self.facts('field on 2', 'press', 'show') self.policy.person('hide') + self.shown = False # the swipe put it away self.wait(1) self.facts('show', 'field off', 'field on 2') self.wait(1) From 1a10e839fd16db8bd0e17596e68b996c829307a9 Mon Sep 17 00:00:00 2001 From: Henrik Klee Date: Thu, 19 Nov 2026 04:10:56 +0800 Subject: [PATCH 2/2] On-screen keyboard: an app's request right after a touch opens it Qt 6.12 on a field tapped again after focus went elsewhere sends show_input_panel at once but enables its text input only with the next press, and disables it again right after (simulator facts log). The policy waited for the field and never opened. A request right after a touch now opens the keyboard by itself: Qt asks only for a text item it focused, and the keyboard types through key presses either way. Assisted-by: LLM --- desktop/shell/bin/omarchy-keyboard | 9 +++++---- tests/test_keyboard_policy.py | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/desktop/shell/bin/omarchy-keyboard b/desktop/shell/bin/omarchy-keyboard index 5d9de2c5..2951fcde 100644 --- a/desktop/shell/bin/omarchy-keyboard +++ b/desktop/shell/bin/omarchy-keyboard @@ -150,11 +150,12 @@ class Policy: if self.opened_here: self.hide_at = now + self.HIDE_DELAY elif words == ["show"]: + # Asked for right after a touch: Qt asks only for a text item it + # focused, and may enable its text input only at the next input + # event (a field tapped again after focus went elsewhere), so the + # request is enough. The keyboard types through key presses. if now < self.touched_until: - if self.field: - self._open() - else: - self.asked_until = now + self.SHOW_WAIT + self._open() elif words == ["hide"]: # Held back a moment: an app that asks to hide and show again at # once (to be heard after the person put the keyboard away) must diff --git a/tests/test_keyboard_policy.py b/tests/test_keyboard_policy.py index 3f69ce99..c299f2df 100644 --- a/tests/test_keyboard_policy.py +++ b/tests/test_keyboard_policy.py @@ -83,10 +83,10 @@ def test_a_request_before_its_field_is_kept_a_moment(self): self.facts('press', TAP, 'show', 'field on 2') # Folio: the path label becomes a field self.assertEqual(self.calls, ['show']) - def test_a_request_long_before_its_field_is_not(self): - self.facts('press', TAP, 'show') + def test_a_request_long_after_a_tap_is_not(self): + self.facts('press', TAP) self.wait(1) - self.facts('field on 2') + self.facts('show', 'field on 2') # an app asking by itself later self.assertEqual(self.calls, []) def test_a_tap_in_a_version_1_field_opens_it(self): @@ -159,6 +159,19 @@ def test_tapping_the_same_field_again_after_it_closed_on_its_own_opens_it(self): self.wait(1) self.assertEqual(self.calls, ['show', 'hide', 'show']) + def test_a_request_after_a_tap_opens_it_before_qt_enables_its_field(self): + # Qt 6.12 on a field tapped again: show at once, the enable only with + # the next press, and disabled again right after. + self.facts('press', 'field on 2', TAP, 'show') + self.facts('press', 'field off', TAP) + self.wait(1) + self.facts('press', TAP, 'show') + self.wait(1) + self.assertEqual(self.calls, ['show', 'hide', 'show']) + self.facts('press', 'field on 2', 'field off', TAP) + self.wait(1) + self.assertEqual(self.calls, ['show', 'hide', 'show', 'hide']) + def test_a_field_focused_after_the_finger_lifts_does_not_open_it(self): self.facts('press', TAP, 'field on 2') # a click handler focusing a field self.wait(1)