fix: add Event::Move check preventing infinite recursion caused by stale surfaces

This commit is contained in:
En-En 2024-12-05 23:40:53 +00:00 committed by Shawn Wallace
parent 02f3054626
commit c45c2ed990

View file

@ -346,7 +346,6 @@ impl HandleEvent for Pointer {
// destroy the menu if this occurs within a 500 ms interval (which it always does with // destroy the menu if this occurs within a 500 ms interval (which it always does with
// Niri). Other compositors do not run into this problem because they appear to not send // Niri). Other compositors do not run into this problem because they appear to not send
// wl_pointer.enter until the user actually moves the mouse in the popup. // wl_pointer.enter until the user actually moves the mouse in the popup.
let mut process_event = Vec::new();
match event { match event {
client::wl_pointer::Event::Enter { client::wl_pointer::Event::Enter {
serial, serial,
@ -423,14 +422,20 @@ impl HandleEvent for Pointer {
else { else {
unreachable!(); unreachable!();
}; };
process_event.push(client::wl_pointer::Event::Enter { let surface_key: ObjectKey = surface.data().copied().unwrap();
serial: *serial, if state.objects.get(surface_key).is_some() {
surface: surface.clone(), trace!("resending enter ({serial}) before motion");
surface_x: *surface_x, let enter_event = client::wl_pointer::Event::Enter {
surface_y: *surface_y, serial: *serial,
}); surface: surface.clone(),
process_event.push(event); surface_x: *surface_x,
trace!("resending enter ({serial}) before motion"); surface_y: *surface_y,
};
self.handle_event(enter_event, state);
self.handle_event(event, state);
} else {
warn!("could not move pointer to surface ({serial}): stale surface");
}
} else { } else {
self.server.motion(time, surface_x, surface_y); self.server.motion(time, surface_x, surface_y);
} }
@ -496,10 +501,6 @@ impl HandleEvent for Pointer {
] ]
}, },
} }
for event in process_event {
self.handle_event(event, state);
}
} }
} }