Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unable to cycle through stacked window #1918

Closed
justintheyang opened this issue Oct 17, 2023 · 10 comments
Closed

Unable to cycle through stacked window #1918

justintheyang opened this issue Oct 17, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@justintheyang
Copy link

Hi all, I'm pretty new to MacOS and wanted to give this a try.

Currently running Sonoma 14.0 on a MacBook Pro (M2) with SIP disabled and

  • skhd-v0.3.9
  • yabai-v6.0.0
  • sketchybar-v2.17.1

I am able to make stacked windows using yabai -m window --stack north|west|south|east, however the problem is that when try to switch focus on a stacked window (yabai -m window --focus stack.next|prev) the newly focused window does not show up at the front of the screen.

When I do stack.next|prev I get the following log output:

EVENT_HANDLER_DAEMON_MESSAGE: window --focus stack.prev
EVENT_HANDLER_WINDOW_FOCUSED: Google Chrome 6248
event_signal_flush: transmitting window_focused to 1 subscriber(s)
EVENT_HANDLER_WINDOW_FOCUSED: Google Chrome 6248
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window stack.last

EVENT_HANDLER_DAEMON_MESSAGE: window --focus stack.next
EVENT_HANDLER_WINDOW_FOCUSED: Google Chrome 5325
event_signal_flush: transmitting window_focused to 1 subscriber(s)
EVENT_HANDLER_WINDOW_FOCUSED: Google Chrome 5325
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window stack.last

When I stack the entire space using yabai -m space --layout stack I am able to cycle through the stack properly using stack.next|prev giving the log output:

EVENT_HANDLER_DAEMON_MESSAGE: window --focus stack.prev
EVENT_HANDLER_APPLICATION_FRONT_SWITCHED: Google Chrome (699)
event_signal_flush: transmitting window_focused to 1 subscriber(s)
EVENT_HANDLER_APPLICATION_FRONT_SWITCHED: Google Chrome (699)
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window stack.last

EVENT_HANDLER_DAEMON_MESSAGE: window --focus stack.next
EVENT_HANDLER_APPLICATION_FRONT_SWITCHED: Code (709)
event_signal_flush: transmitting window_focused to 1 subscriber(s)
EVENT_HANDLER_APPLICATION_FRONT_SWITCHED: Code (709)
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window
EVENT_HANDLER_DAEMON_MESSAGE: query --windows --window stack.last
@justintheyang
Copy link
Author

Here is my skhdrc:

## Layouts ##
# Switch layout to float on space
shift + alt + ctrl - f : yabai -m space --layout float
# Switch layout to bsp on space
shift + alt + ctrl - b : yabai -m space --layout bsp
# Switch layout to stack on space
shift + alt + ctrl - s : yabai -m space --layout stack

## Desktops ##
# Space Navigation (four spaces per display): lalt - {1, 2, 3, 4}
lalt - 1 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[1] ]] && yabai -m space --focus $SPACES[1]
lalt - 2 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[2] ]] && yabai -m space --focus $SPACES[2]
lalt - 3 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[3] ]] && yabai -m space --focus $SPACES[3]
lalt - 4 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[4] ]] && yabai -m space --focus $SPACES[4]
lalt - 5 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[5] ]] && yabai -m space --focus $SPACES[5]

# Moving windows between spaces and follow: shift + lalt - {1, 2, 3, 4, p, n } (Assumes 4 Spaces Max per Display)
shift + lalt - 1 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[1] ]] \
                  && yabai -m window --space $SPACES[1] \
                  && yabai -m space --focus $SPACES[1] \
                  && sketchybar --trigger windows_on_spaces
shift + lalt - 2 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[2] ]] \
                  && yabai -m window --space $SPACES[2] \
                  && yabai -m space --focus $SPACES[2] \
                  && sketchybar --trigger windows_on_spaces
shift + lalt - 3 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[3] ]] \
                  && yabai -m window --space $SPACES[3] \
                  && yabai -m space --focus $SPACES[3] \
                  && sketchybar --trigger windows_on_spaces
shift + lalt - 4 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[4] ]] \
                  && yabai -m window --space $SPACES[4] \
                  && yabai -m space --focus $SPACES[4] \
                  && sketchybar --trigger windows_on_spaces
shift + lalt - 5 : SPACES=($(yabai -m query --displays --display | jq '.spaces[]')) && [[ -n $SPACES[5] ]] \
                  && yabai -m window --space $SPACES[5] \
                  && yabai -m space --focus $SPACES[5] \
                  && sketchybar --trigger windows_on_spaces

# create desktop, move window and follow focus - uses jq for parsing json (brew install jq)
shift + lalt - n : yabai -m space --create && \
                  index="$(yabai -m query --spaces --display | jq 'map(select(."is-native-fullscreen" == false))[-1].index')" && \
                  yabai -m window --space "${index}" && \
                  yabai -m space --focus "${index}"
# Destroy desktop.
shift + lalt - w : yabai -m space --destroy


## Windows ##
# focus window
alt - h : yabai -m window --focus west
alt - j : yabai -m window --focus south
alt - k : yabai -m window --focus north
alt - l : yabai -m window --focus east

# cycle focus window
shift + lalt - 0x1E : yabai -m window --focus next || yabai -m window --focus first
shift + lalt - 0x21 : yabai -m window --focus prev || yabai -m window --focus last

# swap managed window
shift + lalt - h : yabai -m window --swap west
shift + lalt - j : yabai -m window --swap south
shift + lalt - k : yabai -m window --swap north
shift + lalt - l : yabai -m window --swap east

# move managed window
shift + cmd - h : yabai -m window --warp west
shift + cmd - j : yabai -m window --warp south
shift + cmd - k : yabai -m window --warp north
shift + cmd - l : yabai -m window --warp east

# Balance size of windows.
shift + alt - 0 : yabai -m space --balance

# cycle through all windows, including floating ones, even when unfocused
alt - tab : [ $(yabai -m query --windows --space | jq -re "map(select(.\"has-focus\" == true)) | length != 0") = true ] && yabai -m window --focus "$(yabai -m query --windows --space | jq -re "[sort_by(.id, .frame) | reverse | .[] | select(.role == \"AXWindow\" and .subrole == \"AXStandardWindow\") | .id] | nth(index($(yabai -m query --windows --window | jq -re ".id")) - 1)")" ||  yabai -m window --focus "$(yabai -m query --spaces --space | jq -re ".windows[0]?")" &> /dev/null

# Resize windows
alt - 0x18: yabai -m window --resize left:-20:0 || yabai -m window --resize right:20:0 # increase horizontal size
alt - 0x1B: yabai -m window --resize left:20:0 || yabai -m window --resize right:-20:0 # decrease horizontal size
alt + shift - 0x18: yabai -m window --resize bottom:0:20 || yabai -m window --resize top:0:-20 # increase vertical size
alt + shift - 0x1B: yabai -m window --resize bottom:0:-20 || yabai -m window --resize top:0:20 # decrease vertical size

# toggle window zoom
lalt - d : yabai -m window --toggle zoom-parent; sketchybar --trigger window_focus
lalt - f : yabai -m window --toggle zoom-fullscreen; sketchybar --trigger window_focus


## Floating windows ##
# float / unfloat window and center on screen
alt - t : yabai -m window --toggle float --grid 4:4:1:1:2:2

# Make floating window fill screen.
shift + ctrl - up     : yabai -m window --grid 1:1:0:0:1:1

# Make floating window fill left-half of screen.
shift + ctrl - left   : yabai -m window --grid 1:2:0:0:1:1

# Make floating window fill right-half of screen.
shift + ctrl - right  : yabai -m window --grid 1:2:1:0:1:1

# move floating window
shift + ctrl - w : yabai -m window --move rel:0:-20
shift + ctrl - a : yabai -m window --move rel:-20:0
shift + ctrl - s : yabai -m window --move rel:0:20
shift + ctrl - d : yabai -m window --move rel:20:0


## Monitors ##
# focus monitor
cmd + alt - 1  : yabai -m display --focus 1
cmd + alt - 2  : yabai -m display --focus 2

# send window to monitor and follow focus
cmd + alt + shift - 1  : yabai -m window --display 1; yabai -m display --focus 1
cmd + alt + shift - 2  : yabai -m window --display 2; yabai -m display --focus 2


## Stacks ##
# stack window
rcmd + ralt - w : yabai -m window --stack north
rcmd + ralt - a : yabai -m window --stack west
rcmd + ralt - s : yabai -m window --stack south
rcmd + ralt - d : yabai -m window --stack east

# cycle through stacked window
rcmd + ralt - e : yabai -m window --focus stack.next #|| yabai -m window --focus stack.first
rcmd + ralt - q : yabai -m window --focus stack.prev #|| yabai -m window --focus stack.last

And yabairc:

#!/usr/bin/env sh

#
# for this to work you must configure sudo such that
# it will be able to run the command without password
#
# see this wiki page for information:
#  - https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)#configure-scripting-addition
#
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa

# from https://github.com/FelixKratz/dotfiles/tree/master
yabai -m signal --add event=window_focused action="sketchybar --trigger window_focus"
yabai -m signal --add event=window_created action="sketchybar --trigger windows_on_spaces"
yabai -m signal --add event=window_destroyed action="sketchybar --trigger windows_on_spaces"

# global settings
yabai -m config                                 \
    mouse_follows_focus          off            \
    focus_follows_mouse          off            \
    window_origin_display        default        \
    window_placement             second_child   \
    window_zoom_persist          on             \
    window_shadow                on             \
    window_opacity_duration      0.0            \
    active_window_opacity        1.0            \
    normal_window_opacity        0.90           \
    window_opacity               off            \
    insert_feedback_color        0xffd75f5f     \
    split_ratio                  0.50           \
    split_type                   auto           \
    auto_balance                 off            \
    top_padding                  6              \
    bottom_padding               12             \
    left_padding                 12             \
    right_padding                12             \
    window_gap                   08             \
    layout                       bsp            \
    mouse_modifier               fn             \
    mouse_action1                move           \
    mouse_action2                resize         \
    mouse_drop_action            swap           \
    window_border                on             \
    window_border_width          2              \
    active_window_border_color   0xffe1e3e4     \
    normal_window_border_color   0xff494d64     \
    insert_feedback_color        0xff9dd274
    # window_animation_duration    0.1            \
    # window_animation_frame_rate  120            \



yabai -m config external_bar all:$(sketchybar --query bar | jq .height):0

# yabai -m config window_topmost on
# yabai -m config window_opacity on
# yabai -m config active_window_opacity 1.0
# yabai -m config normal_window_opacity 0.9
yabai -m config debug_output on

echo "yabai configuration loaded.."

@kiryph
Copy link

kiryph commented Oct 18, 2023

I can confirm this issue on my system as well. It has worked for me in version yabai-v5.0.2. Possibly a regression introduced with the new possibility of swapping stacked windows.

see also issue: #1896

@shrimpram
Copy link

Can confirm this issue on an M1 MBP running yabai-v6.0.0; though this bug was not present in yabai-v5.0.9.

Using Cmd + Tab does not bypass this bug either. If window B is stacked below window A, and I use Cmd + Tab to change focus to B, yabai immediately snaps focus back to A.

@sergiornelas
Copy link

I'm facing the same issue.

@ZeChArtiahSaher
Copy link

OSX 13.5. Using prev and recent is much wonky

@kiryph
Copy link

kiryph commented Oct 26, 2023

I can confirm that commit 40d1075 fixes the issue.

Side Note: self-signed certificates expire within a year.
https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(from-HEAD)

@cauliyang
Copy link

cauliyang commented Oct 26, 2023

hi @kiryph, could you please share how to codesign with a self-signed certificate for the latest yabai, I checked the wiki https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(from-HEAD) and followed the instructions but got

libc++abi: terminating due to uncaught exception of type std::runtime_error: Only ad-hoc identities supported, requested: 'yabai-cert'
t.sh: line 1: 60487 Abort trap: 6           codesign -fs "${YABAI_CERT:-yabai-cert}" "$(brew --prefix yabai)/bin/yabai"

Thanks a lot!

@kiryph
Copy link

kiryph commented Oct 27, 2023

@cauliyang I actually followed only the wiki and do not have much more insight.
I have not encountered your error.

I have noticed a new issue with Yabai version 6/current head and AltTab for macOS. AltTab does not show any windows anymore. So I returned to version 5.0.9 which did not have this reported issue. If you do not need the new features of version 6, I would simply suggest that you revert your homebrew formula to version 5.0.9 and use it without the need for a self-signed certificate.

@cauliyang
Copy link

hi @kiryph, I do not use Altab to get all windows' information. Instead, I use https://github.com/AdamWagner/stackline/.

I will wait for the next release (I hope soon). thanks for your help!

@albertsj1
Copy link

@cauliyang I actually followed only the wiki and do not have much more insight. I have not encountered your error.

I have noticed a new issue with Yabai version 6/current head and AltTab for macOS. AltTab does not show any windows anymore.

I am currently using Yabi v6.0.0 and altTab v6.62.0 and have not experienced any issues.

@koekeishiya koekeishiya removed the addressed on master; not released Fixed upstream, but not yet released label Nov 12, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants