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

Yabai lose control of window if I close the window and reopen it #2552

Open
quarkquartet opened this issue Feb 15, 2025 · 9 comments
Open

Yabai lose control of window if I close the window and reopen it #2552

quarkquartet opened this issue Feb 15, 2025 · 9 comments

Comments

@quarkquartet
Copy link

quarkquartet commented Feb 15, 2025

I'm not sure whether it's a bug or I'm using it in a wrong way. I found Yabai lose control of the app window if I close and reopen it. Close means just close the window but does not quit the app.

For example, if I have a app window, say, slack, opening.

I can use all the yabai commands to deal with it. I can toggle fullscreen, toggle float, and so forth.

Then I close slack window (but do not quit the app) and reopen it. Then yabai completely lose control of it. I cannot toggle float, toggle fullscreen, or do anything.

I run yabai -m query window to see the difference.

I found the can move, can resize becomes false after I reopen the window.

Why?

System: MacOS 15.2.
Yabai version: 7.1.8.

Output of csrutil status:

System Integrity Protection status: unknown (Custom Configuration).

Configuration:
	Apple Internal: disabled
	Kext Signing: enabled
	Filesystem Protections: disabled
	Debugging Restrictions: disabled
	DTrace Restrictions: enabled
	NVRAM Protections: disabled
	BaseSystem Verification: enabled
	Boot-arg Restrictions: disabled
	Kernel Integrity Protections: enabled
	Authenticated Root Requirement: enabled

This is an unsupported configuration, likely to break in the future and leave your machine in an unknown state.

My config:

#!/usr/bin/env sh

sudo /opt/Homebrew/bin/yabai --load-sa
yabai -m signal --add event=dock_did_restart action="sudo /opt/Homebrew/bin/yabai --load-sa"

# global settings
yabai -m rule --add app=".*" sub-layer=normal

yabai -m space 1 --label browser
yabai -m space 2 --label finder
yabai -m space 3 --label coding
yabai -m space 4 --label draft
yabai -m space 5 --label coding2
yabai -m space 6 --label coding3
yabai -m space 7 --label coding4
yabai -m space 8 --label video
yabai -m space 9 --label backup
yabai -m space 10 --label terminal
yabai -m space 11 --label management
yabai -m space 12 --label chat
yabai -m space 13 --label paper
yabai -m space 14 --label entertain
yabai -m space 15 --label present
yabai -m space 16 --label zoom
# yabai -m config external_bar all:40:0
# yabai -m config mouse_follows_focus on
# yabai -m config focus_follows_mouse off
# yabai -m config window_origin_display default
# yabai -m config window_placement second_child
# yabai -m config window_topmost on
# yabai -m config window_shadow on
# yabai -m config window_opacity off
# yabai -m config window_opacity_duration 2000.0
# yabai -m config active_window_opacity 1.0
# yabai -m config normal_window_opacity 0.85
# yabai -m config window_border off
# yabai -m config window_border_width 6
# yabai -m config active_window_border_color 0xff775759
# 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
# yabai -m config mouse_drop_action swap
# yabai -m config menubar_opacity 0.9
yabai -m config focus_space on
yabai -m config auto_balance on
# general space settings
yabai -m config top_padding 4
yabai -m config bottom_padding 8
yabai -m config left_padding 8
yabai -m config right_padding 8
yabai -m config window_gap 10

yabai -m config layout bsp

# Per-app settings
yabai -m rule --add app="^System Settings*" manage=off

## Coding
yabai -m rule --add app="^iTerm2*" manage=off space=^terminal
yabai -m rule --add app="^Code*" space=^coding sub-layer=normal
yabai -m rule --add app="^Mathematica" space=^coding

## Overleaf
yabai -m config --space draft top_padding 0
yabai -m config --space draft bottom_padding 0
yabai -m config --space draft left_padding 0
yabai -m config --space draft right_padding 0
yabai -m config --space draft window_gap 0
yabai -m rule --add app="^Overleaf*" space=^draft
yabai -m config --space draft layout stack

## Chats
yabai -m config --space chat layout float
yabai -m rule --add app="^WeChat*" manage=off space=^chat
yabai -m rule --add app="^Discord*" manage=off space=^chat
yabai -m rule --add app="^Telegram*" manage=off space=^chat
yabai -m rule --add app="WhatsApp*" manage=off space=^chat
yabai -m rule --add app="^Messages*" manage=off space=^chat
yabai -m rule --add app="^Messenger*" manage=off space=^chat
yabai -m rule --add app="^Slack*" manage=off space=^chat
yabai -m rule --add app="^Skype*" manage=off space=^chat
yabai -m rule --add app="^Spark*" manage=off space=^chat
yabai -m rule --add app="^QQ" manage=off space=^chat

## Browser
yabai -m config --space browser top_padding 0
yabai -m config --space browser bottom_padding 0
yabai -m config --space browser left_padding 0
yabai -m config --space browser right_padding 0
yabai -m config --space browser window_gap 0

yabai -m rule --add app="^Firefox*" space=^browser
yabai -m rule --add app="^Safari*" space=^browser
# yabai -m config --space 1 layout stack

## Finder
yabai -m rule --add app="^Finder*" space=^finder
yabai -m config --space finder layout stack

## Entertain
yabai -m rule --add app="^Chrome$" space=^8
yabai -m config --space video layout stack

yabai -m config --space entertain layout float
# yabai -m config --space entertain top_padding 70
# yabai -m config --space entertain bottom_padding 100
# yabai -m config --space entertain left_padding 100
# yabai -m config --space entertain right_padding 100

yabai -m rule --add app="^NetEaseMusic*$" space=^entertain manage=off
yabai -m rule --add app="^QQ音乐*$" space=^entertain manage=off
yabai -m rule --add app="^Books*$" space=^entertain manage=off

## Management
yabai -m rule --add app="^Obsidian$" space=^management
yabai -m rule --add app="^Calendar*" space=^management
yabai -m rule --add app="^Reminders*" space=^management

## Paper
yabai -m config --space paper layout stack
yabai -m config --space paper top_padding 0
yabai -m config --space paper bottom_padding 0
yabai -m config --space paper left_padding 0
yabai -m config --space paper right_padding 0
yabai -m config --space paper window_gap 0
yabai -m rule --add app="^PDF Expert*$" space=^paper
yabai -m rule --add app="^Zotero*" space=^paper

## Presentation
yabai -m config --space present layout stack
yabai -m rule --add app="^Microsoft Word*$" space=^present
yabai -m rule --add app="^Microsoft PowerPoint*$" space=^present
yabai -m rule --add app="^Keynote*$" space=^present

## Zoom
yabai -m rule --add app="^zoom.us$" space=^zoom manage=off
yabai -m rule --add app="^VooV$" space=^zoom manage=off

## Other apps
yabai -m rule --add app="^Contacts" manage=off
yabai -m rule --add app="^BaiduNetdisk" manage=off
# Automations
yabai -m signal --add event=window_focused action="sketchybar --trigger window_focus"
yabai -m signal --add event=window_title_changed action="sketchybar --trigger title_change"

# Window focus preferences

## focus window after active space changes
yabai -m signal --add event=space_changed action="yabai -m window --focus \$(yabai -m query --windows --space | jq .[0].id)"

## focus window after active display changes
yabai -m signal --add event=display_changed action="yabai -m window --focus \$(yabai -m query --windows --space | jq .[0].id)"

## focus previous window when window destroyed
# yabai -m signal --add event=window_destroyed action="yabai -m window --focus recent"

borders active_color=0xff537eec inactive_color=0x00ffffff width=7.0 &
# borders active_color=0xff416cc3 inactive_color=0x00ffffff width=7.0 &

echo "yabai configuration loaded.."
@koekeishiya
Copy link
Owner

Try to upgrade to v7.1.10

@quarkquartet
Copy link
Author

Just tried. But still the same result.

@Bellavene
Copy link

Just tried. But still the same result.

If you think you've updated through brew, check yabai -v.
As for now you can install 7.1.10 by compiling.

@quarkquartet
Copy link
Author

Just tried. But still the same result.

If you think you've updated through brew, check yabai -v. As for now you can install 7.1.10 by compiling.

Yeah I updated through brew.

Image

@Bellavene
Copy link

Ah ok, didn't for me yesterday

@quarkquartet
Copy link
Author

Try to upgrade to v7.1.10

Sorry for mentioning again. Just want to make sure I understand it: is 7.1.10 expected to solve this problem when it was released? For me it's just 'I'm using 7.1.10 now but the problem persists.'

@quarkquartet
Copy link
Author

quarkquartet commented Feb 21, 2025

More test:

When slack is started, I get the following information.

{
  "id": 11562,
  "pid": 1260,
  "app": "Slack",
  "title": "Slack",
  "scratchpad": "",
  "frame": {
    "x": 311,
    "y": 113,
    "w": 1123,
    "h": 879
  },
  "role": "AXWindow",
  "subrole": "AXStandardWindow",
  "root-window": true,
  "display": 1,
  "space": 12,
  "level": 0,
  "sub-level": 0,
  "layer": "normal",
  "sub-layer": "normal",
  "opacity": 1,
  "split-type": "none",
  "split-child": "none",
  "stack-index": 0,
  "can-move": true,
  "can-resize": true,
  "has-focus": false,
  "has-shadow": true,
  "has-parent-zoom": false,
  "has-fullscreen-zoom": false,
  "has-ax-reference": true,
  "is-native-fullscreen": false,
  "is-visible": false,
  "is-minimized": false,
  "is-hidden": false,
  "is-floating": true,
  "is-sticky": false,
  "is-grabbed": false
}

When I close and reopen the window, I found the following:

{
  "id": 11562,
  "pid": 1260,
  "app": "Slack",
  "title": "",
  "scratchpad": "",
  "frame": {
    "x": 311,
    "y": 113,
    "w": 1123,
    "h": 879
  },
  "role": "",
  "subrole": "",
  "root-window": true,
  "display": 1,
  "space": 12,
  "level": 0,
  "sub-level": 0,
  "layer": "normal",
  "sub-layer": "normal",
  "opacity": 1,
  "split-type": "none",
  "split-child": "none",
  "stack-index": 0,
  "can-move": false,
  "can-resize": false,
  "has-focus": false,
  "has-shadow": true,
  "has-parent-zoom": false,
  "has-fullscreen-zoom": false,
  "has-ax-reference": true,
  "is-native-fullscreen": false,
  "is-visible": false,
  "is-minimized": false,
  "is-hidden": false,
  "is-floating": true,
  "is-sticky": false,
  "is-grabbed": false
}

Note: the 'is-native-fullscreen' is always false after reopening, even if I manually put it into native full screen.

It seems some apps are using different mechanism to 'close' the window in a way that Yabai does not regard this window as closed, but something else.

I should emphasize that this issue only appears in some apps.

@Bellavene
Copy link

Bellavene commented Feb 21, 2025

All programs that I use are working as expected. So I believe you should ask Slack to address this issue. Maybe I am wrong, but it seems that Slack does not distribute system-wide messages of the window roles/states when creating a window while already running. Åsmund will correct me, if I am wrong. Take a look at this issue, looks familiar

@quarkquartet
Copy link
Author

Yeah I redo some tests for many apps. I found that this happens only on a few apps, like slack, telegram, and some music apps. But for most apps this issue does not happen.

So maybe these apps are using some different window destroy mechanisms and breaks how yabai works.

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

3 participants