tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] Tap the system tray to trigger other applications

Open DWHengr opened this issue 3 years ago • 10 comments

Describe the bug

When I click on the system tray, I see an input method toggle and trigger other application hover Windows.

https://user-images.githubusercontent.com/55067857/195519569-03775949-5dc5-49a0-b42b-c6396712b18e.mp4

When I comment out the window.set_focus().unwrap(), there is no bug.

https://user-images.githubusercontent.com/55067857/195520615-83ecb3d6-6dc9-4ec2-a37b-431c3dbe90db.mp4

code address:https://github.com/DWHengr/flash/blob/main/src-tauri/src/main.rs

Reproduction

No response

Expected behavior

No response

Platform and versions

Environment › OS: Windows 10.0.19043 X64 › Webview2: 106.0.1370.37 › MSVC: - Visual Studio Community 2022 › Node.js: 14.15.4 › npm: 6.14.10 › pnpm: 7.9.5 › yarn: 1.22.17 › rustup: 1.25.1 › rustc: 1.63.0 › cargo: 1.63.0 › Rust toolchain: stable-x86_64-pc-windows-msvc

Packages › @tauri-apps/cli [NPM]: 1.1.1 › @tauri-apps/api [NPM]: 1.1.0 › tauri [RUST]: 1.1.1, › tauri-build [RUST]: 1.1.1, › tao [RUST]: 0.14.0, › wry [RUST]: 0.21.1,

App › build-type: bundle › CSP: unset › distDir: ../dist › devPath: http://localhost:1420/ › framework: React

App directory structure ├─ .git ├─ .idea ├─ .vscode ├─ dist ├─ node_modules ├─ public ├─ src └─ src-tauri

Stack trace

No response

Additional context

No response

DWHengr avatar Oct 13 '22 06:10 DWHengr

Do you have this option enabled? image

amrbashir avatar Oct 13 '22 10:10 amrbashir

No Settings allowed. And tapping the system tray triggers a hover application.

DWHengr avatar Oct 13 '22 11:10 DWHengr

I am really not sure what you mean by that and the videos are not clear enough either. The only somewhat weird behavior I see is the input language change which would make sense if you have option I mentioned above enabled.

amrbashir avatar Oct 13 '22 11:10 amrbashir

This is the effect of double clicking on other applications:

https://user-images.githubusercontent.com/55067857/195587772-6af8eda1-c5ec-4900-90ac-78d5ed480b9a.mp4

I double-click on the system tray here and it triggers the application as well:

https://user-images.githubusercontent.com/55067857/195588233-661d3eb1-df91-44b5-9530-3a21ab070f50.mp4

DWHengr avatar Oct 13 '22 11:10 DWHengr

What is that app name? or is it something you are developing?

amrbashir avatar Oct 13 '22 12:10 amrbashir

The app is Tencent PC Manager from Tencent in China.

DWHengr avatar Oct 13 '22 12:10 DWHengr

Just clearing some info, the problem is not in the system tray icon, it is in the call to window.set_focus and I am also assuming that your window gets hidden automatically when it loses focus, right?

Now about the tencent app launching its rocket, it maybe a bug in that tencent app logic, like it could be triggering that logic based on a focus event also and not just click, so we need to confirm if another app has this issue, by making another tauri app that listens globally on the window for click events and logs it, if clicking the system tray icon, logs that it was indeed clicked I will try to investigate it, otherwise it is a bug in the tencent app.

amrbashir avatar Oct 13 '22 12:10 amrbashir

Yes, my own app hides when it loses focus. And clicking the system tray triggers an input method switch.

DWHengr avatar Oct 13 '22 14:10 DWHengr

And clicking the system tray triggers an input method switch.

If you have the option I mentioned earlier enabled, then it makes sense, otherwise it is probably a bug in Windows but that's a different bug.

The bug you described, is that the tencent app receives a click upon calling window.set_focus when it shouldn't, and we need to confirm that behavior by doing the following:

making another tauri app that listens globally on the window for click events and logs it the console. Then try click the system tray icon once which will call window.set_focus in your app, then check the console for logs, if you find any logs there that confirm the bug.

amrbashir avatar Oct 13 '22 14:10 amrbashir

Click to trigger the input method switch, double-click to trigger the Tencent app.

My program logic is that when out of focus, the hidden window listens to tauri:: WindowEvent:: Focused, and when clicking the point tray, the window listens to SystemTrayEvent:: LeftClick.

DWHengr avatar Oct 13 '22 14:10 DWHengr

I couldn't reproduce neither of bugs mentioned here.

For the language picker bug, this is probably just because Let me set a different input method for each app window Windows option is ON and your app window and another app window has a different input method selected when they were last active.

For the tencent app launching bug, I made an app that logs to console if a click happens within its window, and another app that has a tray icon when clicked, will show a hidden window and focuses it and the window hides when losing focus. You can see in the attached GIF that it doesn't matter how many times I click on tray and toggle the window, the window in the left doesn't log anything until clicking inside it.

sss

amrbashir avatar Oct 18 '22 22:10 amrbashir