tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
79.58k stars 2.36k forks source link

[bug] Window focus is done prematurely in development #7053

Open AuracleTech opened 1 year ago

AuracleTech commented 1 year ago

Describe the bug

Tauri doesn't focus when the window instance is launched, instead the focus is done prematurely during loading right after compilation which means that any focus on another window during loading will make the window appear in the background

Reproduction

Launch compile & run and focus on any other window (VSC for example) when tauri is launched it will be in the background

2023-05-24 15-18-11.webm

Expected behavior

When the window is launched (visible to the user) the focus is applied Currently the focus is applied earlier even though the window is not visible

Platform and versions

[✘] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 113.0.1774.50
    ✘ Couldn't detect Visual Studio or Visual Studio Build Tools. Download from https://aka.ms/vs/17/release/vs_BuildTools.exe
    ✔ rustc: 1.69.0 (84c898d65 2023-04-16)
    ✔ Cargo: 1.69.0 (6e9a83356 2023-04-12)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)

[-] Packages
    - tauri [RUST]: 1.3.0
    - tauri-build [RUST]: 1.3.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.1
    - @tauri-apps/api [NPM]: not installed!
    - @tauri-apps/cli [NPM]: 1.3.1

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../src
    - devPath: ../src

Stack trace

No response

Additional context

No response

amrbashir commented 1 year ago

Sounds to me like an issue that would only happen while developing and not in a release build but I need to know your window configuration or better, a minimal repro.

FabianLars commented 1 year ago

For context 2 discord threads: https://discord.com/channels/616186924390023171/731495028677148753/1111000687308963901 (from OP) https://discord.com/channels/616186924390023171/1114886207520911391 (same issue different user)

The repro is basically:

  1. Have a window configured in tauri.conf.json, anything will do
  2. Run tauri dev and, in case you're manually running it in a terminal, focus something else than the terminal before the window opens.
  3. Also try triggering the dev watcher, it will rebuild the app without bringing it up front.
amrbashir commented 1 year ago

I can't reproduce, neither using tauri dev or a release build binary.

amrbashir commented 1 year ago

I am closing this for now since it doesn't seem to affect the release build or when actually launching the executable normally without the tauri CLI involved.

FabianLars commented 1 year ago

tbh this is kinda annoying me too so i will reopen this with a low prio and assign myself to it :)

(Edit: if i can't find a workaround that does not affect production i'll close it again)

THEGOLDENPRO commented 9 months ago

yeah I +1 this. Slightly annoying during development.