Skip to content

Commit

Permalink
#1772 update scripting addition for macOS Sonoma 14.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Oct 1, 2023
1 parent cb19999 commit ea834ac
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 30 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]
### Changed
- Updated scripting-addition to support macOS Sonoma 14.0 [#1772](https://github.com/koekeishiya/yabai/issues/1772)
- Fix window focusing (autofocus, and autoraise across multiple monitors [#109](https://github.com/koekeishiya/yabai/issues/109)) for macOS Sonoma [#1772](https://github.com/koekeishiya/yabai/issues/1772)
- Fix scripting-addition functionaltiy that uses Dock.app connection to the WindowServer for macOS Sonoma [#1772](https://github.com/koekeishiya/yabai/issues/1772)
- Fix scripting-addition functionality that uses Dock.app connection to the WindowServer for macOS Sonoma [#1772](https://github.com/koekeishiya/yabai/issues/1772)
- Fix mission-control integration for macOS Sonoma [#1772](https://github.com/koekeishiya/yabai/issues/1772)
- Prevent *focus follows mouse* from activating the menubar in vertical display arrangements [#1857](https://github.com/koekeishiya/yabai/issues/1857)

Expand Down
56 changes: 42 additions & 14 deletions src/osax/arm64/payload.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
__asm__("mov x0, %0\n""mov x1, %1\n""mov x2, %2\n""mov x20, %3\n" : :"r"(v0), "r"(v1), "r"(v2), "r"(v3) :"x0", "x1", "x2", "x20"); ((void (*)())(func))();

uint64_t get_dock_spaces_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return 0x114000;
} else if (os_version.majorVersion == 13) {
return 0x118000;
} else if (os_version.majorVersion == 12) {
return 0x8000;
Expand All @@ -15,7 +17,9 @@ uint64_t get_dock_spaces_offset(NSOperatingSystemVersion os_version) {
}

uint64_t get_dppm_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return 0x9000;
} else if (os_version.majorVersion == 13) {
return 0x9000;
} else if (os_version.majorVersion == 12) {
return 0x7000;
Expand All @@ -25,7 +29,9 @@ uint64_t get_dppm_offset(NSOperatingSystemVersion os_version) {
}

uint64_t get_fix_animation_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return 0x1F0000;
} else if (os_version.majorVersion == 13) {
return 0x1E0000;
} else if (os_version.majorVersion == 12) {
return 0x230000;
Expand All @@ -35,7 +41,9 @@ uint64_t get_fix_animation_offset(NSOperatingSystemVersion os_version) {
}

uint64_t get_add_space_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return 0x1F0000;
} else if (os_version.majorVersion == 13) {
return 0x1E0000;
} else if (os_version.majorVersion == 12) {
return 0x220000;
Expand All @@ -45,7 +53,9 @@ uint64_t get_add_space_offset(NSOperatingSystemVersion os_version) {
}

uint64_t get_remove_space_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return 0x2B0000;
} else if (os_version.majorVersion == 13) {
return 0x2A0000;
} else if (os_version.majorVersion == 12) {
return 0x2E0000;
Expand All @@ -55,7 +65,9 @@ uint64_t get_remove_space_offset(NSOperatingSystemVersion os_version) {
}

uint64_t get_move_space_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return 0x2A0000;
} else if (os_version.majorVersion == 13) {
return 0x290000;
} else if (os_version.majorVersion == 12) {
return 0x2D0000;
Expand All @@ -65,7 +77,9 @@ uint64_t get_move_space_offset(NSOperatingSystemVersion os_version) {
}

uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return 0x47000;
} else if (os_version.majorVersion == 13) {
return 0x47000;
} else if (os_version.majorVersion == 12) {
return 0x4D000;
Expand All @@ -75,7 +89,9 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
}

const char *get_dock_spaces_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return "97 18 00 B0 F7 02 0F 91 E0 02 40 F9 E2 03 14 AA 1A 09 08 94 FD 03 1D AA 3C EF 07 94 F6 03 00 AA 00 01 00 B5 E0 02 40 F9 E2 03 14 AA 3B 0F 08 94 FD 03 1D AA 35 EF 07 94 F6 03 00 AA E0 00 00 B4 E0 03 15 AA E2 03 13 AA E3 03 16 AA F3 F3 07 94 E0 03 16 AA 1D EF 07 94 E0 03 14 AA";
} else if (os_version.majorVersion == 13) {
return "?? 17 00 ?? 73 ?? ?? 91 60 02 40 F9 E2 03 17 AA ?? ?? 07 94 FD 03 1D AA ?? ?? 07 94 E0 07 00 F9 ?? 16 00 ?? 00 ?? ?? F9 ?? ?? 07 94 02 00 80 D2 ?? ?? 07 94 E0 13 00 F9 60 02 40 F9 FC 1F 00 F9 E2 03 1C AA ?? ?? 07 94 FD 03 1D AA ?? ?? 07 94 F5 03 00 AA ?? 16 00 ?? ?? ?? ?? F9";
} else if (os_version.majorVersion == 12) {
return "55 21 00 ?? B5 ?? ?? 91 A0 02 40 F9 ?? 1F 00 ?? 01 ?? ?? F9 E2 03 1B AA ?? ?? 0C 94 FD 03 1D AA ?? ?? 0C 94 E0 13 00 F9 ?? 20 00 ?? 00 ?? ?? F9 ?? ?? 0C 94 E8 1F 00 ?? 13 ?? ?? F9 E1 03 13 AA 02 00 80 D2 ?? ?? 0C 94 E0 27 00 F9 A0 02 40 F9 08 20 00 ?? 01 ?? ?? F9";
Expand All @@ -85,7 +101,9 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
}

const char *get_dppm_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return "E0 20 00 90 00 ?? ?? 91 E1 03 13 AA ?? ?? 0C 94 73 2D 00 B4 E1 20 00 90 21 ?? ?? 91 00 00 80 D2 D9 13 0C 94 A8 1F 00 F0 00 79 43 F9 A2 38 0C 94 FD 03 1D AA 1C 1E 0C 94 F4 03 00 AA BF 7F 37 A9";
} else if (os_version.majorVersion == 13) {
return "00 20 00 D0 00 ?? ?? 91 E1 03 13 AA ?? ?? 0B 94 13 2E 00 B4 16 20 00 D0 D6 ?? ?? 91 00 00 80 D2 E1 03 16 AA ?? ?? 0B 94 E8 1E 00 D0 00 ?? ?? F9 ?? ?? 0B 94 FD 03 1D AA ?? ?? 0B 94 F4 03 00 AA";
} else if (os_version.majorVersion == 12) {
return "?? 21 00 ?? 00 ?? ?? 91 E1 03 13 AA ?? ?? 0C 94 ?? ?? 00 B4 ?? 20 00 ?? 00 ?? ?? F9 ?? ?? 00 ?? 19 ?? ?? F9 E1 03 19 AA ?? ?? 0C 94 FD 03 1D AA ?? ?? 0C 94 F4 03 00 AA ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? ?? ??";
Expand All @@ -95,7 +113,9 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
}

const char *get_fix_animation_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return "00 10 6A 1E E0 03 14 AA E1 03 ?? AA E2 03 ?? AA A8 ?? 01 D1";
} else if (os_version.majorVersion == 13) {
return "00 10 6A 1E E0 03 14 AA E1 03 18 AA E2 03 17 AA A8 43 01 D1";
} else if (os_version.majorVersion == 12) {
return "00 10 6A 1E E0 03 14 AA E2 03 13 AA A8 43 01 D1 04 01 50 B8";
Expand All @@ -105,7 +125,9 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
}

const char *get_add_space_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return "7F 23 03 D5 FF C3 01 D1 E1 03 1E AA ?? ?? 00 94 FE 03 01 AA FD 7B 06 A9 FD 83 01 91 F5 03 14 AA F3 03 00 AA 89 E2 40 39 96 16 40 F9 C8 FE 7E D3 3F 05 00 71 A1 00 00 54 ?? ?? 00 B5 C8 E2 7D 92 17 09 40 F9 ?? 00 00 14 ?? ?? 00 B5 C8 E2 7D 92 17 09 40 F9 ?? ?? 16 AA 0F 7A 04 94 77 07 00 B4 F8 06 00 F1 A6 18 00 54 DA 0A 42 F2 E1 17 9F 1A E0 03 18 AA E2 03 16 AA E9 8A FF 97 1A 18 00 B5 C8 0E 18 8B 00 11 40 F9";
} else if (os_version.majorVersion == 13) {
return "7F 23 03 D5 FF C3 01 D1 E1 03 1E AA ?? ?? 00 94 FE 03 01 AA FD 7B 06 A9 FD 83 01 91 F5 03 14 AA F3 03 00 AA 89 E2 40 39 96 16 40 F9 C8 FE 7E D3 3F 05 00 71 A1 00 00 54 ?? 14 00 B5 C8 E2 7D 92 17 09 40 F9 ?? 00 00 14 ?? ?? 00 B5 C8 E2 7D 92 17 09 40 F9 ?? ?? 00 94 ?? ?? 00 B4 F8 06 00 F1 ?? 15 00 54 DA 0A 42 F2 E1 17 9F 1A E0 03 18 AA E2 03 16 AA ?? ?? ?? 97 ?? 14 00 B5 C8 0E 18 8B ?? ?? 00 94 F4 03 00 AA";
} else if (os_version.majorVersion == 12) {
return "7F 23 03 D5 FF C3 01 D1 E1 03 1E AA ?? ?? 00 94 FE 03 01 AA FD 7B 06 A9 FD 83 01 91 F5 03 14 AA F3 03 00 AA 89 E2 40 39 96 16 40 F9 C8 FE 7E D3 3F 05 00 71 A1 00 00 54 ?? 14 00 B5 C8 E2 7D 92 17 09 40 F9 ?? 00 00 14 ?? ?? 00 B5 C8 E2 7D 92 17 09 40 F9 ?? ?? 00 94 ?? ?? 00 B4 F8 06 00 F1 ?? 15 00 54 DA 0A 42 F2 E1 17 9F 1A E0 03 18 AA E2 03 16 AA ?? ?? FD 97 ?? 14 00 B5 C8 0E 18 8B ?? ?? 00 94 F4 03 00 AA";
Expand All @@ -115,7 +137,9 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
}

const char *get_remove_space_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return "7F 23 03 D5 FF 83 ?? D1 FC 6F ?? A9 FA 67 ?? A9 F8 5F ?? A9 F6 57 ?? A9 F4 4F ?? A9 FD 7B ?? A9 FD 43 ?? 91 ?? 03 03 AA ?? 03 02 AA ?? 03 01 AA ?? 03 00 AA ?? ?? ?? 97 FC 03 00 AA 08 FC 7E D3 ?? ?? 00 B5 88 E3 7D 92 00 09 40 F9 1F 08 00 F1 2B 0F 00 54 ?? ?? 01 A9 C8 0A 00 ?? 1F 20 03 D5 08 ?? ?? F9 ?? ?? 08 8B 14 55 40 A9 ?? 0B 00 ?? 1F 20 03 D5 00 ?? ?? F9 28 0A 00 ?? 01 ?? ?? F9 E2 03 1A AA";
} else if (os_version.majorVersion == 13) {
return "7F 23 03 D5 FF 83 ?? D1 FC 6F ?? A9 FA 67 ?? A9 F8 5F ?? A9 F6 57 ?? A9 F4 4F ?? A9 FD 7B ?? A9 FD 43 ?? 91 ?? 03 03 AA ?? 03 02 AA ?? 03 01 AA F3 03 00 AA ?? ?? FD 97 FC 03 00 AA 08 FC 7E D3 ?? 20 00 B5 88 E3 7D 92 00 09 40 F9 1F 08 00 F1 2B 0F 00 54 F5 53 01 A9 C8 0A 00 B0 1F 20 03 D5 08 ?? ?? F9 68 02 08 8B 14 55 40 A9 48 0B 00 F0 1F 20 03 D5 00 ?? ?? F9 28 0A 00 B0 01 ?? ?? F9 F3 13 00 F9";
} else if (os_version.majorVersion == 12) {
return "7F 23 03 D5 FF 83 03 D1 FC 6F 08 A9 FA 67 09 A9 F8 5F 0A A9 F6 57 0B A9 F4 4F 0C A9 FD 7B 0D A9 FD 43 03 91 F7 03 03 AA F6 03 02 AA F5 03 01 AA F3 03 00 AA F4 03 01 AA ?? ?? FD 97 F4 03 00 AA 08 FC 7E D3 ?? ?? 00 B5 88 E2 7D 92 00 09 40 F9 1F 08 00 F1 ?? 0E 00 54 ?? ?? ?? ?? F5 ?? ?? ?? ?? ?? 00 ?? 1F 20 03 D5 08 ?? ?? F9 68 02 08 8B 14 69 40 A9 ?? 0A 00 ?? 1F 20 03 D5 00 ?? ?? F9 48 09 00 ?? 01 ?? ?? F9 F3 ?? 00 F9 E2 03 13 AA";
Expand All @@ -125,7 +149,9 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
}

const char *get_move_space_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return "7F 23 03 D5 FF C3 01 D1 E3 03 1E AA ?? ?? 00 94 FE 03 03 AA FD 7B 06 A9 FD 83 01 91 F6 03 14 AA F4 03 02 AA FA 03 01 AA FB 03 00 AA ?? 0B 00 ?? F7 ?? ?? 91 E8 02 40 F9 19 68 68 F8 E0 03 19 AA E1 03 16 AA ?? 25 00 94 ?? ?? 00 B4 ?? 03 00 AA ?? 03 01 AA C8 0B 00 ?? 08 ?? ?? 91 08 01 40 39 1F 05 00 71 ?? ?? 00 54 ?? ?? 00 91 E0 03 13 AA 36 29 FD 97 5B 96 01 94 E0 03 13 AA E1 03 1A AA F4 03 15 AA 77 2E FD 97 EF 00 00 14 14 00 80 52";
} else if (os_version.majorVersion == 13) {
if (os_version.minorVersion >= 3) {
return "7F 23 03 D5 FF C3 01 D1 E3 03 1E AA EB 55 00 94 FE 03 03 AA FD 7B 06 A9 FD 83 01 91 F6 03 14 AA F4 03 02 AA FA 03 01 AA FB 03 00 AA 37 0B 00 D0 F7 82 19 91 E8 02 40 F9 19 68 68 F8 E0 03 19 AA E1 03 16 AA 42 25 00 94 80 01 00 B4 F5 03 00 AA F3 03 01 AA C8 0B 00 90 08 A1 1D 91 08 01 40 39 1F 05 00 71 E1 00 00 54 62 58 00 94 ED 9C 01 94 1F 58 00 94 C7 00 00 14 14 00 80 52 CA 00 00 14 1A 01 00 B4 E8 02 40 F9 40 6B 68 F8 E1 03 16 AA";
} else {
Expand All @@ -139,7 +165,9 @@ uint64_t get_set_front_window_offset(NSOperatingSystemVersion os_version) {
}

const char *get_set_front_window_pattern(NSOperatingSystemVersion os_version) {
if (os_version.majorVersion == 13) {
if (os_version.majorVersion == 14) {
return "7F 23 03 D5 FF ?? 02 D1 F6 57 ?? A9 F4 4F ?? A9 FD 7B ?? A9 FD ?? 02 91 ?? ?? 00 ?? 08 ?? ?? F9 08 01 40 F9 A8 83 1D F8 ?? ?? 00 ?? ?? ?? ?? ?? ?? 03 ?? AA ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? E8 ?? 06 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? ?? ?? ?? ?? ?? ??";
} else if (os_version.majorVersion == 13) {
return "7F 23 03 D5 FF ?? 02 D1 F6 57 ?? A9 F4 4F ?? A9 FD 7B ?? A9 FD ?? 02 91 ?? 1A 00 ?? 08 ?? ?? F9 08 01 40 F9 A8 83 1D F8 ?? ?? 00 ?? ?? ?? ?? ?? ?? 03 ?? AA ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? E8 ?? 06 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? ?? ?? ?? ?? ?? ??";
} else if (os_version.majorVersion == 12) {
return "7F 23 03 D5 FF ?? 02 D1 F6 57 ?? A9 F4 4F ?? A9 FD 7B ?? A9 FD ?? 02 91 ?? 1A 00 ?? 08 ?? 44 F9 08 01 40 F9 A8 83 1D F8 ?? ?? 00 ?? ?? ?? ?? ?? ?? 03 ?? AA ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? E8 ?? 06 ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? ?? ?? ?? ?? ?? ??";
Expand Down
2 changes: 1 addition & 1 deletion src/osax/common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SA_COMMON_H
#define SA_COMMON_H

#define OSAX_VERSION "2.0.20"
#define OSAX_VERSION "2.0.21"

#define OSAX_ATTRIB_DOCK_SPACES 0x01
#define OSAX_ATTRIB_DPPM 0x02
Expand Down
24 changes: 24 additions & 0 deletions src/osax/payload.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ static bool verify_os_version(NSOperatingSystemVersion os_version)
return true; // Monterey 12.0
} else if (os_version.majorVersion == 13) {
return true; // Ventura 13.0
} else if (os_version.majorVersion == 14) {
return true; // Sonoma 14.0
}

NSLog(@"[yabai-sa] spaces functionality is only supported on macOS Big Sur 11.0.0+, Monterey 12.0.0+, and Ventura 13.0.0+");
Expand All @@ -242,6 +244,8 @@ static bool verify_os_version(NSOperatingSystemVersion os_version)
return true; // Monterey 12.0
} else if (os_version.majorVersion == 13) {
return true; // Ventura 13.0
} else if (os_version.majorVersion == 14) {
return true; // Sonoma 14.0
}

NSLog(@"[yabai-sa] spaces functionality is only supported on macOS Monterey 12.0.0+, and Ventura 13.0.0+");
Expand Down Expand Up @@ -291,6 +295,26 @@ static void init_instances()
NSLog(@"[yabai-sa] (0x%llx) dppm found at address 0x%llX (0x%llx)", baseaddr, dppm_offset, dppm_offset - baseaddr);
dp_desktop_picture_manager = [(*(id *)(baseaddr + dppm_offset)) retain];
#endif

//
// @hack
//
// NOTE(koekeishiya): For whatever reason, in Sonoma, DPDesktopPictureManager is initialized and swapped
// to an alternate storage location instead of where it used to be stored in previous macOS versions..
//
// This alternate storage location resides 8-bytes before the usual location, so we simply do
// the subtract to arrive at the correct location in cases where the usual location is null.
//

#ifdef __x86_64__
if (dp_desktop_picture_manager == nil) {
dp_desktop_picture_manager = [(*(id *)(dppm_addr + dppm_offset + 0x4 - 0x8)) retain];
}
#elif __arm64__
if (dp_desktop_picture_manager == nil) {
dp_desktop_picture_manager = [(*(id *)(baseaddr + dppm_offset - 0x8)) retain];
}
#endif
}

uint64_t add_space_addr = hex_find_seq(baseaddr + get_add_space_offset(os_version), get_add_space_pattern(os_version));
Expand Down
Loading

0 comments on commit ea834ac

Please sign in to comment.