koekeishiya / yabai

A tiling window manager for macOS based on binary space partitioning
MIT License
23.27k stars 641 forks source link

Some applications raise even though autofocus is set #397

Open pixmin opened 4 years ago

pixmin commented 4 years ago

I have just installed yabai with a minimal setup (to use "focus follow mouse" feature, without auto raise):

yabai -m config focus_follows_mouse autofocus

It works great, except for Firefox (at least that's the only application I've noticed so far). In addition to getting focused when being mouse over, Firefox also get raised.

Any idea why/how to fix this?

Thanks,

koekeishiya commented 4 years ago

The autofocus functionality was implemented by reverse engineering the event-flow of the WindowServer, and so I don't actually know why it will not work for some applications.

Ref. https://github.com/koekeishiya/yabai/issues/333#issuecomment-565710628

pixmin commented 4 years ago

If that can help, I just noticed that PHPStorm also has the same issue.

pixmin commented 4 years ago

And Compass (MongoDB) https://www.mongodb.com/products/compass

svintit commented 4 years ago

To add here, this seems to be happening to me also, but with intellij IDEA, I think I can live with it though.

Thanks for this!

cormacrelf commented 4 years ago

Another way the Firefox window difference manifests itself is in yabai -m window --display X && yabai -m display --focus X. I'm not sure how related it is, but it's definitely Firefox specific so might help? Anyway:

If I use Safari/most standard windows, I can bounce a window between two displays (next; prev; next; prev) as many times as I like. With Firefox, windows get 'stuck' on a display after a few bounces, i.e. the window moving commands seem to fail. Here's an example I can reproduce on macOS 10.14.6, two displays, yabai is homebrew/2.4.1 but also happens on 2.3.0.

  1. nextfocus ✅ (now on display 2)
  2. prevfocus ✅ (now on display 1)
  3. nextfocus ✅ (now on display 2)
  4. prev ❌ (still on display 2)
  5. prev ❌ (still on display 2)
  6. ...

To get it unstuck, you can click on the window, and normal functionality resumes. The window is never unfocused, and the click doesn't refocus it, it just seems to get yabai back in sync. I can get the "n = number of times it works = 1" if the window in question is the only window open on the machine. I.E.

  1. nextfocus ✅ (now on display 2)
  2. prev ❌ (still on display 2)
  3. prev ❌ (still on display 2)
  4. ...

Click on the window, and it will work again.

koekeishiya commented 4 years ago

From #333

there is one application that is refusing to focus but not raise, it's called yEd:

guy-dude commented 4 years ago

Add Simulator to the list.

lucian303 commented 3 years ago

Maybe it's related to some cross-platform app tech stack? The ones I see that this happens with are Intellij IDEA, PHPStorm, PyCharm (all Jetbrains IDEs which are java Swing apps and essentially, the same app) as well as Firefox and Blender, both of which use custom GUI toolkits. It could be Swing / other custom GUI toolkits not playing nice. On the other hand other cross platform apps seem fine like Audacity, Bitwig, Visual Studio Code, Slack, etc. Compass, mentioned above, seems to be an electron app that has issues though other electron apps seem ok (Slack, VSC) white yEd is also a cross-platform app. Not sure what the common thing they have is that's preventing autofocus from working though.

caduellery commented 3 years ago

Thunderbird (might use the same GUI toolkit as Firefox) is another app that always raise automatically :(

I've installed yabai just because of the "focus follow mouse autofocus" feature, but unfortunately can't keep using it since I'm a heavy user of Firefox and Thunderbird.

lesgrieve commented 3 years ago

Today's Visual Studio Code 1.57.0 update introduced this problem; focussing VSCode causes it to be raised to the front of the desktop. The workaround for that is to downgrade to 1.56.2. I thought this may be of interest since the version introducing the problem could be compared with the previous working version. I opened issue https://github.com/microsoft/vscode/issues/126044 and the response is that the developers plan to fix it in their next update.

berenddeboer commented 3 years ago

Yeah, the FireFox issue is really annoying. A big reason I'm only using it in a minor way on a Mac. On Linux it's my main development browser.

lesgrieve commented 3 years ago

I just discovered this Bugzilla https://bugzilla.mozilla.org/show_bug.cgi?id=1707379 Firefox raises window when it gains focus when using yabai with focus_follows_mouse with autofocus, but not autoraise

lesgrieve commented 2 years ago

In https://bugzilla.mozilla.org/show_bug.cgi?id=1707379, a patch has been provided for Firefox. Follow https://firefox-source-docs.mozilla.org/setup/macos_build.html to acquire source, apply the patch before .mach build step.

lesgrieve commented 2 years ago

Today's Firefox Nightly build 97.0a1 (2022-01-07) available on https://www.mozilla.org/en-CA/firefox/channel/desktop/ has this bug fixed. I plan to use this build until the fix is released in the stable version.

rickyelopez commented 1 year ago

I have this issue with Microsoft Teams (but only the main chat window, not the call in-progress ' window) and Mattermost. Maybe something to do with electron apps? Someone above mentioned vscode which I think is also an electron app?

caduellery commented 1 year ago

Having this issue with Microsoft Teams too, which is annoying, since I have to work with it all day.