Cannot have focus on Ubuntu GNOME
bachrc opened this issue · 9 comments
Describe the bug
I am on Ubuntu 22.04, with GNOME on Xorg (because Tauri doesn’t support global shortcuts on wayland)
My app launches as a tray app.
I registered a global shortcut to show my window, and it works well. Though : the window does not have any focus. When the shortcut is triggered, i get my window, i make it .show(), and I make it .set_focus()… but it won’t. I must click on it to get my focus.
Same with a tray item as a trigger.
Reproduction
- Crrate a Tauri app
- Main window is hidden by default
- App is a tray app
- Register a global shortcut : when triggered, get the main window and make it visible. No focus
- You can make a set_focus too : no focus on the app
Expected behavior
With a show(), the window is supposed to get the focus.
Platform and versions
Environment
› OS: Ubuntu 22.04 X64
› Node.js: 18.13.0
› npm: 8.19.3
› pnpm: 7.25.1
› yarn: Not installed!
› rustup: 1.25.2
› rustc: 1.67.0
› cargo: 1.67.0
› Rust toolchain: stable-x86_64-unknown-linux-gnu
Packages
› @tauri-apps/cli [NPM]: 1.2.3
› @tauri-apps/api [NPM]: 1.2.0
› tauri [RUST]: 1.2.4,
› tauri-build [RUST]: 1.2.1,
› tao [RUST]: 0.15.8,
› wry [RUST]: 0.23.4,
App
› build-type: bundle
› CSP: unset
› distDir: ../build
› devPath: http://localhost:5173/
› framework: Svelte
› bundler: Vite
App directory structure
├─ src
├─ .idea
├─ build
├─ .svelte-kit
├─ static
├─ .git
├─ node_modules
└─ src-tauri
Stack trace
No errors
Additional context
No response
Same happens with me.
Could you guys test with another desktop environment or another window manager? I am pretty sure that's just another Gnome bug (or a restriction).
I had the same problem with archlinux Gnome 43.3, I tested it in a virtual machine with the Deepin desktop environment and found no such problem, I guess maybe it's a Gnome bug?
Additional, when I tested on Gnome, I found that if I don't do anything to the window, I have no problem getting focus at all, but if I open the window with a shortcut once, my mouse has any action in the window (click, scroll wheel), After I close the window, and the next time I open the window with a shortcut, getting focus fails.
I don't have any other DE, I cannot test on another one.
What could the Gnome bug be? I searched through the Gnome issue tracker, and I couldn't find something like this.
I am not sure if it is a bug or not but recently, I have seen more often than before that a lot of APIs stopped working on Gnome, for example, set_focus
and unminimize
and I am not sure if it is just a restriction imposed by the Window Manager in Gnome or straight up a bug but we are calling the right GTK methods so if they ever fix it, the fix will land in tauri automatically.
+1
I just found the same issue on KDE Plasma. Unlike Gnome, when I create a window using a shortcut key on the desktop in KDE, it can capture focus well. However, if the focus is on another window and I create a window using a shortcut key, this new window will not be able to capture focus. Hope this information helps.