diff --git a/CHANGELOG.md b/CHANGELOG.md index f44329bf..d771ea6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Update scripting-addition to support macOS Big Sur 10.16 Build 20A5343i [#589](https://github.com/koekeishiya/yabai/issues/589) - Border windows should not have shadows [#617](https://github.com/koekeishiya/yabai/issues/617) - *external_bar* should not have to be set before regular padding [#615](https://github.com/koekeishiya/yabai/issues/615) +- Adjust reported mouse location to use when synthesizing events for ffm autofocus [#637](https://github.com/koekeishiya/yabai/issues/637) ## [3.2.1] - 2020-06-17 ### Changed - Fixed a race condition upon receiving window destroy notifications from macOS because their API is garbage and reports duplicate notifications for the same window [#580](https://github.com/koekeishiya/yabai/issues/580) - focus-follows-mouse *autofocus* needs to perform some validation in order to see if the window is focusable [#578](https://github.com/koekeishiya/yabai/issues/578) +- Properly set mouse location for synthesized events used by ffm autofocus [#545](https://github.com/koekeishiya/yabai/issues/545) ## [3.2.0] - 2020-06-14 ### Added diff --git a/src/window_manager.c b/src/window_manager.c index de810f26..8267864a 100644 --- a/src/window_manager.c +++ b/src/window_manager.c @@ -764,23 +764,8 @@ struct window *window_manager_find_smallest_managed_window(struct space_manager static void window_manager_make_key_window(ProcessSerialNumber *window_psn, uint32_t window_id) { - uint8_t bytes1[0xf8] = { - [0x04] = 0xf8, - [0x08] = 0x01, - [0x26] = 0xf0, - [0x27] = 0xbf, - [0x2e] = 0xf0, - [0x2f] = 0xbf - }; - - uint8_t bytes2[0xf8] = { - [0x04] = 0xf8, - [0x08] = 0x02, - [0x26] = 0xf0, - [0x27] = 0xbf, - [0x2e] = 0xf0, - [0x2f] = 0xbf - }; + uint8_t bytes1[0xf8] = { [0x04] = 0xf8, [0x08] = 0x01, [0x26] = 0xef, [0x27] = 0x7f, [0x2e] = 0xef, [0x2f] = 0x7f }; + uint8_t bytes2[0xf8] = { [0x04] = 0xf8, [0x08] = 0x02, [0x26] = 0xef, [0x27] = 0x7f, [0x2e] = 0xef, [0x2f] = 0x7f }; memcpy(bytes1 + 0x3c, &window_id, sizeof(uint32_t)); memcpy(bytes2 + 0x3c, &window_id, sizeof(uint32_t)); @@ -789,34 +774,12 @@ static void window_manager_make_key_window(ProcessSerialNumber *window_psn, uint SLPSPostEventRecordTo(window_psn, bytes2); } -static void window_manager_deactivate_window(ProcessSerialNumber *window_psn, uint32_t window_id) -{ - uint8_t bytes[0xf8] = { - [0x04] = 0xf8, - [0x08] = 0x0d, - [0x8a] = 0x02 - }; - - memcpy(bytes + 0x3c, &window_id, sizeof(uint32_t)); - SLPSPostEventRecordTo(window_psn, bytes); -} - -static void window_manager_activate_window(ProcessSerialNumber *window_psn, uint32_t window_id) -{ - uint8_t bytes[0xf8] = { - [0x04] = 0xf8, - [0x08] = 0x0d, - [0x8a] = 0x01 - }; - - memcpy(bytes + 0x3c, &window_id, sizeof(uint32_t)); - SLPSPostEventRecordTo(window_psn, bytes); -} - void window_manager_focus_window_without_raise(ProcessSerialNumber *window_psn, uint32_t window_id) { if (psn_equals(window_psn, &g_window_manager.focused_window_psn)) { - window_manager_deactivate_window(&g_window_manager.focused_window_psn, g_window_manager.focused_window_id); + uint8_t bytes1[0xf8] = { [0x04] = 0xf8, [0x08] = 0x0d, [0x8a] = 0x02 }; + memcpy(bytes1 + 0x3c, &g_window_manager.focused_window_id, sizeof(uint32_t)); + SLPSPostEventRecordTo(&g_window_manager.focused_window_psn, bytes1); // @hack // Artificially delay the activation by 1ms. This is necessary @@ -824,7 +787,9 @@ void window_manager_focus_window_without_raise(ProcessSerialNumber *window_psn, // the events appear instantaneously. usleep(10000); - window_manager_activate_window(window_psn, window_id); + uint8_t bytes2[0xf8] = { [0x04] = 0xf8, [0x08] = 0x0d, [0x8a] = 0x01 }; + memcpy(bytes2 + 0x3c, &window_id, sizeof(uint32_t)); + SLPSPostEventRecordTo(window_psn, bytes2); } _SLPSSetFrontProcessWithOptions(window_psn, window_id, kCPSUserGenerated);