[bug] can't create non focused window on MacOS
Describe the bug
I use latest tauri from dev
And I try to create non focused (minimized) window on MacOS
in tauri.conf.json -> windows[0] I set focus to false but when the app opens in MacOS the window is focused instead of being in background / minimized.
The same happens as well with dynamic created windows with focused(false).
Reproduction
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "app",
"width": 800,
"label": "main",
"focus": false // still focused and not minimized on launch
}
]
or
WebviewWindowBuilder::new(&app, "second", tauri::WebviewUrl::External(Url::from_str("https://github.com".into()).unwrap())).focused(false).build().unwrap(); // still focused and not minimized on execute
Expected behavior
Newly created window should be non focused (minimized?)
Full tauri info output
app npx tauri info
WARNING: no lock files found, defaulting to npm
[✔] Environment
- OS: Mac OS 14.2.1 X64
✔ Xcode Command Line Tools: installed
✔ rustc: 1.75.0 (82e1608df 2023-12-21)
✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
✔ Rust toolchain: stable-aarch64-apple-darwin (default)
- node: 18.19.0
- npm: 10.2.3
[-] Packages
- tauri [RUST]: 2.0.0-beta.8
- tauri-build [RUST]: 2.0.0-beta.6
- wry [RUST]: 0.37.0
- tao [RUST]: 0.26.1
- tauri-cli [RUST]: 1.5.9
- @tauri-apps/api : not installed!
- @tauri-apps/cli [NPM]: 2.0.0-beta.1
[-] App
- build-type: bundle
- CSP: unset
Stack trace
No response
Additional context
Looks like an issue in tao, it happens there as well.
@amrbashir Any chance we could get this issue looked at or any workarounds we can apply for now? This bug is detrimental to our app.
There is no workaround that I know of atm, I also don't have access to a macOS to help with these issues
We're also running into this issue while trying to implement a floating overlay window that shouldn't steal keyboard focus. We've tried:
- Setting
focus: falsein the config as mentioned - Experimenting with custom NSPanel implementations (via tauri-nspanel)
- Attempting to create a custom panel class to override
canBecomeKeyWindow
Our specific use case is creating a floating overlay that remains non-interactive with keyboard input while visible. Has there been any progress on this? We're happy to help test potential solutions.
bumping this.
also tried the said settings with extra:
always_on_background(true)
always_on_top(false)
but still it focuses regardless.
would there be a solution somewhat align below?:
window_event(|e| {
if e == Focused {
*de focus*
}
}