From 0b8f3af04fee01f40fca4f52f8b1f9b8cab437c0 Mon Sep 17 00:00:00 2001 From: Sludge <96552222+SludgePhD@users.noreply.github.com> Date: Sat, 13 Aug 2022 17:33:26 +0200 Subject: [PATCH] Also emit all appropriate cursor events --- .../linux/wayland/seat/dnd/handlers.rs | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/platform_impl/linux/wayland/seat/dnd/handlers.rs b/src/platform_impl/linux/wayland/seat/dnd/handlers.rs index cab880bab4f..933cd02130c 100644 --- a/src/platform_impl/linux/wayland/seat/dnd/handlers.rs +++ b/src/platform_impl/linux/wayland/seat/dnd/handlers.rs @@ -8,8 +8,9 @@ use sctk::data_device::{DataOffer, DndEvent}; use wayland_client::Display; use crate::{ + dpi::PhysicalPosition, event::WindowEvent, - platform_impl::wayland::{event_loop::WinitState, make_wid}, + platform_impl::wayland::{event_loop::WinitState, make_wid, DeviceId}, }; use super::DndInner; @@ -21,6 +22,8 @@ pub(super) fn handle_dnd(event: DndEvent<'_>, inner: &mut DndInner, winit_state: DndEvent::Enter { offer: Some(offer), surface, + x, + y, .. } => { let window_id = make_wid(&surface); @@ -34,6 +37,25 @@ pub(super) fn handle_dnd(event: DndEvent<'_>, inner: &mut DndInner, winit_state: .push_window_event(WindowEvent::HoveredFile(path), window_id); } inner.window_id = Some(window_id); + + winit_state.event_sink.push_window_event( + WindowEvent::CursorEntered { + device_id: crate::event::DeviceId( + crate::platform_impl::DeviceId::Wayland(DeviceId), + ), + }, + window_id, + ); + winit_state.event_sink.push_window_event( + WindowEvent::CursorMoved { + device_id: crate::event::DeviceId( + crate::platform_impl::DeviceId::Wayland(DeviceId), + ), + position: PhysicalPosition::new(x, y), + modifiers: Default::default(), + }, + window_id, + ); } } } @@ -57,6 +79,28 @@ pub(super) fn handle_dnd(event: DndEvent<'_>, inner: &mut DndInner, winit_state: winit_state .event_sink .push_window_event(WindowEvent::HoveredFileCancelled, window_id); + winit_state.event_sink.push_window_event( + WindowEvent::CursorLeft { + device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland( + DeviceId, + )), + }, + window_id, + ); + } + } + DndEvent::Motion { x, y, .. } => { + if let Some(window_id) = inner.window_id { + winit_state.event_sink.push_window_event( + WindowEvent::CursorMoved { + device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland( + DeviceId, + )), + position: PhysicalPosition::new(x, y), + modifiers: Default::default(), + }, + window_id, + ); } } _ => {}