Skip to content

Instantly share code, notes, and snippets.

@jorpilo
Created August 27, 2023 03:39
Show Gist options
  • Save jorpilo/da6446b6ee4d72cb492653a3b97b0457 to your computer and use it in GitHub Desktop.
Save jorpilo/da6446b6ee4d72cb492653a3b97b0457 to your computer and use it in GitHub Desktop.
Yabai sonoma patch
diff --git a/src/window_manager.c b/src/window_manager.c
index c14309c..6a8d4c8 100644
--- a/src/window_manager.c
+++ b/src/window_manager.c
@@ -1221,6 +1221,11 @@ static void window_manager_make_key_window(ProcessSerialNumber *window_psn, uint
void window_manager_focus_window_without_raise(ProcessSerialNumber *window_psn, uint32_t window_id)
{
+ if (workspace_is_macos_sonoma()) {
+ debug("%s is not available on macOS Sonoma..\n", __FUNCTION__);
+ return;
+ }
+
if (psn_equals(window_psn, &g_window_manager.focused_window_psn)) {
uint8_t bytes1[0xf8] = { [0x04] = 0xf8, [0x08] = 0x0d, [0x8a] = 0x02 };
memcpy(bytes1 + 0x3c, &g_window_manager.focused_window_id, sizeof(uint32_t));
@@ -1246,13 +1251,18 @@ void window_manager_focus_window_without_raise(ProcessSerialNumber *window_psn,
void window_manager_focus_window_with_raise(ProcessSerialNumber *window_psn, uint32_t window_id, AXUIElementRef window_ref)
{
+ if (workspace_is_macos_sonoma()) {
+ _SLPSSetFrontProcessWithOptions(window_psn, 0, kCPSNoWindows);
+ AXUIElementPerformAction(window_ref, kAXRaiseAction);
+ } else {
#if 1
- _SLPSSetFrontProcessWithOptions(window_psn, window_id, kCPSUserGenerated);
- window_manager_make_key_window(window_psn, window_id);
- AXUIElementPerformAction(window_ref, kAXRaiseAction);
+ _SLPSSetFrontProcessWithOptions(window_psn, window_id, kCPSUserGenerated);
+ window_manager_make_key_window(window_psn, window_id);
+ AXUIElementPerformAction(window_ref, kAXRaiseAction);
#else
- scripting_addition_focus_window(window_id);
+ scripting_addition_focus_window(window_id);
#endif
+ }
}
#pragma clang diagnostic push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment