rukai / winit_input_helper

Processes winit events, allowing input state to be queried at any time.
MIT License
72 stars 31 forks source link

CloseRequested from windows task bar is not propagated #55

Open Azkellas opened 8 months ago

Azkellas commented 8 months ago

Clicking on "Close window" via the windows task bar is ignored in winit_inputhelper. The CloseRequested event is sent between two steps, after an AboutToWait and before a `NewEvents(), so when theNewEvents(_)arrives, the step begins and resetWinitInputHelper::close_requestedtofalse`.

With ControlFlow::Poll:

event: NewEvents(Poll)
event: AboutToWait
event: WindowEvent { window_id: WindowId(WindowId(11996930)), event: CloseRequested }
event: WindowEvent { window_id: WindowId(WindowId(11996930)), event: Focused(true) }
event: NewEvents(Poll)
event: AboutToWait

Without ControlFlow::Poll:

event: AboutToWait
event: NewEvents(WaitCancelled { start: Instant { t: 1776733.8859361s }, requested_resume: None })
event: AboutToWait
event: WindowEvent { window_id: WindowId(WindowId(340828)), event: Focused(true) }
event: WindowEvent { window_id: WindowId(WindowId(340828)), event: CloseRequested }
event: NewEvents(WaitCancelled { start: Instant { t: 1776734.1857145s }, requested_resume: None })
event: AboutToWait
rukai commented 7 months ago

Thankyou for the thorough investigation! Its not clear to me if winit is breaking its contract by returning events between an AboutToWait and a NewEvent, I'll raise an issue on their repo to get it clarified.