Smooth wheel scrolling: route scroll over sliders to the list or the volume
CI / check (pull_request) Successful in 9s
CI / native (pull_request) Successful in 1m15s

GtkRange's built-in scroll controller moved a slider by its page increment
(10%) per wheel detent, ignored the tilt wheel and returned GDK_EVENT_STOP
for every scroll event, including a touchpad's vertical swipe it did nothing
with. So scrolling a list stopped dead whenever a slider passed under the
pointer and changed that stream's volume instead.

Sliders now replace that controller with one that asks MoonBit
(@model.SliderWheel) synchronously where each event goes:
- while the list is moving (it moved or was sent a scroll < 600 ms ago,
  kinetic deceleration included) events keep scrolling the list;
- otherwise a mouse wheel changes the volume by 2% per detent, fractional
  for high-resolution wheels, tilt wheel included;
- a touchpad gesture is decided at its first movement: mainly vertical
  scrolls the list (kinetic), mainly horizontal moves the knob with the
  fingers (physical direction).

Measured under Xvfb with XTest and 8 playback streams: 12 wheel notches
over a row title used to scroll 3 times and drop a stream from 100% to 20%;
now the list scrolls to the end and no volume changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Opus 5.5 committed 2026-11-23 06:44:52 +00:00
1 parent 0760d7ba6c
commit cff5f49dc3
9 files changed
+511 -15

No files matched your search

+37 -12
View File
@@ -208,19 +208,44 @@ fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
let slider_row = @gtk.hbox(8)
let volume_label = @gtk.label(row.volume_text)
volume_label.set_width_chars(16)
let (scale, scale_tag) = @gtk.scale(@model.MAX_PERCENT, @model.NORM_PERCENT, fn(
percent,
) {
match app.find_view(tab, id) {
Some(v) => {
let vols = @model.scale_linked(v.row.volumes, percent)
v.last_local_us = @gtk.now_us()
v.volume_label.set_text(@model.format_volume(vols))
let _ = @wp.set_volumes(id, vols)
// Wheel/touchpad over the slider: see @model.SliderWheel.
let wheel = @model.SliderWheel::new()
let (scale, scale_tag) = @gtk.scale(
@model.MAX_PERCENT,
@model.NORM_PERCENT,
fn(percent) {
match app.find_view(tab, id) {
Some(v) => {
let vols = @model.scale_linked(v.row.volumes, percent)
v.last_local_us = @gtk.now_us()
v.volume_label.set_text(@model.format_volume(vols))
let _ = @wp.set_volumes(id, vols)
}
None => ()
}
None => ()
}
})
},
on_scroll=fn(ev) {
match ev.phase {
Begin | End => {
wheel.reset()
None
}
Scroll =>
wheel.scroll(
if ev.pixels {
Pixels
} else {
Wheel
},
ev.dx,
ev.dy,
ev.since_list_us,
ev.value,
ev.extent,
)
}
},
)
tags.push(scale_tag)
// Peak meter under the slider, as wide as it.
let meter = @gtk.level_bar()