Launcher: a thumb scrolls the app list
Deploy to the handset / build-and-deploy (push) Successful in 2m21s
CI / test (push) Failing after 2m49s

On a touchscreen a drag over the launcher's list scrolls it by pixels, a flick
keeps it going, and a tap still launches (or stops a moving list).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nandiandClaude Opus 5.5 committed 2026-11-29 22:40:32 -08:00
1 parent cb0ff0715e
commit 7029c92e6e
8 files changed
+313 -32

No files matched your search

+69
View File
@@ -136,3 +136,72 @@ test "a window moved by its own title bar follows the finger that asked for it"
assert_true(comp.wm.drag is None)
comp.close()
}
///|
test "a finger scrolls the launcher's list: a drag moves it, a flick keeps it going, a tap launches" {
let comp = osk_comp("touchlist", enable_osk=false)
load_handset_modules(comp)
let data = "/tmp/chandra-touch-apps-" + @sys.getpid().to_string()
ignore(@sys.mkdir_p(data + "/applications"))
for i in 0..<30 {
ignore(
@sys.write_file_bytes(
data + "/applications/touch" + i.to_string() + ".desktop",
@sys.str_to_utf8_bytes(
"[Desktop Entry]\nType=Application\nName=Touch " + i.to_string() + "\nExec=true\n",
),
),
)
}
comp.shell.xdg_dirs = { ..comp.shell.xdg_dirs, data_home: data, data_dirs: [] }
comp.shell.toggle_launcher()
comp.shell.toggle_launcher()
comp.shell.toggle_launcher()
for _ in 0..<10 {
@sys.sleep_ms(30)
ignore(comp.compose_frame())
}
let pr = comp.shell.slot_popup_rect(comp.shell.slot_of("launcher"))
let st = comp.shell.launcher_state
assert_eq(comp.shell.apps.length(), 30)
let x = (pr.x + pr.w - 120).to_double()
let y = (pr.y + 300).to_double()
// Past the threshold the list follows the finger by pixels.
comp.handle_input(Touch(Down(0, x, y)), 10U)
comp.handle_input(Touch(Motion(0, x, y - 10.0)), 20U)
assert_eq((st.scroll, st.offset), (0, 0))
comp.handle_input(Touch(Motion(0, x, y - 60.0)), 30U)
assert_eq(st.scroll * 46 + st.offset, 60)
comp.handle_input(Touch(Motion(0, x, y - 50.0)), 300U)
assert_eq(st.scroll * 46 + st.offset, 50)
// Held still, then up: it stays, and nothing was launched.
comp.handle_input(Touch(Motion(0, x, y - 50.0)), 900U)
comp.handle_input(Touch(Up(0)), 910U)
assert_true(st.open)
assert_eq(st.scroll * 46 + st.offset, 50)
// A flick goes on after the lift, and a finger stops it without launching.
comp.handle_input(Touch(Down(0, x, y)), 1000U)
comp.handle_input(Touch(Motion(0, x, y - 40.0)), 1020U)
comp.handle_input(Touch(Motion(0, x, y - 80.0)), 1040U)
comp.handle_input(Touch(Up(0)), 1045U)
let at = st.scroll * 46 + st.offset
assert_eq(at, 130)
assert_true(comp.has_timed_work())
@sys.sleep_ms(30)
comp.step()
assert_true(st.scroll * 46 + st.offset > at)
comp.handle_input(Touch(Down(0, x, y)), 1100U)
let at = st.scroll * 46 + st.offset
comp.handle_input(Touch(Up(0)), 1120U)
@sys.sleep_ms(30)
comp.step()
assert_eq(st.scroll * 46 + st.offset, at)
assert_true(st.open)
// Never past the ends.
comp.handle_input(Touch(Down(0, x, y)), 2000U)
comp.handle_input(Touch(Motion(0, x, y + 5000.0)), 2010U)
comp.handle_input(Touch(Motion(0, x, y + 5000.0)), 2900U)
comp.handle_input(Touch(Up(0)), 2910U)
assert_eq((st.scroll, st.offset), (0, 0))
comp.close()
}