From 9e45bd2378c8baaba9be3fe97135fc7915ae83ff Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 30 Jul 2025 13:12:05 -0700 Subject: [PATCH] winit/sctk: Update cursor position on touch event Ideally pointer should be seperate from touch, but this should match how Iced handles input in normal winit windows. https://github.com/iced-rs/iced/blob/d475ae5b454b82cb549d6dd961ae158eb5ac7f19/winit/src/window/state.rs#L165-L170 With this, touch input for applets seems to work as expected in general. --- .../platform_specific/wayland/sctk_event.rs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/winit/src/platform_specific/wayland/sctk_event.rs b/winit/src/platform_specific/wayland/sctk_event.rs index 32e2bb4c..96d57adc 100755 --- a/winit/src/platform_specific/wayland/sctk_event.rs +++ b/winit/src/platform_specific/wayland/sctk_event.rs @@ -687,10 +687,23 @@ impl SctkEvent { touch_id: _, seat_id: _, surface, - } => events.push(( - surface_ids.get(&surface.id()).map(|id| id.inner()), - iced_runtime::core::Event::Touch(variant), - )), + } => { + let position = match variant { + touch::Event::FingerPressed { position, .. } => position, + touch::Event::FingerMoved { position, .. } => position, + touch::Event::FingerLifted { position, .. } => position, + touch::Event::FingerLost { position, .. } => position, + }; + let id = surface_ids.get(&surface.id()).map(|id| id.inner()); + if let Some(w) = + id.clone().and_then(|id| window_manager.get_mut(id)) + { + w.state.set_logical_cursor_pos( + (position.x, position.y).into(), + ); + } + events.push((id, iced_runtime::core::Event::Touch(variant))) + } SctkEvent::WindowEvent { .. } => {} SctkEvent::LayerSurfaceEvent { variant,