Description
On Windows, EventLoopExtPumpEvents::pump_app_events (which is intended for integrating winit into an external event loop) calls PeekMessageW with a null window handle:
PeekMessageW(&mut msg, ptr::null_mut(), 0, 0, PM_REMOVE)
This pulls all messages for the current thread, not just those related to winit. As a result, winit ends up draining the thread’s message queue.
This becomes a problem if the application also uses its own Win32 message loop or manages additional windows outside of winit. Messages intended for other parts of the application may be consumed before they can be handled.
I understand this may be intentional, since some messages are thread-level, but it makes it difficult to integrate winit into setups where message dispatching is shared.
In my case, winit is only used for a small UI part, while other windows are created and handled directly via Win32. With the current behavior, it’s hard to keep those parts independent.
Is there a recommended way to use winit alongside an existing message loop without it consuming unrelated messages? Alternatively, would it make sense to allow restricting message retrieval to winit-owned windows or making this configurable?
Relevant platforms
Windows
Description
On Windows,
EventLoopExtPumpEvents::pump_app_events(which is intended for integrating winit into an external event loop) callsPeekMessageWwith a null window handle:PeekMessageW(&mut msg, ptr::null_mut(), 0, 0, PM_REMOVE)This pulls all messages for the current thread, not just those related to winit. As a result, winit ends up draining the thread’s message queue.
This becomes a problem if the application also uses its own Win32 message loop or manages additional windows outside of winit. Messages intended for other parts of the application may be consumed before they can be handled.
I understand this may be intentional, since some messages are thread-level, but it makes it difficult to integrate winit into setups where message dispatching is shared.
In my case, winit is only used for a small UI part, while other windows are created and handled directly via Win32. With the current behavior, it’s hard to keep those parts independent.
Is there a recommended way to use winit alongside an existing message loop without it consuming unrelated messages? Alternatively, would it make sense to allow restricting message retrieval to winit-owned windows or making this configurable?
Relevant platforms
Windows