Merge pull request #2381 from dra11y/fix-magnifier-scroll
fix(magnifier): smooth mouse wheel zoom and respect natural scroll direction
This commit is contained in:
commit
8450e89de4
2 changed files with 15 additions and 8 deletions
|
|
@ -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,6 +915,12 @@ 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.;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use cosmic::{
|
||||||
};
|
};
|
||||||
use cosmic_comp_config::ZoomMovement;
|
use cosmic_comp_config::ZoomMovement;
|
||||||
use cosmic_config::ConfigSet;
|
use cosmic_config::ConfigSet;
|
||||||
use keyframe::{ease, functions::EaseInOutCubic};
|
use keyframe::{ease, functions::Linear};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::renderer::{ImportMem, Renderer, element::AsRenderElements},
|
backend::renderer::{ImportMem, Renderer, element::AsRenderElements},
|
||||||
desktop::space::SpaceElement,
|
desktop::space::SpaceElement,
|
||||||
|
|
@ -135,7 +135,7 @@ impl OutputZoomState {
|
||||||
let percentage =
|
let percentage =
|
||||||
duration_since.as_millis() as f32 / ANIMATION_DURATION.as_millis() as f32;
|
duration_since.as_millis() as f32 / ANIMATION_DURATION.as_millis() as f32;
|
||||||
ease(
|
ease(
|
||||||
EaseInOutCubic,
|
Linear,
|
||||||
EasePoint(*old_point),
|
EasePoint(*old_point),
|
||||||
EasePoint(self.focal_point),
|
EasePoint(self.focal_point),
|
||||||
percentage,
|
percentage,
|
||||||
|
|
@ -159,7 +159,7 @@ impl OutputZoomState {
|
||||||
let percentage = Instant::now().duration_since(*start).as_millis() as f32
|
let percentage = Instant::now().duration_since(*start).as_millis() as f32
|
||||||
/ ANIMATION_DURATION.as_millis() as f32;
|
/ ANIMATION_DURATION.as_millis() as f32;
|
||||||
|
|
||||||
ease(EaseInOutCubic, *old_level, self.level, percentage)
|
ease(Linear, *old_level, self.level, percentage)
|
||||||
} else {
|
} else {
|
||||||
self.level
|
self.level
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue