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

'display --focus' not working when windows stacked #1198

Closed
workcomplete opened this issue Mar 17, 2022 · 13 comments
Closed

'display --focus' not working when windows stacked #1198

workcomplete opened this issue Mar 17, 2022 · 13 comments

Comments

@workcomplete
Copy link

Hey really appreciate the updates - I have been having an nagging issue I was hoping would be resolved with this release but doesn't seem to be. I use the following config to move my focus between windows and monitors (displays):

shift + ctrl + alt + cmd - a : yabai -m window --focus west || yabai -m display --focus west
alt + shift - s : yabai -m window --focus south
shift + ctrl + alt + cmd - d : yabai -m window --focus east || yabai -m display --focus east
alt + shift - w : yabai -m window --focus north

This works fine when windows are not stacked. When windows are stacked, I am still able to move focus between windows, but when I try to switch focus between monitors I lose focus (ie. no window is in focus and the focus stays on the current monitor/display).

Hopefully this is a fixable issue with my config but I thought I would open here in case anyone is having the same issue.

Thanks!

@pierclgr
Copy link

I have a similar problem. I have an external display connected which is set to be the main display, so it is N.1 display in yabai. It happens that the command yabai -m display --focus only works when I'm focusing display 2, so the display of my MacBook, when I'm focusing display 1 (the external display) it doesn't work.
The same happens when I focus a space on the external display from a space in MacBook's display: it doesn't actually get focused because the menu bar is still darken and no window in the target space is focused.
Yesterday I reinstalled yabai and the problem went away, but now I have it again, don't know why.

@danymat
Copy link

danymat commented Mar 27, 2022

Hello, i have the same problem.
I use this skhd macro to toggle between stack and bsp mode:

hyper - z : yabai -m space --layout $(yabai -m query --spaces --space | jq -r 'if .type == "bsp" then "stack" else "bsp" end')

@diocletiann
Copy link

diocletiann commented Apr 16, 2022

I also have this issue, if the destination display of yabai -m display --focus has a stack, all focus goes away and you have to click on a window.

Edit: I've tried every combination I can think of and focusing across displays breaks focus every time.

@koekeishiya
Copy link
Owner

Hm I am unable to reproduce this using yabai v4.0.0 on macOS 12.3.1 (Apple Silicon).

I have tested using bsp layout with stacked nodes on the destination display, and the window is focused correctly.
I also tested using the stack layout on the destination display, and the window is focused correctly.

The above tests worked using both yabai -m display --focus next and yabai -m display --focus 2.

Is this happening with specific applications? Are you running Hammerspoon or other accessibility software that could interfere in some way?

@diocletiann
Copy link

I just quit Hammerspoon, which I was using only for Stackline, and focus now works correctly. My focus command is yabai -m window --focus west || yabai -m display --focus west.

@koekeishiya
Copy link
Owner

I think this is a problem with Stackline, the Hammerspoon window "steals" focus for whatever reason. What yabai is doing is simply sending focus to the window that macOS says is the "front-most" window on the destination display.

I'd like to make something like Stackline built-in to yabai itself in the future. There are tons of things that can be improved regarding the stack-system.

@diocletiann
Copy link

diocletiann commented Apr 18, 2022

It's a shame because the workflow with these commands was getting really good:

ctrl - left : yabai -m window --focus west || \
              yabai -m display --focus west

ctrl - right: yabai -m window --focus east || \
              yabai -m display --focus east

ctrl - down : yabai -m window --focus south || \
              yabai -m window --focus stack.next || \
              yabai -m window --focus stack.first

ctrl - up : yabai -m window --focus north || \
            yabai -m window --focus stack.prev || \
            yabai -m window --focus stack.last

@koekeishiya
Copy link
Owner

koekeishiya commented Apr 18, 2022

I believe this is the relevant issue: AdamWagner/stackline#67

A possible workaround that would let you keep Stackline running could be the following:

Instead of yabai -m focus --display west, you could run yabai -m query --spaces --display west and select the one with is-visible true (using jq), then run a yabai -m window --focus <id> command on the first window listed in the windows array.

Docs for query output: https://github.com/koekeishiya/yabai/blob/master/doc/yabai.asciidoc#query

@diocletiann
Copy link

diocletiann commented Apr 18, 2022

I got it working, thank you!!

ctrl - left : yabai -m window --focus west || \
              yabai -m window --focus $(yabai -m query --spaces --display west | jq '.[] | select(."is-visible" == true) | ."last-window"')

ctrl - right: yabai -m window --focus east || \
              yabai -m window --focus $(yabai -m query --spaces --display east | jq '.[] | select(."is-visible" == true) | ."first-window"')

@diocletiann
Copy link

diocletiann commented Apr 18, 2022

I can also stack across displays now:

meh - left  : yabai -m window west --stack $(yabai -m query --windows --window | jq -r '.id') || \
              yabai -m window $(yabai -m query --spaces --display west | jq '.[] | select(."is-visible" == true) | ."last-window"') --stack $(yabai -m query --windows --window | jq -r '.id')
meh - right : yabai -m window east --stack $(yabai -m query --windows --window | jq -r '.id') || \
              yabai -m window $(yabai -m query --spaces --display east | jq '.[] | select(."is-visible" == true) | ."first-window"') --stack $(yabai -m query --windows --window | jq -r '.id')
meh - up    : yabai -m window north --stack $(yabai -m query --windows --window | jq -r '.id')
meh - down  : yabai -m window south --stack $(yabai -m query --windows --window | jq -r '.id')

@koekeishiya
Copy link
Owner

Closing this as there isn't really anything yabai can do about this, use the workaround mentioned above if Stackline is unable to fix the issue on their end.

@pierclgr
Copy link

pierclgr commented Apr 26, 2022

I don't have stackline and hammerspoon, I had them in the past but now I removed them, however I still have the same issue. I noticed that if I reinstall yabai or force the update, it works for the first like 5 minutes, then it starts giving the same problem again.

@dmitrym0
Copy link

dmitrym0 commented Apr 9, 2024

Having the same problem where switching to a desktop doesn't focus any windows. With or without Hammerspoon. I have never used stack line.

Any advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants