You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Android (S2): touch input and the system long-press delay #2649
crates/rune/src/runtime/input/touch.rs:19 hardcodes LONG_PRESS at 0.5 s, whereas Android's system long-press timeout is 400 ms by default and up to 1.5 s with the accessibility Touch & hold delay setting.
Cx::touch_controls is false on Android.
Slice (+655 −438 over S1, mostly kit-gallery's main.rs split into lib.rs)
RuneView.onTouchEvent forwards every pointer and batched historical samples.
Pure Android action-to-phase mapping with host tests.
Runtime::set_touch_long_press to pass the system's long-press timeout.
touch_controls / hover_none enabled on Android.
examples/android-gallery.
Checked
Host: 61 touch and Android tests, including hold arming at a host-supplied delay and invalid delays falling back to the default.
Emulator (x86_64 API 35): tap toggles switches; gallery scrolls under the finger and coasts after lift; hold arms at Android's 400 ms.
this slice builds on #2647 (s0) and #2648 (s1), which are not on dev yet (platform/android/ and RuneView are not in the tree), and raises two product/api decisions alongside Runtime::set_touch_long_press (only the shared runtime hooks could land ahead of s1; Runtime::set_touch_controls already exists in crates/rune/src/runtime/api.rs:397, matching ios in crates/rune/src/platform/embed.rs:241).
thoughts from the current codebase (crates/rune/src/runtime/input/touch.rs, crates/rune/src/runtime/scroll/touch.rs, crates/rune/src/runtime/motion/tracks.rs, crates/rune/src/popup_menu/mod.rs, crates/rune/src/runtime/input/popup_fallback.rs, crates/rune/src/platform/embed_frame.rs, PLAN.md):
touch fling physics (runtime/scroll/touch.rs): touch flings currently share one curve across web, ios, and touchscreens (±8000 pt/s clamp, exponential decay SCROLL_DECAY = 2.002 from runtime/motion/tracks.rs:6, no minimum fling threshold). PLAN.md lists scroll momentum under native behaviour, and android's ViewConfiguration exposes scaledMinimumFlingVelocity (50 dp/s), scaledMaximumFlingVelocity (8000 dp/s), and scrollFriction (0.015, driving OverScroller's spline curve rather than plain exponential decay). keeping rune's shared momentum for s2 matches ios/web and avoids adding a second physics path now, while passing ViewConfiguration bounds or matching OverScroller would add a host-configurable fling api on Runtime beside set_touch_long_press.
Tx::popup_menu on android (popup_menu/mod.rs, runtime/input/popup_fallback.rs, platform/embed_frame.rs):popup_menu_supported() is true only on macos and windows, so returning None by default on android matches linux and ios (and rune's own-look direction in PLAN.md). note that linux also supports opt-in in-window menus via App::on_popup_menu (Presenter::open_core checks popup_menu_fallback_active), whereas embed_frame::flush_requests (platform/embed_frame.rs:226-228) currently calls rt.cancel_popups(app) unconditionally, so App::on_popup_menu is bypassed on LayerHost hosts (ios and android) even though App::on_field_menu runs in field_menu.rs:147.
questions for maintainers:
should android touch flings keep rune's shared momentum curve (SCROLL_DECAY = 2.002, ±8000 pt/s) for s2, or expose a Runtime hook for ViewConfiguration's velocity bounds / friction (or OverScroller curve)?
should popup_menu_supported() stay false on android (no native PopupMenu), and should embed_frame::flush_requests honor App::on_popup_menu on LayerHost (android and ios) the same way desktop linux does?
Flings: the fork keeps the shared curve. On a 120 Hz phone it held its frames; it was not compared side by side with a native list. Keeping it for S2 is fine by us.
Tx::popup_menu: popup_menu_supported() stays false in the fork. Text's own menus (a field's, selected text's Copy) are left to the host, which shows them as Android's floating selection toolbar (a later slice, host.text_menus); every other menu is cancelled by flush_requests, so App::on_popup_menu is bypassed there as you describe. Honoring it on LayerHost would be welcome and does not conflict with the toolbar.
Touch forwarding & system long-press delay: RuneView.onTouchEvent forwards all pointers and batched historical ACTION_MOVE samples in chronological order across JNI (nativeTouch), mapped through a pure cross-platform action/flag/coordinate module (crates/rune/src/platform/android/touch.rs, including API 33+ MotionEvent.FLAG_CANCELED -> TouchPhase::Cancelled). Added Runtime::set_touch_long_press / Runtime::touch_long_press (default 0.5 s; invalid non-positive or non-finite values fall back to 0.5 s) and wired ViewConfiguration.getLongPressTimeout() on view init and resume so Android's 400 ms default and accessibility Touch & hold delay changes take effect.
Touch fling physics: Kept Rune's shared fling momentum curve (SCROLL_DECAY = 2.002, ±8000 pt/s) for S2, matching iOS and web.
Tx::popup_menu & App::on_popup_menu on LayerHost: Kept popup_menu_supported()false on Android and iOS, and updated embed_frame::flush_requests to honor App::on_popup_menu when registered instead of unconditionally cancelling open/queued fallback pop-up menus (apps without on_popup_menu still resolve to None immediately).
Example: Split examples/kit-gallery into lib.rs + thin main.rs and added examples/android-gallery (dev.rune.gallery).
Verification
Verified locally on Windows host: runtime::input::touch (53 tests including 400 ms / 1500 ms / invalid long-press fallback), platform::android (21 tests including action/flag mapping, batched touch pipeline, and state-machine frame deduplication), platform::embed_frame (10 tests including App::on_popup_menu preservation and missed_step delivery), set_touch_long_press doctest, android-gallery unit test, and kit-gallery check.
Verified in CI: Android NDK cross-checks (aarch64-linux-android, x86_64-linux-android including android-gallery), Kotlin/DEX/APK packaging (android-hello), check, and size all passed.
Not run on real Android hardware or an Android emulator (no Android device/emulator available on this host). Please reopen if anything behaves unexpectedly on device.
Activity
opencodejr commentedon Nov 27, 2026
this slice builds on #2647 (s0) and #2648 (s1), which are not on
devyet (platform/android/andRuneVieware not in the tree), and raises two product/api decisions alongsideRuntime::set_touch_long_press(only the shared runtime hooks could land ahead of s1;Runtime::set_touch_controlsalready exists incrates/rune/src/runtime/api.rs:397, matching ios incrates/rune/src/platform/embed.rs:241).thoughts from the current codebase (
crates/rune/src/runtime/input/touch.rs,crates/rune/src/runtime/scroll/touch.rs,crates/rune/src/runtime/motion/tracks.rs,crates/rune/src/popup_menu/mod.rs,crates/rune/src/runtime/input/popup_fallback.rs,crates/rune/src/platform/embed_frame.rs,PLAN.md):runtime/scroll/touch.rs): touch flings currently share one curve across web, ios, and touchscreens (±8000 pt/sclamp, exponential decaySCROLL_DECAY = 2.002fromruntime/motion/tracks.rs:6, no minimum fling threshold).PLAN.mdlists scroll momentum under native behaviour, and android'sViewConfigurationexposesscaledMinimumFlingVelocity(50 dp/s),scaledMaximumFlingVelocity(8000 dp/s), andscrollFriction(0.015, drivingOverScroller's spline curve rather than plain exponential decay). keeping rune's shared momentum for s2 matches ios/web and avoids adding a second physics path now, while passingViewConfigurationbounds or matchingOverScrollerwould add a host-configurable fling api onRuntimebesideset_touch_long_press.Tx::popup_menuon android (popup_menu/mod.rs,runtime/input/popup_fallback.rs,platform/embed_frame.rs):popup_menu_supported()istrueonly on macos and windows, so returningNoneby default on android matches linux and ios (and rune's own-look direction inPLAN.md). note that linux also supports opt-in in-window menus viaApp::on_popup_menu(Presenter::open_corecheckspopup_menu_fallback_active), whereasembed_frame::flush_requests(platform/embed_frame.rs:226-228) currently callsrt.cancel_popups(app)unconditionally, soApp::on_popup_menuis bypassed onLayerHosthosts (ios and android) even thoughApp::on_field_menuruns infield_menu.rs:147.questions for maintainers:
SCROLL_DECAY = 2.002,±8000 pt/s) for s2, or expose aRuntimehook forViewConfiguration's velocity bounds / friction (orOverScrollercurve)?popup_menu_supported()stayfalseon android (no nativePopupMenu), and shouldembed_frame::flush_requestshonorApp::on_popup_menuonLayerHost(android and ios) the same way desktop linux does?pascalandr commentedon Nov 27, 2026
Tx::popup_menu:popup_menu_supported()stays false in the fork. Text's own menus (a field's, selected text's Copy) are left to the host, which shows them as Android's floating selection toolbar (a later slice,host.text_menus); every other menu is cancelled byflush_requests, soApp::on_popup_menuis bypassed there as you describe. Honoring it onLayerHostwould be welcome and does not conflict with the toolbar.Hona commentedon Nov 28, 2026
Shipped in PR #2709 (
86189625b).Design decisions
RuneView.onTouchEventforwards all pointers and batched historicalACTION_MOVEsamples in chronological order across JNI (nativeTouch), mapped through a pure cross-platform action/flag/coordinate module (crates/rune/src/platform/android/touch.rs, including API 33+MotionEvent.FLAG_CANCELED->TouchPhase::Cancelled). AddedRuntime::set_touch_long_press/Runtime::touch_long_press(default0.5s; invalid non-positive or non-finite values fall back to0.5s) and wiredViewConfiguration.getLongPressTimeout()on view init and resume so Android's 400 ms default and accessibility Touch & hold delay changes take effect.SCROLL_DECAY = 2.002,±8000 pt/s) for S2, matching iOS and web.Tx::popup_menu&App::on_popup_menuonLayerHost: Keptpopup_menu_supported()falseon Android and iOS, and updatedembed_frame::flush_requeststo honorApp::on_popup_menuwhen registered instead of unconditionally cancelling open/queued fallback pop-up menus (apps withouton_popup_menustill resolve toNoneimmediately).examples/kit-galleryintolib.rs+ thinmain.rsand addedexamples/android-gallery(dev.rune.gallery).Verification
runtime::input::touch(53 tests including 400 ms / 1500 ms / invalid long-press fallback),platform::android(21 tests including action/flag mapping, batched touch pipeline, and state-machine frame deduplication),platform::embed_frame(10 tests includingApp::on_popup_menupreservation andmissed_stepdelivery),set_touch_long_pressdoctest,android-galleryunit test, andkit-gallerycheck.aarch64-linux-android,x86_64-linux-androidincludingandroid-gallery), Kotlin/DEX/APK packaging (android-hello),check, andsizeall passed.