Node.js: Avoid running epoll() in the wayland event loop when pumping… (#7682)

Work around pump_events() with `Some(std::time::Duration::ZERO)` still entering `epoll` and thus not returning, preventing us from processing node events.

cc  #7657


Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
This commit is contained in:
Simon Hausmann 2025-02-21 14:50:20 +01:00 committed by GitHub
parent 3c7494a543
commit 2b6938bce8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -276,6 +276,9 @@ pub struct EventLoopState {
loop_error: Option<PlatformError>,
current_resize_direction: Option<ResizeDirection>,
/// Set to true when pumping events for the shortest amount of time possible.
pumping_events_instantly: bool,
}
impl winit::application::ApplicationHandler<SlintUserEvent> for EventLoopState {
@ -607,6 +610,10 @@ impl winit::application::ApplicationHandler<SlintUserEvent> for EventLoopState {
event_loop.set_control_flow(ControlFlow::wait_duration(next_timer));
}
}
if self.pumping_events_instantly {
event_loop.set_control_flow(ControlFlow::Poll);
}
}
}
@ -766,9 +773,13 @@ impl EventLoopState {
let mut winit_loop = not_running_loop_instance.instance;
self.pumping_events_instantly = timeout.is_some_and(|duration| duration.is_zero());
let result = winit_loop
.pump_app_events(timeout, &mut ActiveEventLoopSetterDuringEventProcessing(&mut self));
self.pumping_events_instantly = false;
*GLOBAL_PROXY.get_or_init(Default::default).lock().unwrap() = Default::default();
// Keep the EventLoop instance alive and re-use it in future invocations of run_event_loop().