I'm writing various graphical tests in Bevy. Each spawns the GUI, runs for a few seconds, and then exits the app and moves on to the next.
I love being able to visually check its doing what I think, but when each starts it steals focus from VS Code. This means I can't code while the tests are running, or use a 'hot-reload' workflow.
I understand that Bevy uses Winit under the hood, but couldn't find anything in either the bevy plugin or Winit source on opening a window without focus, or surrendering focus once it is open.
My ideal solution would be a simple setting in the WindowDescriptor
:
App::new()
.insert_resource(WindowDescriptor {
// this would be awesome
open_without_focus:true,
..Default::default()
})
.run()
A few notes:
- I'm on Windows 11 but it would be great to have a platform agnostic solution.
- I have tried various Always On Top solutions like PowerToys but this doesn't help with focus.
Not ideal, but am finding invoking
Alt+Escape
with enigo better than nothing: