koekeishiya / yabai

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

Issue with assigned space rule in Yabai #965

Closed jaideeprana closed 6 months ago

jaideeprana commented 3 years ago

Hi, in my case I have assigned Intellij to space 4 via the config yabai -m rule --add app="IntelliJ IDEA" space=4.

It works fine but when I move it to a different space let's say to space 5 and any pop window gets opened, then Yabai starts behaving weird. In my case when I open system preference when it's on space 5, Yabai keeps on toggling between space 4 and 5.

Any idea how I can fix this?

Attaching a video for the same so that it's easier to relate. Let me know if more info is needed from my end.

https://user-images.githubusercontent.com/3875065/126457550-72fe8353-4aa9-4c38-b222-76e4facd10cb.mov

koekeishiya commented 3 years ago

This seems weird. I can't really tell right now why exactly yabai would make that happen.

Just to confirm, have you disabled the following mission-control setting?

In the Mission Control preferences pane in System Preferences, the setting "Automatically rearrange Spaces based on most recent use" should be disabled for commands that rely on the ordering of spaces to work reliably.

jaideeprana commented 3 years ago

Yes I have it disabled.

Following is a screenshot with all of my Mission Control settings:

Screenshot 2021-07-29 at 10 34 33 AM
jaideeprana commented 3 years ago

Sharing my yabairc as well in case it helps:

!/usr/bin/env zsh
sudo yabai --load-sa
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"

alias yc='yabai -m config'
alias yr='yabai -m rule --add'

# global settings
yabai -m config mouse_follows_focus          off
yabai -m config focus_follows_mouse          off
yabai -m config window_placement             second_child
yabai -m config window_topmost               off
yabai -m config window_shadow                off
yabai -m config window_opacity               on
# yabai -m config window_opacity_duration      0.0
# yabai -m config active_window_opacity        1.0
yabai -m config active_window_opacity        1.0
# yabai -m config normal_window_opacity        0.90
yabai -m config normal_window_opacity        0.90
# yabai -m config normal_window_opacity        1
# yabai -m config window_border                on
yabai -m config window_border                off
# yabai -m config window_border_width          6
yabai -m config window_border_width          3
# yabai -m config active_window_border_color   0xff9d0006

# yabai -m config active_window_border_color   0xfffb4934 # bright red
# yabai -m config active_window_border_color   0xffcc241d # neutral red
yabai -m config active_window_border_color   0xffa89984 # neutral red

# yabai -m config active_window_border_color   0xff9d0006 # faded red
# yabai -m config active_window_border_color   0xff775759 # default
yabai -m config normal_window_border_color   0xff555555
yabai -m config insert_feedback_color        0xffd75f5f
yabai -m config split_ratio                  0.50
yabai -m config auto_balance                 off
yabai -m config mouse_modifier               fn
yabai -m config mouse_action1                move
yabai -m config mouse_action2                resize

# general space settings
yabai -m config layout                       bsp
yabai -m config top_padding                  4
yabai -m config bottom_padding               20
yabai -m config left_padding                 5
yabai -m config right_padding                5
yabai -m config window_gap                   5

# Space labels
yabai -m space 1 --label "Notes"
yabai -m space 2 --label "Terminal"
yabai -m space 3 --label "Browser"
yabai -m space 4 --label "Editor"
yabai -m space 8 --label "Comms"
yabai -m space 8 --label "Chat"

# Primary
# yabai -m rule --add app="Brave Browser"       space=3
yabai -m rule --add app="kitty"                 space=2
yabai -m rule --add app="Obsidian"              space=1
yabai -m rule --add app="IntelliJ IDEA"         space=4
yabai -m rule --add app="zoom"                  space=5
yabai -m rule --add app="Anki"                  space=10

# Communication
yabai -m rule --add app="Microsoft Teams"       space=9
yabai -m rule --add app="Calendar"              space=8
yabai -m rule --add app="Mail"                  space=8
yabai -m rule --add app="WhatsApp"              space=11
yabai -m rule --add app="IINA"                  space=12

# yabai rules
# yr title='^Preferences' manage=off layer=above
yr title='^(Opening)' manage=off layer=above
yr title='Library' manage=off layer=above
yr app='App Store' manage=off layer=above
yr app='Numi' manage=off layer=above
yr app='Keka' manage=off layer=above
yr app='Contexts' manage=off layer=above
yr app='Deepl*' manage=off layer=above
yr app='ProtonVPN' manage=off layer=above
yr app='ExpressVPN' manage=off layer=above
yr app='nordVPN' manage=off layer=above

#yr app='Firefox' space=1
#yr app='Safari' space=1
yr app='Dofus'   space=2
yr app='Discord' space=5
yr app='Spotify' space=6

# yabai signals
yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"
yabai -m signal --add event=application_terminated action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"
yabai -m signal --add event=space_changed action="landscape"

yabai -m rule --add title="Microsoft Teams Notification" window_border=off
yabai -m rule --add title="Microsoft Teams Notification" manage=off

# float system preferences
# yabai -m rule --add app="^System Preferences$" manage=off layer=above

# show digital colour meter topmost and on all spaces
yabai -m rule --add app="^Digital Colou?r Meter$" sticky=on

# set focus follows mouse mode (default: off, options: off, autoraise, autofocus)
yabai -m config focus_follows_mouse autoraise

# set mouse interaction modifier key (default: fn)
yabai -m config mouse_modifier fn

# set modifier + left-click drag to resize window (default: move)
yabai -m config mouse_action1 move

# set modifier + right-click drag to resize window (default: resize)
yabai -m config mouse_action2 resize

# set mouse follows focus mode (default: off)
yabai -m config mouse_follows_focus on

# yabai -m config external_bar all:26:0
echo "yabai configuration loaded.."
jaideeprana commented 3 years ago

@koekeishiya Is there anything I can do to debug this from my end? Or share any logs for the same?

koekeishiya commented 3 years ago

So it appears to me that this is what's happening:

IntelliJ is launched (for the first time) and yabai moves it to space 4. Later on at some point you move it to space 5. When a popup-window is created, yabai moves it to space 4. Because this is a popup, macOS follows the focus (or something, as yabai is not making space 4 focused here). The popup is automatically closed because IntelliJ is no longer the active application/on the active space, and when the popup closes, IntelliJ receives focus again, making the switch to space 5.

Am I understanding the issue correctly?

If so I believe the fix is to adjust your rule such that popup windows (and everything that is not the main editor window) is unaffected by the rule.

If you can try to retrieve the output of running yabai -m query --windows while IntelliJ and some of the popup-windows are visible, while on space 4, the information might give you some tips as how to adjust your rule. you can probably do this by having a terminal session and doing a sleep 2 && yabai -m query --windows. While the sleep is executing, you tab into intelliJ and trigger a popup.

koekeishiya commented 6 months ago

Changes have been made to newest releases of yabai that should have resolved this issue.