fix(magnifier): smooth mouse wheel zoom and respect natural scroll direction

- Disable animation for mouse wheel zoom to eliminate the timing race
  that causes lag and sudden jumps. Each wheel tick now zooms instantly.
- Invert zoom direction when natural scrolling is enabled so that
  forward scroll zooms in, matching macOS/Windows behavior.
This commit is contained in:
Tom Grushka 2026-05-15 15:51:24 -06:00
parent b5186ef21a
commit 92fcceba54

View file

@ -37,11 +37,12 @@ use cosmic_settings_config::shortcuts;
use cosmic_settings_config::shortcuts::action::{Direction, ResizeDirection}; use cosmic_settings_config::shortcuts::action::{Direction, ResizeDirection};
use smithay::{ use smithay::{
backend::input::{ backend::input::{
AbsolutePositionEvent, Axis, AxisSource, Device, DeviceCapability, GestureBeginEvent, AbsolutePositionEvent, Axis, AxisRelativeDirection, AxisSource, Device, DeviceCapability,
GestureEndEvent, GesturePinchUpdateEvent as _, GestureSwipeUpdateEvent as _, InputBackend, GestureBeginEvent, GestureEndEvent, GesturePinchUpdateEvent as _,
InputEvent, KeyState, KeyboardKeyEvent, PointerAxisEvent, ProximityState, Switch, GestureSwipeUpdateEvent as _, InputBackend, InputEvent, KeyState, KeyboardKeyEvent,
SwitchState, SwitchToggleEvent, TabletToolButtonEvent, TabletToolEvent, PointerAxisEvent, ProximityState, Switch, SwitchState, SwitchToggleEvent,
TabletToolProximityEvent, TabletToolTipEvent, TabletToolTipState, TouchEvent, TabletToolButtonEvent, TabletToolEvent, TabletToolProximityEvent, TabletToolTipEvent,
TabletToolTipState, TouchEvent,
}, },
desktop::{PopupKeyboardGrab, WindowSurfaceType, utils::under_from_surface_tree}, desktop::{PopupKeyboardGrab, WindowSurfaceType, utils::under_from_surface_tree},
input::{ input::{
@ -914,12 +915,18 @@ impl State {
.or_else(|| event.amount(Axis::Vertical)) .or_else(|| event.amount(Axis::Vertical))
.map(|val| val * scroll_factor) .map(|val| val * scroll_factor)
{ {
if event.relative_direction(Axis::Vertical)
== AxisRelativeDirection::Inverted
{
percentage *= -1.;
}
if event.source() == AxisSource::Wheel { if event.source() == AxisSource::Wheel {
percentage *= 5.; percentage *= 5.;
} }
let change = -(percentage / 100.); let change = -(percentage / 100.);
self.update_zoom(&seat, change, event.source() == AxisSource::Wheel); self.update_zoom(&seat, change, false);
} }
} else { } else {
let mut frame = AxisFrame::new(event.time_msec()).source(event.source()); let mut frame = AxisFrame::new(event.time_msec()).source(event.source());