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

Unable to Move Windows Between Spaces #2484

Open
creese opened this issue Nov 28, 2024 · 9 comments
Open

Unable to Move Windows Between Spaces #2484

creese opened this issue Nov 28, 2024 · 9 comments

Comments

@creese
Copy link

creese commented Nov 28, 2024

The problem started after upgrading to Sequoia.

@odi89
Copy link

odi89 commented Dec 2, 2024

@creese

Seems to be a issue with current version
I got stuck after updating to
yabai-v7.1.5
I have been on Sequoia for while now=)
Cheers from norway

Edit:
If i downgrade to yabai-v7.1.2 then it works like a charm again=)

Mac Os
Versjon 15.1.1 (24B91)

@tiagojsag
Copy link

tried 7.1.2, no luck

From other issues previously reported, moving windows is supported in Sequoia if you enable SA. Unfortunately that's not an option for me, company laptop :(

@berkmonder
Copy link

tried 7.1.2, no luck

From other issues previously reported, moving windows is supported in Sequoia if you enable SA. Unfortunately that's not an option for me, company laptop :(

Same for me. Are there any workarounds?

@egbaydarov
Copy link

egbaydarov commented Dec 6, 2024

I have the same issue after upgrading to Sequoia. I’ve noticed that moving windows works between spaces that are currently visible on a multi-monitor setup (no SA setup).

For example, I have two monitors, and they are currently displaying spaces 1, 3. In this case, I can move windows between spaces using the following command:

yabai -m window --space <1, 3>

However, when a space is not visible, some issues occur.

Setup:

  • Space 10 (two Warp windows)
  • Space 3 (Sublime Text window + Warp window)
  • Space 1 (some other windows)

Currently, displays 3 and 10 are visible on two monitors.

yabai --verbose

Case 1: Moving a Warp window from a visible space on a display to another visible space:

yabai -m window --space 10;

EVENT_HANDLER_WINDOW_TITLE_CHANGED: Warp 78909
EVENT_HANDLER_DAEMON_MESSAGE: window --space 10
EVENT_HANDLER_APPLICATION_FRONT_SWITCHED: Sublime Text (513)
EVENT_HANDLER_SLS_WINDOW_ORDERED: 94
EVENT_HANDLER_WINDOW_RESIZED: Sublime Text 94
EVENT_HANDLER_WINDOW_RESIZED: Warp 99
EVENT_HANDLER_WINDOW_RESIZED: Warp 78909
EVENT_HANDLER_WINDOW_MOVED: DEBOUNCED Warp 78909
EVENT_HANDLER_WINDOW_TITLE_CHANGED: Warp 78909

Case 2: Moving a Warp window from a visible space on a display to an invisible space:

yabai -m window --space 1;

EVENT_HANDLER_WINDOW_TITLE_CHANGED: Warp 78909
EVENT_HANDLER_DAEMON_MESSAGE: window --space 1
EVENT_HANDLER_APPLICATION_FRONT_SWITCHED: Sublime Text (513)
EVENT_HANDLER_WINDOW_FOCUSED: Sublime Text 94
EVENT_HANDLER_SLS_WINDOW_ORDERED: 94
EVENT_HANDLER_WINDOW_RESIZED: Sublime Text 94
EVENT_HANDLER_WINDOW_TITLE_CHANGED: Warp 78909

Seems like

EVENT_HANDLER_WINDOW_FOCUSED: Sublime Text 94

brakes a behavior. Sublime Text is a first window in the display I was moving from. If display contains a no windows (only one which is moving) then focus will be on Finder (desktop).

Might be some patches around #2240 (comment) and

void space_manager_move_window_to_space(uint64_t sid, struct window *window)
happened.

@koekeishiya
Copy link
Owner

You need to use the latest version of yabai and disable SIP as described in the wiki, for moving windows to other spaces to work in Sequoia. Apple added protection to the API - there is no workaround.

@grugnog
Copy link

grugnog commented Dec 13, 2024

Edit: including a pair of scripts that can move windows between spaces when you have multiple displays. This works by temporarily moving the window to a non-focused display, then switching spaces (using keyboard shortcuts) and moving it to the right space. In a hacky state, but could help someone else get day-to-day window shuffling less painful.

space-switch: This uses applescript to send keystrokes and switch spaces using a configured shortcut (option and a number in my case - you will need to adapt to your own shortcuts):

#!/usr/bin/env osascript
on run argv
    if (count of argv) < 1 then
        error "No argument provided. Please provide a space number."
    end if

    set spaceNumber to item 1 of argv as number
    if spaceNumber is greater than 10 or spaceNumber is less than 1 then
        error "Invalid space number. Please provide a number between 1 and 10."
    end if

    -- Calculate the appropriate key code
    set keyCodes to {18, 19, 20, 21, 23, 22, 26, 28, 25, 29} -- Key codes for numbers 0-9
    set keyCode to item (spaceNumber) of keyCodes

    tell application "System Events"
        key code keyCode using option down
    end tell
end run

move-window: Move windows to another space by (if needed/possible) juggling then to another display. If you only have a single display available this will not work.

#!/usr/bin/env bash
space=$1
if !(( space >= 1 && space <= 10 )); then
  echo "Invalid space number: ${space}"
  exit 1
fi
window=$(yabai -m query --windows --window | jq -r '.id')
if !(( window > 0 )); then
  echo "Couldn't find window"
  exit 2
fi
# Quick path - if the space is already visible on the other display we can just move it
if yabai -m query --spaces --space "${space}" | jq -e '."is-visible" == true'; then
  yabai -m window --space "${space}" --focus
  exit 0
fi
# If not we need to switch it to the non-focused display, then switch spaces on the other display and then switch it
tmp_display=$(yabai -m query --displays | jq -r '.[] | select(."has-focus" == false) | .id')
yabai -m window "${window}" --display "${tmp_display}"
space-switch "${space}"
for ((i=0; i<100; i++)); do
    if yabai -m query --spaces --space "${space}" | jq -e '."has-focus" == true'; then
        echo "Space ${space} has focus."
        break
    fi
    sleep 0.01
done
yabai -m space "${space}" --layout bsp
yabai -m window "${window}" --space "${space}" --focus

@Spuxy
Copy link

Spuxy commented Dec 13, 2024

thats pretty sad, that we need to disable that... time to switch to x86 notebook

@creese
Copy link
Author

creese commented Dec 27, 2024

You need to use the latest version of yabai and disable SIP as described in the wiki, for moving windows to other spaces to work in Sequoia. Apple added protection to the API - there is no workaround.

Thanks for clarifying this can't be fixed. Disabling SIP is a no-go, and not being able to move windows between spaces greatly reduces yabai's utility for me. I guess it’s back to Linux!

@pm0u
Copy link

pm0u commented Dec 30, 2024

The end of an era. sadly can't disable SIP due to work restrictions. understandably out of your control, thanks for all the effort as always.

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

9 participants