[presto] reduce touch debounce while searching
This commit is contained in:
+9
-1
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user