Skip to content

Commit

Permalink
#2380 use space workaround for Ventura 13.6, and fix misc Sequoia sup…
Browse files Browse the repository at this point in the history
…port
  • Loading branch information
koekeishiya committed Aug 10, 2024
1 parent 4572d69 commit 6773d2b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Allow *window_animation_duration* to be set to `0.0` without requesting *Screen Capture* permissions [#2378](https://github.com/koekeishiya/yabai/issues/2378)
- Add new *window --toggle* option `windowed-fullscreen` to fullscreen a window, ignoring all configured padding for both managed and unmanaged windows [#2221](https://github.com/koekeishiya/yabai/issues/2221)
- Moving windows to other spaces requires SIP to be disabled on macOS Sequoia [#2324](https://github.com/koekeishiya/yabai/issues/2324) [#2331](https://github.com/koekeishiya/yabai/issues/2331)
- Updated scripting-addition mach loader/injection and payload to work for macOS Sequoia Beta 1, 2, 3, and 4 [#2324](https://github.com/koekeishiya/yabai/issues/2324) [#2331](https://github.com/koekeishiya/yabai/issues/2331)
- Updated scripting-addition mach loader/injection and payload to work for macOS Sequoia Beta 1, 2, 3, 4, and 5 [#2324](https://github.com/koekeishiya/yabai/issues/2324) [#2331](https://github.com/koekeishiya/yabai/issues/2331)
- Extend *stack window selector* to allow numeric indices: `yabai -m window --focus stack.3` [#2342](https://github.com/koekeishiya/yabai/issues/2342)

## [7.1.1] - 2024-05-18
Expand Down
5 changes: 4 additions & 1 deletion src/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,10 @@ static EVENT_HANDLER(DOCK_DID_RESTART)
{
debug("%s:\n", __FUNCTION__);

if (workspace_is_macos_monterey() || workspace_is_macos_ventura() || workspace_is_macos_sonoma()) {
if (workspace_is_macos_monterey() ||
workspace_is_macos_ventura() ||
workspace_is_macos_sonoma() ||
workspace_is_macos_sequoia()) {
mission_control_unobserve();
mission_control_observe();
}
Expand Down
24 changes: 10 additions & 14 deletions src/space_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,31 +647,27 @@ uint64_t space_manager_active_space(void)

void space_manager_move_window_list_to_space(uint64_t sid, uint32_t *window_list, int window_count)
{
if (workspace_is_macos_sonoma14_5_or_newer()) {
if (!scripting_addition_move_window_list_to_space(sid, window_list, window_count)) {
SLSSpaceSetCompatID(g_connection, sid, 0x79616265);
SLSSetWindowListWorkspace(g_connection, window_list, window_count, 0x79616265);
SLSSpaceSetCompatID(g_connection, sid, 0x0);
}
} else {
if (!workspace_use_macos_space_workaround()) {
CFArrayRef window_list_ref = cfarray_of_cfnumbers(window_list, sizeof(uint32_t), window_count, kCFNumberSInt32Type);
SLSMoveWindowsToManagedSpace(g_connection, window_list_ref, sid);
CFRelease(window_list_ref);
} else if (!scripting_addition_move_window_list_to_space(sid, window_list, window_count)) {
SLSSpaceSetCompatID(g_connection, sid, 0x79616265);
SLSSetWindowListWorkspace(g_connection, window_list, window_count, 0x79616265);
SLSSpaceSetCompatID(g_connection, sid, 0x0);
}
}

void space_manager_move_window_to_space(uint64_t sid, struct window *window)
{
if (workspace_is_macos_sonoma14_5_or_newer()) {
if (!scripting_addition_move_window_to_space(sid, window->id)) {
SLSSpaceSetCompatID(g_connection, sid, 0x79616265);
SLSSetWindowListWorkspace(g_connection, &window->id, 1, 0x79616265);
SLSSpaceSetCompatID(g_connection, sid, 0x0);
}
} else {
if (!workspace_use_macos_space_workaround()) {
CFArrayRef window_list_ref = cfarray_of_cfnumbers(&window->id, sizeof(uint32_t), 1, kCFNumberSInt32Type);
SLSMoveWindowsToManagedSpace(g_connection, window_list_ref, sid);
CFRelease(window_list_ref);
} else if (!scripting_addition_move_window_to_space(sid, window->id)) {
SLSSpaceSetCompatID(g_connection, sid, 0x79616265);
SLSSetWindowListWorkspace(g_connection, &window->id, 1, 0x79616265);
SLSSpaceSetCompatID(g_connection, sid, 0x0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ int window_level(uint32_t wid)
{
int level = 0;

if (workspace_is_macos_ventura() || workspace_is_macos_sonoma()) {
if (workspace_is_macos_ventura() || workspace_is_macos_sonoma() || workspace_is_macos_sequoia()) {
CFArrayRef window_ref = cfarray_of_cfnumbers(&wid, sizeof(uint32_t), 1, kCFNumberSInt32Type);

CFTypeRef query = SLSWindowQueryWindows(g_connection, window_ref, 1);
Expand Down
5 changes: 4 additions & 1 deletion src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -2173,7 +2173,10 @@ void window_manager_wait_for_native_fullscreen_transition(struct window *window)
{
TIME_FUNCTION;

if (workspace_is_macos_monterey() || workspace_is_macos_ventura() || workspace_is_macos_sonoma()) {
if (workspace_is_macos_monterey() ||
workspace_is_macos_ventura() ||
workspace_is_macos_sonoma() ||
workspace_is_macos_sequoia()) {
while (!space_is_user(space_manager_active_space())) {

//
Expand Down
3 changes: 2 additions & 1 deletion src/workspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define WORKSPACE_H

#define SUPPORTED_MACOS_VERSION_LIST \
SUPPORT_MACOS_VERSION(sequoia, 15) \
SUPPORT_MACOS_VERSION(sonoma, 14) \
SUPPORT_MACOS_VERSION(ventura, 13) \
SUPPORT_MACOS_VERSION(monterey, 12) \
Expand Down Expand Up @@ -31,6 +32,6 @@ void workspace_application_observe_activation_policy(void *context, struct proce
int workspace_display_notch_height(uint32_t did);
pid_t workspace_get_dock_pid(void);
bool workspace_event_handler_begin(void **context);
bool workspace_is_macos_sonoma14_5_or_newer(void);
bool workspace_use_macos_space_workaround(void);

#endif
7 changes: 3 additions & 4 deletions src/workspace.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ bool workspace_event_handler_begin(void **context)
return true;
}

bool workspace_is_macos_sonoma14_5_or_newer(void)
bool workspace_use_macos_space_workaround(void)
{
NSOperatingSystemVersion os_version = [[NSProcessInfo processInfo] operatingSystemVersion];

if (os_version.majorVersion > 14) return true;

if (os_version.majorVersion == 13 && os_version.minorVersion >= 6) return true;
if (os_version.majorVersion == 14 && os_version.minorVersion >= 5) return true;

return false;
return os_version.majorVersion >= 15;
}

void *workspace_application_create_running_ns_application(struct process *process)
Expand Down
9 changes: 7 additions & 2 deletions src/yabai.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,15 @@ int main(int argc, char **argv)
error("yabai: could not start mouse handler! abort..\n");
}

if (workspace_is_macos_monterey() || workspace_is_macos_ventura() || workspace_is_macos_sonoma()) {
if (workspace_is_macos_monterey() ||
workspace_is_macos_ventura() ||
workspace_is_macos_sonoma() ||
workspace_is_macos_sequoia()) {
mission_control_observe();

if (workspace_is_macos_ventura() || workspace_is_macos_sonoma()) {
if (workspace_is_macos_ventura() ||
workspace_is_macos_sonoma() ||
workspace_is_macos_sequoia()) {
SLSRegisterConnectionNotifyProc(g_connection, connection_handler, 1327, NULL);
SLSRegisterConnectionNotifyProc(g_connection, connection_handler, 1328, NULL);
}
Expand Down

0 comments on commit 6773d2b

Please sign in to comment.