Skip to content

Windows: pump_app_events consumes entire thread message queue #4554

@LaG1924

Description

@LaG1924

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions