I'm trying to construct my application in such a way that the winit (or really Glutin) event loop is on another thread, e,g.:
let events_loop = ...
let window = glutin::GlWindow::new(...pass in events_loop and windowbuilder, etc...)
thread::spawn(move || {
events_loop.run_forever(|event| {
....convert events to other format and dispatch...
ControlFlow::Continue
});
);
This way my application is not "driven" by the winit event loop, it has just become a source of events for other parts of my code.
Anyway, the window I have is not moved to that thread, it's just the event loop that's running there. This works fine on Windows. Except on Wayland (Ubuntu) every method I invoke on window is blocked unless the event loop becomes momentarily awakened, like when I move my mouse:
// blocks!
let _ = window.get_inner_size_pixels().unwrap();
The same thing happens when calling swap_buffers on glutin's GlWindow. This will block unless the event loop is somehow awakened. Everything is fine, then.
Is this by design? Is it not supported to run the event loop on a separate thread?
I'm trying to construct my application in such a way that the winit (or really Glutin) event loop is on another thread, e,g.:
This way my application is not "driven" by the winit event loop, it has just become a source of events for other parts of my code.
Anyway, the window I have is not moved to that thread, it's just the event loop that's running there. This works fine on Windows. Except on Wayland (Ubuntu) every method I invoke on
windowis blocked unless the event loop becomes momentarily awakened, like when I move my mouse:The same thing happens when calling
swap_bufferson glutin's GlWindow. This will block unless the event loop is somehow awakened. Everything is fine, then.Is this by design? Is it not supported to run the event loop on a separate thread?