Skip to content

Scroll: a wheel passes only to a region around the one under it, as Chromium chains a scroll - #1137

Merged
Hona merged 4 commits into
devfrom
scroll-wheel-chain
Nov 17, 2026
Merged

Hona merged 4 commits into
devfrom
scroll-wheel-chain

Conversation

@Hona

@Hona Hona commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

What a user sees on dev (since #1123): with an overlay open over the timeline, a wheel over the overlay scrolls the timeline behind it. This happens with the / command list, the @ mention list, an in-window menu (every menu on Windows is drawn in the window) and the peeked sidebar. Three notches move the session 200 to 300 pt while the overlay stays open. Before #1123 nothing moved over the lists, and in official nothing moves.

Cause: #1123 starts a wheel run on the innermost viewport under the point with room in its direction, searching every viewport there in tree order. A viewport that only lies beneath an overlay qualifies once the overlay's own list is at its end, fits, or there is none.

Fix: a run starts on what is on top under the pointer, then walks up its ancestors to the first vertical viewport with room, as Chromium chains a scroll.

  • The start: the paint pass now lists, in paint order, everything a wheel can start on (wheel_hits, input/hit.rs): what takes input, every visible scroll view, and the roots of what is drawn over others: an anchored overlay (above), a raise()d panel, a sticky element. Runtime::chain_start takes the topmost entry that contains the point.
    • A row inside a list paints after the list, so the row wins.
    • Any other box without a handler lets the wheel through, as an element with pointer-events: none does.
  • Paint reuse: a release build reuses unchanged subtrees, so the list is kept as hits is (paint/keep.rs): a range in each PaintRec, swapped and twinned in the swap, opened and closed, copied and shifted with a reused subtree, and compared in a debug build's check.
  • Who uses it: gesture_chain (on_wheel routing) and wheel_target (the scroll) share the start. It's found once per delta and handed on (WheelStart).
flowchart TB
  P[point under the wheel] --> I[topmost of: input, scroll views, painted surfaces]
  I -->|a viewport with room| T[it takes the run]
  I -->|none, or at its end| A[the next ancestor]
  A -->|a viewport with room| T2[it takes the run]
  A -->|no ancestor left| N[nothing moves]
  B[timeline beneath an overlay]:::x -. not an ancestor: never .-> T
  classDef x stroke-dasharray: 4 4
Loading
// crates/rune/src/runtime/input/gesture.rs
pub(super) fn chain_start(&self, x: f32, y: f32) -> Option<usize> {
    self.wheel_hits.iter().rev().find_map(|&(id, r)| {
        if !self.hit_contains(id, r, x, y) { return None; }
        let i = *self.node_index.get(&id)?;
        (!self.subtree_exiting(i) && self.allowed(i)).then_some(i)
    })
}

Overlays over the timeline. Headless, Rune's own frames: three notches up at the overlay's top, a rest, eight down, a rest, one down. Official from a capture ticket (official-overlays.ts): three notches at each end.

This PR's rows are from a release-quick build with RUNE_PAINT_KEEP_LOG=1. The pointer crosses the transcript first (for the peeked sidebar, its own rows), so the paint step reuses what didn't change: 294 to 506 nodes copied in one paint. The peeked sidebar is raised, so reuse is off there, as in the app.

Overlay Official dev (3d037b49) This PR
/ command list (40 commands: scrolls) nothing moves at either end the timeline behind moves 200 pt the list 800 pt, the timeline 0
Mention list (@; a viewport that fits) nothing moves the timeline behind moves 300 pt timeline 0
Windows app menu, the wheel over its scrim (drawn in the window, no scroller) — the timeline behind moves 300 pt timeline 0
Peeked sidebar (raised over the timeline), over its list — the timeline behind moves 300 pt timeline 0
Peeked sidebar, over its section header — the timeline behind moves 300 pt timeline 0
Peeked sidebar, over the gap between its sections — the timeline behind moves 300 pt timeline 0
/ list closed by Escape mid-burst — the timeline moves 300 pt (from the notches at the list's top) the list 200 pt, the timeline 0
Model picker, plugin dialog nothing moves (dialogs) 0 (modal) 0
Command palette, View code dialog nothing moves (dialogs) out of reach: both modal(true) same
Agent and effort menus nothing moves in-window popover::MENU, no scroller: as the app menu as the app menu
Tab hover card the timeline behind scrolls (the card isn't a hit) — (Rune has none) —

The app's popovers come from one surface (session_view::popover). It takes a hit (on_press), and so does its scrim, so a wheel over a popover's body or padding starts on the popover. The app doesn't use the kit's Popover.

What #1123 fixed, still fixed (headless; this PR's column on the release-quick build, after the pointer crossed the transcript: 297 to 316 nodes reused in one paint). In each case the region that takes the hand-on contains the inner one.

Region dev This PR
Shell console in the timeline the burst back to the console's top, the rest held, timeline 1185.6; the lone notch moves the timeline to 1085.6 same
A failed command's full text the lone notch moves the timeline 1205.6 → 1105.6 same
The View code dialog's script box at its end, each later notch moves the dialog's body 100 pt same

Elsewhere, against Rune before #1123 (route-regress.ts, headless: every scroll area of 23 surfaces, the same wheel at each). Plain transcript text, tool rows, a read, a patch, a wide diagram, a long summary, code blocks and tables wider than the timeline, Review's tree and diffs, a Markdown file, Settings and the open pickers are the same. The one difference is intended: the Settings/Page story's side list at its end hands the lone notch to the story's frame around it, where before nothing moved.

Next, in a PR on top of this one:

  • the horizontal wheel, fling, fling_xy, touch and the Windows page-scroll size get the same start and chain;
  • a latched list that closes mid-burst stops taking the burst;
  • whether every painted box should stop the wheel, with an opt-out the app can set where official has pointer-events: none. The evidence (a grid of points over headers, fades, toasts, docks and side panels, on dev, on a fill rule and on official) goes there.

…hromium chains a scroll

#1123 started a wheel run on the innermost viewport under the pointer with room in its direction,
searching every viewport under the point. A viewport that only lies beneath one (the timeline under
the open / command list, which is drawn over it but is not inside it) took the wheel once the list
reached its end, so the timeline scrolled behind an open menu. Chromium chains a scroll from the
scroller under the pointer up its own ancestors; official's list (composer-suggestions) has none, and
three notches at either end of it move nothing. Now the run starts on the innermost viewport under
the pointer or the nearest of its scroll ancestors with room. The Shell console, a failed command's
text and the View code script box are inside the region they hand on to, so they hand on as before.
Copilot AI balanced review requested due to automatic review settings November 17, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

The chain up the ancestors started on the last viewport in tree order that contains the point.
That is not what is painted on top there: a menu with no scroll view of its own over the timeline
(every in-window menu on Windows, `popover::MENU`) let the timeline behind it scroll, and the peeked
sidebar, raised over the timeline but before it in the tree, lost the wheel to it. The start is
now `Runtime::chain_start`, shared with `gesture_chain`: the topmost hit (`hits`, in paint order),
or a scroll view inside it; with no hit, the scroll view there. on_wheel routing and the scroll
target now begin at the same element.
@Hona

Hona commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Answering notes/review-1137.md:

  • Must fix (the start): done in 21d6ce43. Runtime::chain_start is the start gesture_chain already used: the topmost hit in hits (paint order), a scroll view inside it if there is one, and with no hit the scroll view there. gesture_chain and wheel_target both call it now.
    • The non-scrolling menu: the Windows app menu, drawn in the window with no scroller. Over its scrim, the timeline behind moved 300 pt on dev and on 79c941cc, and 0 on this head.
    • The raised panel exists in the app: the peeked sidebar, raised over the timeline and before it in the tree (view.rs). Over its list, the timeline behind moved 300 pt on dev and on 79c941cc, and 0 on this head.
    • The three regions fix(scroll): a wheel no longer traps on a scroll region inside another #1123 fixed: unchanged. The Shell console, a failed command's text and the View code script box still hand on to the region around them.
  • Sticky header over a nested region: not driven yet; it comes with the next PR's cases.
  • Should fix (the horizontal wheel, fling, fling_xy, the Windows page-scroll size, a list closing mid-burst): a PR on top of this one, with Shift plus the wheel over a menu above a sideways code block, and a list closing mid-burst, each driven before and after.
  • No test added, as the repo's rule asks. Every row is from a headless or live run, listed in the description.

@Hona

Hona commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Old head, superseded by 21d6ce43 (PROOF-FARM's Windows lane on adais; the new head's whole suite runs next):

#1137 79c941cc (18 Nov 03:42): 2841 passed, 18 failed in 170 binaries; also on dev: alloc::disabled_trace_hooks_neither_format_nor_allocate, canvas_input::the_middle_button_drags_only_elements_that_take_it, rune::edit::tests::hidden_multiline_pristine_replace_and_delete, rune::edit::tests::pill_edge_cases_words_lines_bidi_and_direct_text_mutation, rune::edit::tests::the_caret_steps_over_a_pill_in_one_move, rune::input::keycaps::tests::repeated_chords_count_and_named_keys_use_glyphs, rune::native_surface::gpu_tests::mirrored_video_is_exact_cropped_centred_and_toggles_without_a_new_frame, rune::native_surface::gpu_tests::video_gpu_colour_sharpness_geometry_and_lifetime, rune::render::breaker::tests::a_refused_blur_pipeline_draws_unblurred, rune::render::layers::cache_tests::live_scale_zoom_sweep_buckets_during_motion_and_settles_crisp, rune::render::layers::rebind_tests::a_texture_switch_binds_no_parked_target_until_one_returns, rune::render::layers::tests::clipped_single_draw_fades_do_not_allocate_targets, rune::runtime::tests::layout_rows::send_flight_follows_the_measured_bubble_while_earlier_rows_land, rune::runtime::tests::picture_scale::a_changing_static_scale_keeps_the_glyph_atlas_bounded, rune::runtime::tests::picture_scale::text_inside_a_scale_draws_at_that_size, rune::runtime::tests::scroll_children::scroll_xy_with_direct_children_scrolls_both_axes_and_warns_on_trailing_growth_sibling, rune::text::macos::smoothing::tests::pipelines_never_share_masks, selectable_text::copy_select_all_and_the_context_menu; none new. Base 842c28c2. Proof db5bb567.

… paints there

`chain_start` picked the topmost interactive hit in paint order, but the scroll view only as the
last in tree order, and `hits` holds only what takes input. Over a raised list's section header
or the gap between its rows, the run started on a hit beneath it and the timeline scrolled. Now
the paint pass also lists, in the same order, every visible scroll view and every painted surface
without a handler (`wheel_hits`), and a run starts at the topmost entry containing the point; a
row inside a list paints after the list, so it still wins, and a box that paints nothing (a
full-window layer) is never one. `find_map` skips an entry whose node is already gone. The start
is found once per delta and handed on to the scroll (`WheelStart`).
@Hona

Hona commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Windows whole suite (-p rune -p rune-kit) on adais, judged against dev's own failures at 32eb7811 (this lane, whole suite) and eb5ae6c9 (FUNCTION's run, rune only) and 3468f3a3 and cca5df6f: #1137 21d6ce43 (18 Nov 06:14): 2840 passed, 19 failed in 170 binaries; also on dev: alloc::disabled_trace_hooks_neither_format_nor_allocate, canvas_input::the_middle_button_drags_only_elements_that_take_it, rune::edit::tests::hidden_multiline_pristine_replace_and_delete, rune::edit::tests::pill_edge_cases_words_lines_bidi_and_direct_text_mutation, rune::edit::tests::the_caret_steps_over_a_pill_in_one_move, rune::input::keycaps::tests::repeated_chords_count_and_named_keys_use_glyphs, rune::native_surface::gpu_tests::mirrored_video_is_exact_cropped_centred_and_toggles_without_a_new_frame, rune::render::breaker::tests::a_refused_blur_pipeline_draws_unblurred, rune::render::layers::cache_tests::cache_matches_uncached_at_rest_and_skips_rerasterize_on_ancestor_live_offset, rune::render::layers::cache_tests::live_scale_zoom_sweep_buckets_during_motion_and_settles_crisp, rune::render::layers::filter_tests::filtered_video_and_image_page_match_primitive_source, rune::render::layers::rebind_tests::a_texture_switch_binds_no_parked_target_until_one_returns, rune::render::layers::tests::clipped_single_draw_fades_do_not_allocate_targets, rune::runtime::tests::layout_rows::send_flight_follows_the_measured_bubble_while_earlier_rows_land, rune::runtime::tests::picture_scale::a_changing_static_scale_keeps_the_glyph_atlas_bounded, rune::runtime::tests::picture_scale::text_inside_a_scale_draws_at_that_size, rune::runtime::tests::scroll_children::scroll_xy_with_direct_children_scrolls_both_axes_and_warns_on_trailing_growth_sibling, rune::text::macos::smoothing::tests::pipelines_never_share_masks, selectable_text::copy_select_all_and_the_context_menu; none new. Base 842c28c2. Proof c7a3394a.

@Hona

Hona commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Answering the re-read at 21d6ce43. The fixes are in d1deb303:

  • Finding 1 (the start): the paint pass now records, in paint order, every visible scroll view alongside the hits, plus the painted surfaces below (wheel_hits, input/hit.rs). chain_start takes the topmost entry that contains the point. A row inside a list paints after the list, so it still wins, and the reverse pass over every node is gone.
  • Finding 4: find_map with subtree_exiting and allowed, so an entry whose node is gone is passed over.
  • Finding 2's cheap part: every painted surface without a handler is a wheel-only entry (vis.fill.a > 0). That covers overlay roots, raised panels and a sticky header's band, and presses are unaffected. A box that paints nothing never is one: a draft that started from element_at's box geometry stopped the wheel over the timeline itself, because a full-window layer counted as "on top".
  • Finding 3: the start is found once per delta (WheelStart, passed from offer_wheel on to wheel_target).
  • Where findings 1 and 2 bite in this app:
    • The app doesn't use the kit's Popover. Its popovers all come from session_view::popover, whose surface takes a hit (on_press), as does its scrim.
    • The peeked sidebar over its section header and over the gap between its sections: 300 pt on dev, 0 at 21d6ce43, 0 now. The sidebar takes a hit there of its own.
    • The rows are in the description.
  • Not driven yet, still running: the whole before/after pass over every other surface against Rune before fix(scroll): a wheel no longer traps on a scroll region inside another #1123, which includes plain transcript text. So far the code block, the table, the open / list and the model picker are the same. And a plain-text sticky header over a console box: the timeline's sticky headers here have handlers, so they're hits on both heads.
  • Stays for the follow-up PR: the horizontal wheel, fling, fling_xy, touch, the page-scroll size, and a latched list closing mid-burst.

…is drawn over others

`wheel_hits` was filled by `register_node_hits`, which a release build's paint skips for every
subtree it reuses, and `keep` restored `hits` and the other hit lists but not it: after a hover
repaint, a wheel over a reused message's console box or a reused popover started on whatever lay
beneath. It is now kept as `hits` is: a range in each `PaintRec`, swapped and twinned in the
swap, opened, closed, copied and shifted with a reused subtree, and compared in a debug build's
check. And of what takes no input, it now holds only the roots of what is drawn over others (an
anchored overlay, a `raise()`d panel, a sticky element), not every filled box: a box without a
handler elsewhere lets the wheel through, as one with `pointer-events: none` does.
@Hona

Hona commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Answering the third read at d1deb303. The fixes are in a7ead633:

  • Must fix 1 (paint reuse): wheel_hits is now kept as hits is (paint/keep.rs):
    • a wheel range in PaintRec, swapped and twinned in keep_swap;
    • its start in keep_open and its end in keep_close;
    • copied and shifted in keep_copy, and compared in keep_check ("wheel hits"), so a debug build reports any later gap.
  • Ruled 2 (three kinds): of what takes no input, wheel_hits holds only anchored overlay roots (above), raise() roots and sticky elements, with their clipped rectangle whatever their fill, plus every hit and every scroll view. Any other box without a handler lets the wheel through, as before.
  • The build kind: my earlier rows were on debug builds, where nothing is reused. This head's rows were re-taken on a release-quick build with RUNE_PAINT_KEEP_LOG=1, after the pointer crossed the transcript first:
    • the Shell console, the error box and the View code box (297 to 316 nodes reused in one paint) behave as on dev;
    • the / list and the mention list (506 and 323 reused) let nothing behind them move;
    • the app menu (316 reused) and the model picker (294 reused) let nothing behind them move;
    • over the peeked sidebar's list, its section header and its gap, nothing behind moves. It's raised, so reuse is off there.
    • The rows are in the description.
  • Still running: the full pass over every surface on this release build, against Rune before fix(scroll): a wheel no longer traps on a scroll region inside another #1123. The same pass on 21d6ce43's start rule came out the same everywhere, except the intended Settings/Page story release.

@Hona

Hona commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Windows whole suite (-p rune -p rune-kit) on adais, judged against dev's own failures at 32eb7811 (this lane, whole suite) and eb5ae6c9 (FUNCTION's run, rune only) and 3468f3a3 and cca5df6f: #1137 a7ead63 a7ead633 (18 Nov 08:13): 2840 passed, 19 failed in 170 binaries; also on dev: alloc::disabled_trace_hooks_neither_format_nor_allocate, canvas_input::the_middle_button_drags_only_elements_that_take_it, rune::edit::tests::hidden_multiline_pristine_replace_and_delete, rune::edit::tests::pill_edge_cases_words_lines_bidi_and_direct_text_mutation, rune::edit::tests::the_caret_steps_over_a_pill_in_one_move, rune::input::keycaps::tests::repeated_chords_count_and_named_keys_use_glyphs, rune::native_surface::gpu_tests::mirrored_video_is_exact_cropped_centred_and_toggles_without_a_new_frame, rune::render::breaker::tests::a_refused_blur_pipeline_draws_unblurred, rune::render::layers::cache_tests::cache_matches_uncached_at_rest_and_skips_rerasterize_on_ancestor_live_offset, rune::render::layers::cache_tests::live_scale_zoom_sweep_buckets_during_motion_and_settles_crisp, rune::render::layers::filter_tests::filtered_video_and_image_page_match_primitive_source, rune::render::layers::rebind_tests::a_texture_switch_binds_no_parked_target_until_one_returns, rune::render::layers::tests::clipped_single_draw_fades_do_not_allocate_targets, rune::runtime::tests::layout_rows::send_flight_follows_the_measured_bubble_while_earlier_rows_land, rune::runtime::tests::picture_scale::a_changing_static_scale_keeps_the_glyph_atlas_bounded, rune::runtime::tests::picture_scale::text_inside_a_scale_draws_at_that_size, rune::runtime::tests::scroll_children::scroll_xy_with_direct_children_scrolls_both_axes_and_warns_on_trailing_growth_sibling, rune::text::macos::smoothing::tests::pipelines_never_share_masks, selectable_text::copy_select_all_and_the_context_menu; none new. Base 842c28c2. Proof 70b4eba4.

@Hona
Hona merged commit 10a3958 into dev Nov 17, 2026
1 check passed
thdxr added a commit that referenced this pull request Nov 19, 2026
The bar's track draws over the viewport's right edge as its sibling (both in the `area` column),
and since #1137 a wheel starts on the topmost hit and chains up its ancestors. So a wheel over
the bar's strip started on the track, whose only ancestors were the area column and the window,
and found no scroller: every scroll view lost wheel scrolling over its rightmost points, and a
wide table lost its sideways wheel.

`El::wheel_scrolls(key)` names the viewport an element's wheel belongs to, and the kit's bars name
the viewport they follow. `scroll_in_chain` takes that hand-off before walking on, so it holds on
both axes: a wheel over the bar scrolls the viewport it follows, then chains on up from it when
that one is at its end, as a wheel over the viewport itself does. Chromium's scrollbar belongs to
its scroller the same way; a press or drag on the bar is unchanged.

The key is resolved in the element's own place, looked up inside the element itself and then its
ancestors, innermost first, so panes and tables that key their viewports alike each take their own
wheel (`markdown/table.rs` keys every wide table's viewport `scroll`). The first scope holding a
match decides: one on its way out or inert hands the wheel nowhere rather than to another pane's.
`in_scope`'s key-name scoping can't tell repeated keys apart, so the boundary is the tree's own
subtree, while the match inside it is `named`, as `Tx::scroll_into_view` names one.

`on_wheel` handlers under the pointer still hear the wheel first; one on the named viewport does
not, since the pointer is over the bar and not the viewport.

Fixes #1200.
thdxr added a commit that referenced this pull request Nov 19, 2026
)

The bar's track draws over the viewport's right edge as its sibling (both in the `area` column),
and since #1137 a wheel starts on the topmost hit and chains up its ancestors. So a wheel over
the bar's strip started on the track, whose only ancestors were the area column and the window,
and found no scroller: every scroll view lost wheel scrolling over its rightmost points, and a
wide table lost its sideways wheel.

`El::wheel_scrolls(key)` names the viewport an element's wheel belongs to, and the kit's bars name
the viewport they follow. `scroll_in_chain` takes that hand-off before walking on, so it holds on
both axes: a wheel over the bar scrolls the viewport it follows, then chains on up from it when
that one is at its end, as a wheel over the viewport itself does. Chromium's scrollbar belongs to
its scroller the same way; a press or drag on the bar is unchanged.

The key is resolved in the element's own place, looked up inside the element itself and then its
ancestors, innermost first, so panes and tables that key their viewports alike each take their own
wheel (`markdown/table.rs` keys every wide table's viewport `scroll`). The first scope holding a
match decides: one on its way out or inert hands the wheel nowhere rather than to another pane's.
`in_scope`'s key-name scoping can't tell repeated keys apart, so the boundary is the tree's own
subtree, while the match inside it is `named`, as `Tx::scroll_into_view` names one.

`on_wheel` handlers under the pointer still hear the wheel first; one on the named viewport does
not, since the pointer is over the bar and not the viewport.

Fixes #1200.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants