-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
Focusing on space does not focus on window in that space #160
Comments
The underlying issue is that focusing a space focuses the most recently focused window on that space, and that obviously does not exist for a newly created space. If you want to follow a window, you can use this keybinding instead, which focuses the moved window instead of the newly created space. shift + cmd - n : yabai -m space --create \
&& wid="$(yabai -m query --windows --window | jq -r '.id')" \
&& sidx="$(yabai -m query --spaces --display | jq -r 'map(select(."native-fullscreen" == 0))[-1].index')" \
&& yabai -m window "${wid}" --space "${sidx}" \
&& yabai -m window --focus "${wid}" Another, more general fix is to always try to focus the window under the cursor after switching a space or destroying a window, but only if no window is focused. #! /usr/bin/env sh
# save this as a file somewhere, then run:
# chmod +x path/to/this/script
# now execute this file from your yabairc:
# ./path/to/this/script
if [ $# -ne 0 ]; then
for event in window_destroyed space_changed; do
yabai -m signal --add label="${0}_${event}" \
event="${event}" action="${0}"
done
exit
fi
{
yabai -m query --windows --window \
|| yabai -m window --focus mouse
} > /dev/null 2>&1 |
Thanks for the reply. Although the alternate keybinding for
where s2 was created using
what actually happens is that w1 in s1 is retaining focus i.e. even though I am on s2 now,
may not work as expected, since there is a window focused, only problem is that its in the wrong space i.e. w1 on s1. Essentially, I would like for the keybind |
@amanjitsk I updated the below post with a more detailed reply. In the script, instead of # 1. grab all windows on the current space
# 2. filter for focused windows
# 3. if the length of the array returned by step 2 is 0, focus the window under the cursor
yabai -m query --windows --space | jq -er 'map(select(.focused == 1)) | length > 0' \
|| yabai -m window --focus mouse This could additionally be improved by trying to focus any window on that space by id if this fails.
You need to save the window id of the window then and have your keybind focus it. After all, you're looking to focus a specific window instead of a specific space. This can be implemented, but it's not trivial. This is also what the updated move window to space and follow along command does, but it's quite a bit harder to implement when you want this across multiple keybindings. Side note: The way you're grabbing the index of the created space is wrong.
A new space is created after the last existing non-fullscreen space on the current display. What you're doing (I know, it's the sample binds... that's for another day) is grabbing the last space on the current display. This is how you correctly get the index: index="$(yabai -m query --spaces --display | jq -r 'map(select(."native-fullscreen" == 0))[-1].index')" |
Thanks for the side note; I have fixed that in my For now, I guess I could augment the bind for
I do agree that this is not elegant for multiple keybindings. Also, maybe this I can open another issue for this, but is there a way to replicate i3-like space numbering, so for ex. having a space 1 and space 3 present, without a space 2. From what I have understood so far, there is no way for me to create a space 3 (named 3 that is) without having to create a space named "space 2" (so that would be 3 spaces instead of 2). Or also things like renaming space 1 to space 5, whilst only having one actual space. Simply speaking, a space-renumbering functionality! |
Note that the code snippet you posted only returns true of there are no focused windows on the current space. It does not actually focus anything. You'd still have to use The keybinding you presented for shift+alt-2 is not reliable in any way sadly.
You can create files that associate space ids (not the indices!) with tags to do this, then grab the space id from the tag and then grab the space index from the space id. Or just wait for #119 of some sort, which will make this easier. This is not a simple thing to implement. |
Right, I had the |
I launch two windows in the current space and then move one of them into a new space using the following keybind
or alternatively, creating a desktop first using
and then moving the window to the newly created space. The weird thing that I notice is that focusing on the newer space does not the focus on the window in that space. So if now switch between spaces using
I find that the window in space 1 is correctly focused on using the above keybind, but when I focus on space 2, it does not focus on the window there.
This issue is however resolved when mission control is activated i.e. It focuses on the window in space 2 only once mission control has been activated (using the 4-finger swap to switch spaces), but not solely using the yabai space keybindings. Is this an expected issue or am I experiencing/doing something silly ?
I am on MacOS 10.14.6 and have disabled SIP and also followed every item in mentioned here
The text was updated successfully, but these errors were encountered: