yabai
yabai copied to clipboard
Can not focus empty space on different display
Hi, I have two displays and when I trying to focus empty space on another display using any of command:
yabai -m display --focus prev
yabai -m display --focus last
yabai -m display --focus next
yabai -m display --focus first
yabai -m space --focus SPACE_SEL
that does not always work. Sometimes it keeps focus on existing display, but losing focus from current window
I noticed the same problem when I have windows for the same app on multiple screens.
Say I have two chrome windows on two screen respectively, if my focus is initially on the chrome window on screen 1, and use yabai command to switch to the a empty space on screen 1. The focus will jump to the chrome window on screen 2, instead of the empty space I just switched.
@albert-ying I noticed a similar issue with Firefox. Let's say I use 2 screens, the internal Macbook screen and one external display. Each screen has 4 spaces assigned and I have a window of the same Firefox profile running on Space 3 - Display 1
and Space 6 - Display 2
. On Display 1, Space 3 is currently selected but I am working on Space 7 on the Display 2. From there executing yabai -m space --focus prev
results in switching to Space 6 - Display 2
, however the focus goes to Space 3 - Display 1
, where another instance of the firefox is running.
Hm I don't think this is something that is fixable. Tested using Terminal.app and Safari.app and I cannot reproduce the issue. I assume that Firefox and Chrome is doing something weird that overrides whatever it is yabai and thus macOS is trying to do in this case.
@koekeishiya Hmm, I can replicate using Terminal.app.
Minimal steps:
- Start with 3 empty spaces (S1, S2, S3), 2 displays (D1, D2), where S1 is in D1 and S2, S3 are in D2.
- Open 2 terminal windows (t1, t2), one in S1 and one in S2
- Focus on t2
- Now use the shortcut to focus on S3 (which is empty) You will notice that your focus is now on t1, instead of S3
I tried these exact steps, but I end up on S3 as expected with Finder as the focused application.
If you run with SIP disabled, could you build from source (toggle this ifdef): https://github.com/koekeishiya/yabai/blob/master/src/window_manager.c#L874
I am curious to see if this is just some macOS quirk or if it has something to do with the way that yabai focuses windows. In either case, your steps above are not enough to reliably reproduce the issue on other systems, unfortunately.
with Finder as the focused application
Hmm interesting, I didn't know what window I was focused on when focusing on an empty space.
And I just tested it, seems that when I focus on an empty space, I actually still focus on an invisible window of whichever application I focused on before. (I know it by using cmd + N
shortcut after focusing on empty space, and it creates a new window of whichever app I focused before)
@albert-ying @hschaeidt do you guys also still run into this bug all the time? (I still see it with yabai v6.0.0.)
Also, do you guys have your external monitor set as your main display under display settings? And does the bug only occur for you if you run the space focusing commands on your laptop monitor? Both of those hold for me. Switching my laptop to be the main display (under System Settings > Displays > Use as) avoided the bug for a few tests at least.
(Even if switching the main display does avoid the bug, I think it wouldn't be a good workaround. For example, Desktops (Spaces) are numbered starting at one on the main display, so the built-in keyboard shortcuts for switching to Desktops 1-9 would be less useful. It's also not easy to test drive since it swaps all windows on the two monitors by swapping the existing Desktops, and I have a crazy amount of windows open. Does someone else want to test drive it?)