Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Calling webContents.focus() forces the entire window to raise above other windows on Linux/GNOME #38184

Open
3 tasks done
devinbinnie opened this issue May 4, 2023 · 10 comments
Labels
24-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/

Comments

@devinbinnie
Copy link

Preflight Checklist

Electron Version

24.1.3

What operating system are you using?

Ubuntu

Operating System Version

22.04.2 LTS, GNOME 42.5

What arch are you using?

x64

Last Known Working Electron version

Not sure, it's been around a while.

Expected Behavior

  1. Using gnome-tweaks, turn on "Focus on Hover" under the Windows category
  2. Open an Electron app where webContents.focus() is called when the window is focused (see gist), and then click on another window that overlaps the application.
  3. Move the cursor over the Electron app's window.

The app should take focus, but the window should not raise above the overlapping app.

Actual Behavior

The app takes focus, and the window raises over top.

Testcase Gist URL

https://gist.github.com/devinbinnie/c0262f5c890edc033fdfe5b7e4209ded

Additional Information

This issue particularly impacts applications where the developer might want to focus a BrowserView when the application is focused, and the user has "sloppy focus" or focus-on-hover enabled on their system.

eg. This issue: mattermost/desktop#1827

@bmnave
Copy link

bmnave commented May 4, 2023

+1

@jkleinsc jkleinsc added has-repro-gist Issue can be reproduced with code at https://gist.github.com/ 24-x-y labels Jun 6, 2023
@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@bmnave
Copy link

bmnave commented Sep 5, 2023

+1

@jin-eld
Copy link

jin-eld commented Nov 7, 2023

Happens on Fedora 37 with MATE desktop as well, see comment mattermost/desktop#1827 (comment)

@darkwater4213
Copy link

darkwater4213 commented Jan 10, 2024

Can confirm on Xfce, xUbuntu versions 16.04 (Xenial), 18.04 (Bionic), and 20.04 (Focal).
This is really quite annoying, particularly with apps that are supposed to stay in the background, like Discord. Worse, apps like Obsidian raise themselves multiple times (three or more) during startup, which is particularly annoying when I'm trying to do something else.

@jctaylor
Copy link

+1

@darkwater4213
Copy link

Further, this bug also happens from time to time on i3wm/Sway.

Obsidian does not forcibly raise itself and switch workspaces, but Discord and Steam do.

And it's annoying.

@darkwater4213
Copy link

Further odd behavior: when running under Hyprland, all three of Obsidian, Steam, and Discord raise themselves, but workspace switching is sporadic. Further, ZSA's Keymapp utility did not raise itself under any of these environments.

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@bmnave
Copy link

bmnave commented Jun 7, 2024

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
24-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/
Projects
No open projects
Status: Unsorted Items
Development

No branches or pull requests

6 participants