wayland: Set cusor position on Enter events

Fixes https://github.com/pop-os/cosmic-workspaces-epoch/issues/143.

The way some events are converted to `WindowEvent`s in `pointer_frame`
but motion is handled in `SctkEvent::process` seems a little cluttered
at the moment, I guess from how this code was ported to be part of
iced-winit instead of separate. But as I understand, the code handling
`PointerEventKind::Enter` in `SctkEvent::enter` wasn't being called, so
that can be replaced with the new code here that sets the logical cursor
position.
This commit is contained in:
Ian Douglas Scott 2025-04-07 09:52:02 -07:00 committed by Ashley Wulber
parent b775402f65
commit 53fed52405
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
2 changed files with 22 additions and 8 deletions

View file

@ -66,6 +66,18 @@ impl PointerHandler for SctkState {
*entry = FrameStatus::Ready;
}
if let PointerEventKind::Enter { .. } = &e.kind {
self.sctk_events.push(SctkEvent::PointerEvent {
variant: PointerEvent {
surface: e.surface.clone(),
position: e.position,
kind: e.kind.clone(),
},
ptr_id: pointer.clone(),
seat_id: my_seat.seat.clone(),
});
}
if let PointerEventKind::Motion { time } = &e.kind {
self.sctk_events.push(SctkEvent::PointerEvent {
variant: PointerEvent {

View file

@ -370,14 +370,16 @@ impl SctkEvent {
SctkEvent::SeatEvent { .. } => Default::default(),
SctkEvent::PointerEvent { variant, .. } => match variant.kind {
PointerEventKind::Enter { .. } => {
events.push((
surface_ids
.get(&variant.surface.id())
.map(|id| id.inner()),
iced_runtime::core::Event::Mouse(
mouse::Event::CursorEntered,
),
));
let id = surface_ids
.get(&variant.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(
(variant.position.0, variant.position.1).into(),
)
}
}
PointerEventKind::Leave { .. } => events.push((
surface_ids.get(&variant.surface.id()).map(|id| id.inner()),