diff --git a/core/src/event/wayland/mod.rs b/core/src/event/wayland/mod.rs index bf3ddcb1b0..f7bfd5bac7 100644 --- a/core/src/event/wayland/mod.rs +++ b/core/src/event/wayland/mod.rs @@ -43,3 +43,20 @@ pub enum Event { /// Frame events Frame(Instant, WlSurface, Id), } + +impl Event { + /// Translate the event by some vector + pub fn translate(&mut self, vector: crate::vector::Vector) { + match self { + Event::DndOffer(DndOfferEvent::Enter { x, y, .. }) => { + *x += vector.x as f64; + *y += vector.y as f64; + } + Event::DndOffer(DndOfferEvent::Motion { x, y }) => { + *x += vector.x as f64; + *y += vector.y as f64; + } + _ => {} + } + } +} diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 7b520476ad..3525b01952 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -657,7 +657,7 @@ pub fn layout( /// accordingly. pub fn update( state: &mut State, - event: Event, + #[allow(unused_mut)] mut event: Event, layout: Layout<'_>, cursor: mouse::Cursor, clipboard: &mut dyn Clipboard, @@ -699,6 +699,14 @@ pub fn update( let translation = state.translation(direction, bounds, content_bounds); + #[cfg(feature = "wayland")] + if let Event::PlatformSpecific( + iced_runtime::core::event::PlatformSpecific::Wayland(e), + ) = &mut event + { + e.translate(translation); + } + update_content( event.clone(), content,