Skip to content

Commit ed5c70b

Browse files
committed
fix: translate the wayland event position for content inside a scrollable
1 parent 8bc47f5 commit ed5c70b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

core/src/event/wayland/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,20 @@ pub enum Event {
4343
/// Frame events
4444
Frame(Instant, WlSurface, Id),
4545
}
46+
47+
impl Event {
48+
/// Translate the event by some vector
49+
pub fn translate(&mut self, vector: crate::vector::Vector) {
50+
match self {
51+
Event::DndOffer(DndOfferEvent::Enter { x, y, .. }) => {
52+
*x += vector.x as f64;
53+
*y += vector.y as f64;
54+
}
55+
Event::DndOffer(DndOfferEvent::Motion { x, y }) => {
56+
*x += vector.x as f64;
57+
*y += vector.y as f64;
58+
}
59+
_ => {}
60+
}
61+
}
62+
}

widget/src/scrollable.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ pub fn layout<Renderer>(
657657
/// accordingly.
658658
pub fn update<Message>(
659659
state: &mut State,
660-
event: Event,
660+
#[allow(unused_mut)] mut event: Event,
661661
layout: Layout<'_>,
662662
cursor: mouse::Cursor,
663663
clipboard: &mut dyn Clipboard,
@@ -699,6 +699,14 @@ pub fn update<Message>(
699699

700700
let translation = state.translation(direction, bounds, content_bounds);
701701

702+
#[cfg(feature = "wayland")]
703+
if let Event::PlatformSpecific(
704+
iced_runtime::core::event::PlatformSpecific::Wayland(e),
705+
) = &mut event
706+
{
707+
e.translate(translation);
708+
}
709+
702710
update_content(
703711
event.clone(),
704712
content,

0 commit comments

Comments
 (0)