tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] Window focus is done prematurely in development

Open AuracleTech opened this issue 1 year ago • 5 comments

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

AuracleTech avatar May 24 '23 20:05 AuracleTech

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.

amrbashir avatar Jun 05 '23 10:06 amrbashir

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.

FabianLars avatar Jun 05 '23 10:06 FabianLars

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

amrbashir avatar Jun 06 '23 16:06 amrbashir

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.

amrbashir avatar Jun 06 '23 16:06 amrbashir

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)

FabianLars avatar Jun 06 '23 19:06 FabianLars

yeah I +1 this. Slightly annoying during development.

THEGOLDENPRO avatar Oct 03 '23 23:10 THEGOLDENPRO