bevy
bevy copied to clipboard
`close_on_esc` does nothing if window was immediately focused on creation
https://github.com/bevyengine/bevy/blob/55957330351828e84bfc63cf8e151e2805e9d278/crates/bevy_window/src/system.rs#L46
On Linux with i3 WM, sometimes the app window will be focused on creation with no initial WindowFocused event. When this happens, close_on_esc does nothing until you unfocus and refocus the window to send a WindowFocused event.
This might be related to IntelliJ. When I start my game from the terminal instead, there seems to always be an initial WindowFocused event. Also, rarely when started from IntelliJ, the game window will be (apparently) focused, and will register mouse click events, but all keyboard events will get sent to IntelliJ itself instead of the game window.
EDIT: Actually I was able to reproduce the no initial WindowFocused event in a terminal. It's just way less common there for some reason.
As far as I can tell, this must be a winit bug/issue.
A search in winit's docs for 'focus' suggest that it doesn't expose any other way for getting window focus.
Alternatively, your window manager is lying to your programs about their focus state.
This sounds like correct behaviour, only the focused window should be able to read keyboard input.
You can configure i3 to focus a window on creation though.
in .config/i3/config add something like:
for_window [class="bevy_game"] floating enable focus
xprop can assist in knowing the window class of your application.
The behavior is that close_on_esc doesn't work (and rarely, keyboard input events aren't even received) despite the fact that the window is focused on creation.
This reminded me of some changes I've got stashed from a couple months ago that would fix this. I'll probably have the PR up in a bit :)
The behavior is that
close_on_escdoesn't work (and rarely, keyboard input events aren't even received) despite the fact that the window is focused on creation.
If you figure out a way to reliably reproduce this let me know, It hasn't happened to me yet in i3 after months of use with bevy.
Can be closed as obsolete after https://github.com/bevyengine/bevy/pull/12859.
Ok I switched accounts lol closing this myself