A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
fix(windows): follow touchpad travel in the sidebars
RoversX7547df094b42
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex e247482a..c775565a 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -356,6 +356,10 @@ impl super::TermWindow {}fn tab_scroll_pixels(amount: i16) -> f32 {+ // Less than a notch (a precision touchpad on Windows) moves no tab.+ if amount == 0 {+ return 0.0;+ }let steps = amount.unsigned_abs().max(1) as f32;let delta = (steps * 56.0).min(280.0);if amount < 0 {@@ -375,8 +379,17 @@ impl super::TermWindow {/// much ground on a 200% display as on a 100% one - on Windows at 200% a/// notch moved less than half a row while the same notch in settings moved/// three rows.- fn sidebar_scroll_pixels(&self, amount: i16) -> f32 {- crate::ui::wheel_delta_pixels(amount, crate::ui::ui_scale_for_dpi(self.dimensions.dpi))+ fn sidebar_scroll_pixels(&self, notches: f32) -> f32 {+ crate::ui::wheel_travel_pixels(notches, crate::ui::ui_scale_for_dpi(self.dimensions.dpi))+ }++ /// How many notches the wheel went: to the fraction where the device+ /// says (a precision touchpad on Windows), so the sidebar follows it+ /// rather than standing still until a whole notch is in.+ fn sidebar_wheel_notches(event: &MouseEvent, amount: i16) -> f32 {+ event+ .precise_wheel_lines+ .unwrap_or_else(|| f32::from(amount))}fn sidebar_vertical_scroll_delta(&self, event: &MouseEvent) -> Option<f32> {@@ -389,8 +402,9 @@ impl super::TermWindow {}}match event.kind {- WMEK::VertWheel(amount) if amount != 0 => Some(self.sidebar_scroll_pixels(amount)),- WMEK::VertWheel(_) => Some(0.0),+ WMEK::VertWheel(amount) => {+ Some(self.sidebar_scroll_pixels(Self::sidebar_wheel_notches(event, amount)))+ }_ => None,}}@@ -405,10 +419,9 @@ impl super::TermWindow {}}match event.kind {- WMEK::HorzWheel(amount) if amount != 0 => {- Some(self.sidebar_scroll_pixels(amount) * 2.0)+ WMEK::HorzWheel(amount) => {+ Some(self.sidebar_scroll_pixels(Self::sidebar_wheel_notches(event, amount)) * 2.0)}- WMEK::HorzWheel(_) => Some(0.0),_ => None,}}@@ -783,6 +796,10 @@ impl super::TermWindow {amount: i16,context: &dyn WindowOps,) {+ // Less than a notch changes nothing, so it repaints nothing either.+ if amount == 0 {+ return;+ }if self.should_ignore_tab_wheel_amount(surface, amount) {context.invalidate();return;diff --git a/wezterm-gui/src/ui/events.rs b/wezterm-gui/src/ui/events.rsindex c4fd22f6..45865bb7 100644--- a/wezterm-gui/src/ui/events.rs+++ b/wezterm-gui/src/ui/events.rs@@ -5,7 +5,12 @@ use window::{MouseEvent, MouseEventKind};/// ([`DrawContext::scale`]): rows shrink with the UI, so the scroll step has to/// shrink with them or one notch jumps a different number of rows per display.pub(crate) fn wheel_delta_pixels(amount: i16, scale: f32) -> f32 {- -(amount as f32) * WHEEL_NOTCH_PIXELS * scale+ wheel_travel_pixels(amount.into(), scale)+}++/// `wheel_delta_pixels` for travel measured to the fraction of a notch.+pub(crate) fn wheel_travel_pixels(notches: f32, scale: f32) -> f32 {+ -notches * WHEEL_NOTCH_PIXELS * scale}/// Distance a single wheel notch scrolls, in design pixels.@@ -77,6 +82,17 @@ mod test {);}+ /// A precision touchpad on Windows reports a fraction of a notch at a+ /// time; it has to move the same distance in all as whole notches do.+ #[test]+ fn a_fraction_of_a_notch_moves_that_fraction_of_the_distance() {+ let scale = ui_scale_for_dpi(144);+ let notch = wheel_delta_pixels(1, scale);+ assert!((wheel_travel_pixels(1.0, scale) - notch).abs() < f32::EPSILON);+ assert!((wheel_travel_pixels(0.25, scale) * 4.0 - notch).abs() < 0.001);+ assert!((wheel_travel_pixels(-0.5, scale) * 2.0 + notch).abs() < 0.001);+ }+/// The old sidebar helper clamped a whole event to 42px, which at its 6px/// step meant anything past 7 notches was silently discarded. Windows/// folds the user's scroll-lines setting into one event, so a fast flickdiff --git a/wezterm-input-types/src/lib.rs b/wezterm-input-types/src/lib.rsindex f63a64a7..7689b462 100644--- a/wezterm-input-types/src/lib.rs+++ b/wezterm-input-types/src/lib.rs@@ -1308,10 +1308,11 @@ pub struct MouseEvent {pub scroll_phase: Option<ScrollPhase>,/// Native momentum scroll phase when available.pub momentum_phase: Option<ScrollPhase>,- /// Wheel travel in lines with the fraction kept, for devices that- /// report finer steps than a line (a precision touchpad on Windows)- /// without a pixel-precise delta. Same sign as `VertWheel`. Only the- /// terminal grid reads it; chrome keeps using the integer kind.+ /// Wheel travel in lines (columns, for `HorzWheel`) with the fraction+ /// kept, for devices that report finer steps than a line (a precision+ /// touchpad on Windows) without a pixel-precise delta. Same sign as the+ /// wheel amount it comes with. The terminal grid and the sidebars read+ /// it; the rest of the chrome keeps using the integer kind.pub precise_wheel_lines: Option<f32>,}diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rsindex 2f934a41..f02a114d 100644--- a/window/src/os/windows/window.rs+++ b/window/src/os/windows/window.rs@@ -2750,7 +2750,15 @@ unsafe fn mouse_wheel(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) ->let coords = mouse_coords(lparam);let screen_coords = ScreenPoint::new(coords.x, coords.y);let coords = screen_to_client(hwnd, screen_coords);- let delta = GET_WHEEL_DELTA_WPARAM(wparam);+ // Windows counts a horizontal wheel turned (or two fingers swiped) to+ // the right as positive; `HorzWheel` counts left as positive, as macOS+ // and Wayland deliver it and as `WheelLeft` reads it. Chromium and WebKit+ // flip it the same way.+ let delta = if msg == WM_MOUSEHWHEEL {+ GET_WHEEL_DELTA_WPARAM(wparam).saturating_neg()+ } else {+ GET_WHEEL_DELTA_WPARAM(wparam)+ };let scaled_delta = if msg == WM_MOUSEWHEEL {delta * (*WHEEL_SCROLL_LINES)} else {@@ -2775,7 +2783,10 @@ unsafe fn mouse_wheel(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) ->inner.hscroll_remainder,position);- if position == 0 {+ // As for the vertical wheel below: sub-column travel goes out as+ // HorzWheel(0) with its fraction, for a surface that pans by+ // pixels.+ if position == 0 && delta == 0 {return Some(0);}MouseEventKind::HorzWheel(position)@@ -2811,13 +2822,9 @@ unsafe fn mouse_wheel(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) ->precise_scroll_delta: None,scroll_phase: None,momentum_phase: None,- // The travel in lines before it was rounded to notches, so a- // sub-line step is not lost; horizontal wheels keep the old path.- precise_wheel_lines: if msg == WM_MOUSEWHEEL {- Some(scaled_delta as f32 / WHEEL_DELTA as f32)- } else {- None- },+ // The travel in lines (columns, for the horizontal wheel) before it+ // was rounded to notches, so a sub-line step is not lost.+ precise_wheel_lines: Some(scaled_delta as f32 / WHEEL_DELTA as f32),};inner.borrow_mut()