fix: handle async nature of [NSWindow -toggleFullScreen] (#25470)

This commit is contained in:
Shelley Vohr 2021-04-21 16:56:25 +02:00 committed by GitHub
parent 7063b5ef2c
commit 503d24a473
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 127 additions and 17 deletions

View file

@ -223,11 +223,23 @@ bool ScopedDisableResize::disable_resize_ = false;
if (is_simple_fs || always_simple_fs) {
shell_->SetSimpleFullScreen(!is_simple_fs);
} else {
bool maximizable = shell_->IsMaximizable();
[super toggleFullScreen:sender];
if (shell_->IsVisible()) {
// Until 10.13, AppKit would obey a call to -toggleFullScreen: made inside
// windowDidEnterFullScreen & windowDidExitFullScreen. Starting in 10.13,
// it behaves as though the transition is still in progress and just emits
// "not in a fullscreen state" when trying to exit fullscreen in the same
// runloop that entered it. To handle this, invoke -toggleFullScreen:
// asynchronously.
[super performSelector:@selector(toggleFullScreen:)
withObject:nil
afterDelay:0];
} else {
[super toggleFullScreen:sender];
}
// Exiting fullscreen causes Cocoa to redraw the NSWindow, which resets
// the enabled state for NSWindowZoomButton. We need to persist it.
bool maximizable = shell_->IsMaximizable();
shell_->SetMaximizable(maximizable);
}
}