Skip to content

Commit

Permalink
Also emit all appropriate cursor events
Browse files Browse the repository at this point in the history
  • Loading branch information
SludgePhD committed Aug 13, 2022
1 parent c3a61fa commit 0b8f3af
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/platform_impl/linux/wayland/seat/dnd/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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,
);
}
}
}
Expand All @@ -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,
);
}
}
_ => {}
Expand Down

0 comments on commit 0b8f3af

Please sign in to comment.