From 4881b172e0c7705c4c119a0657660ade726cf2d0 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Tue, 22 Oct 2024 19:05:18 +0900 Subject: [PATCH] chore: try to fix scroll problem --- iced_layershell/src/event.rs | 11 ++++++----- iced_sessionlock/src/event.rs | 2 +- layershellev/src/events.rs | 4 ++++ layershellev/src/lib.rs | 13 +++++++++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/iced_layershell/src/event.rs b/iced_layershell/src/event.rs index 789c010..6e7b227 100644 --- a/iced_layershell/src/event.rs +++ b/iced_layershell/src/event.rs @@ -215,6 +215,7 @@ impl From<&DispatchMessage> for IcedLayerEvent { if horizontal.stop && vertical.stop { @@ -223,13 +224,13 @@ impl From<&DispatchMessage> for IcedLayerEvent From<&DispatchMessage> for IcedSessionLockEvent y: -vertical.discrete as f32, }); } - IcedSessionLockEvent::Window(WindowEvent::Axis { + IcedSessionLockEvent::Window(WindowEvent::PixelDelta { x: -horizontal.absolute as f32, y: -vertical.absolute as f32, }) diff --git a/layershellev/src/events.rs b/layershellev/src/events.rs index f395f1d..21b1a70 100644 --- a/layershellev/src/events.rs +++ b/layershellev/src/events.rs @@ -186,6 +186,7 @@ pub(crate) enum DispatchMessageInner { surface_y: f64, }, Axis { + scale: f64, time: u32, horizontal: AxisScroll, vertical: AxisScroll, @@ -276,6 +277,7 @@ pub enum DispatchMessage { }, /// About the scroll Axis { + scale: f64, time: u32, horizontal: AxisScroll, vertical: AxisScroll, @@ -410,11 +412,13 @@ impl From for DispatchMessage { is_created, }, DispatchMessageInner::Axis { + scale, time, horizontal, vertical, source, } => DispatchMessage::Axis { + scale, time, horizontal, vertical, diff --git a/layershellev/src/lib.rs b/layershellev/src/lib.rs index f68b1cd..aa6ca9a 100644 --- a/layershellev/src/lib.rs +++ b/layershellev/src/lib.rs @@ -1357,6 +1357,15 @@ impl Dispatch for WindowState { _conn: &Connection, _qhandle: &wayland_client::QueueHandle, ) { + let Some(surface_id) = state.surface_id() else { + return; + }; + let Some(scale) = state + .get_unit_with_id(surface_id) + .map(|unit| unit.scale_float()) + else { + return; + }; match event { wl_pointer::Event::Axis { time, axis, value } => match axis { WEnum::Value(axis) => { @@ -1374,6 +1383,7 @@ impl Dispatch for WindowState { state.message.push(( state.surface_id(), DispatchMessageInner::Axis { + scale, time, horizontal, vertical, @@ -1398,6 +1408,7 @@ impl Dispatch for WindowState { state.message.push(( state.surface_id(), DispatchMessageInner::Axis { + scale, time, horizontal, vertical, @@ -1414,6 +1425,7 @@ impl Dispatch for WindowState { WEnum::Value(source) => state.message.push(( state.surface_id(), DispatchMessageInner::Axis { + scale, horizontal: AxisScroll::default(), vertical: AxisScroll::default(), source: Some(source), @@ -1442,6 +1454,7 @@ impl Dispatch for WindowState { state.message.push(( state.surface_id(), DispatchMessageInner::Axis { + scale, time: 0, horizontal, vertical,