From 890edc6f9aaff23d943bc337a9a1c65ab41d9b58 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 16 May 2026 21:39:26 +0100 Subject: [PATCH] [presto] reduce touch debounce while searching --- presto/main.py | 10 +++++++++- presto/tests/test_screens.py | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/presto/main.py b/presto/main.py index 6c1e6f77..de64930e 100644 --- a/presto/main.py +++ b/presto/main.py @@ -173,6 +173,7 @@ MONTH_NAMES = [ # Touch debounce (milliseconds) DEBOUNCE_MS = 300 +KEYBOARD_DEBOUNCE_MS = 80 DRAG_REDRAW_MS = 40 DRAG_REDRAW_PX = px(8) TOUCH_RELEASE_TIMEOUT_MS = 3_000 @@ -2287,6 +2288,13 @@ def read_touch(): return None +def _touch_debounce_ms(app): + """Return the active debounce threshold for the current screen.""" + if app.screen == STATE_SEARCH_INPUT: + return KEYBOARD_DEBOUNCE_MS + return DEBOUNCE_MS + + def _normalise_touch(point): """Convert common touch return shapes to (x, y).""" if not point: @@ -2692,7 +2700,7 @@ def main(): continue x, y = touch_point - if time.ticks_diff(now, app.touch.last_touch) < DEBOUNCE_MS: + if time.ticks_diff(now, app.touch.last_touch) < _touch_debounce_ms(app): time.sleep(0.02) continue app.touch.last_touch = now diff --git a/presto/tests/test_screens.py b/presto/tests/test_screens.py index 09074aac..b113b5fd 100644 --- a/presto/tests/test_screens.py +++ b/presto/tests/test_screens.py @@ -228,6 +228,19 @@ class TestSmokeScreens: main_module.KB_INPUT_UPDATE_H, )] + def test_search_input_uses_shorter_touch_debounce(self, main_module): + """Keyboard taps use a shorter debounce than the rest of the UI.""" + app = self._make_app(main_module) + + assert main_module.DEBOUNCE_MS == 300 + assert main_module.KEYBOARD_DEBOUNCE_MS == 80 + + app.screen = main_module.STATE_SEARCH_INPUT + assert main_module._touch_debounce_ms(app) == 80 + + app.screen = main_module.STATE_HOME + assert main_module._touch_debounce_ms(app) == 300 + def test_scrobble_button_partial_redraw(self, main_module, monkeypatch): """Scrobble feedback redraws only the visible button region.""" app = self._make_app(main_module)