Skip to content

Commit

Permalink
#690 revert how fullscreen transition spinlock is being done on macOS…
Browse files Browse the repository at this point in the history
… Mojave
  • Loading branch information
koekeishiya committed Nov 14, 2020
1 parent eb16819 commit a39eefb
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Improved SIP detection logic [#716](https://github.com/koekeishiya/yabai/issues/716)
- Windows that do not report a title at all should be treated as having the empty string as its title [#707](https://github.com/koekeishiya/yabai/issues/707)
- Allow *SPACE_SEL* to be used instead of *mission-control index* when specifying config options for a specific space [#705](https://github.com/koekeishiya/yabai/issues/705)
- Native fullscreen transitions would freeze on macOS Mojave due to internal API differences between macOS version [#690](https://github.com/koekeishiya/yabai/issues/690)

## [3.3.4] - 2020-11-14
### Changed
Expand Down
13 changes: 1 addition & 12 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,7 @@ static EVENT_CALLBACK(EVENT_HANDLER_WINDOW_RESIZED)
window_manager_purify_window(&g_window_manager, window);
}
} else if (was_fullscreen && !is_fullscreen) {
uint32_t did = window_display_id(window);

do {

//
// NOTE(koekeishiya): Window has exited native-fullscreen mode.
// We need to spin lock until the display is finished animating
// because we are not actually able to interact with the window.
//

usleep(100000);
} while (display_manager_display_is_animating(did));
window_manager_wait_for_native_fullscreen_transition(window);

if (window_manager_should_manage_window(window) && !window_manager_find_managed_window(&g_window_manager, window)) {
struct view *view = space_manager_tile_window_on_space(&g_space_manager, window, window_space(window));
Expand Down
34 changes: 34 additions & 0 deletions src/window_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,40 @@ void window_manager_toggle_window_shadow(struct space_manager *sm, struct window
if (scripting_addition_set_shadow(window->id, shadow)) window->has_shadow = shadow;
}

void window_manager_wait_for_native_fullscreen_transition(struct window *window)
{
if (workspace_is_macos_mojave()) {
while (!space_is_user(space_manager_active_space())) {

//
// NOTE(koekeishiya): Window has exited native-fullscreen mode.
// We need to spin lock until the display is finished animating
// because we are not actually able to interact with the window.
//
// macOS Mojave freezes fullscreen applications when using the
// display_manager API to check for animation status:
//
// - https://github.com/koekeishiya/yabai/issues/690
//

usleep(100000);
}
} else {
uint32_t did = window_display_id(window);

do {

//
// NOTE(koekeishiya): Window has exited native-fullscreen mode.
// We need to spin lock until the display is finished animating
// because we are not actually able to interact with the window.
//

usleep(100000);
} while (display_manager_display_is_animating(did));
}
}

void window_manager_toggle_window_native_fullscreen(struct space_manager *sm, struct window_manager *wm, struct window *window)
{
uint32_t sid = window_space(window);
Expand Down
1 change: 1 addition & 0 deletions src/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ void window_manager_toggle_window_native_fullscreen(struct space_manager *sm, st
void window_manager_toggle_window_expose(struct window_manager *wm, struct window *window);
void window_manager_toggle_window_pip(struct space_manager *sm, struct window_manager *wm, struct window *window);
void window_manager_toggle_window_border(struct window_manager *wm, struct window *window);
void window_manager_wait_for_native_fullscreen_transition(struct window *window);
void window_manager_validate_and_check_for_windows_on_space(struct space_manager *sm, struct window_manager *wm, uint64_t sid);
void window_manager_handle_display_add_and_remove(struct space_manager *sm, struct window_manager *wm, uint32_t did);
void window_manager_begin(struct space_manager *sm, struct window_manager *window_manager);
Expand Down
1 change: 1 addition & 0 deletions src/workspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void workspace_application_observe_finished_launching(void *context, struct proc
void workspace_application_observe_activation_policy(void *context, struct process *process);
bool workspace_is_macos_bigsur(void);
bool workspace_is_macos_catalina(void);
bool workspace_is_macos_mojave(void);
bool workspace_is_macos_highsierra(void);

#endif
6 changes: 6 additions & 0 deletions src/workspace.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ bool workspace_is_macos_catalina(void)
return version.majorVersion == 10 && version.minorVersion == 15;
}

bool workspace_is_macos_mojave(void)
{
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
return version.majorVersion == 10 && version.minorVersion == 14;
}

bool workspace_is_macos_highsierra(void)
{
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
Expand Down

0 comments on commit a39eefb

Please sign in to comment.