fix: fullscreen crashing with no roundedCorners and no frame (#39747)

This commit is contained in:
Shelley Vohr 2023-09-11 09:38:10 +02:00 committed by GitHub
parent 2324c4d8fd
commit ab185c058f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -683,9 +683,6 @@ void NativeWindowMac::DetachChildren() {
} }
void NativeWindowMac::SetFullScreen(bool fullscreen) { void NativeWindowMac::SetFullScreen(bool fullscreen) {
if (!has_frame() && !HasStyleMask(NSWindowStyleMaskTitled))
return;
// [NSWindow -toggleFullScreen] is an asynchronous operation, which means // [NSWindow -toggleFullScreen] is an asynchronous operation, which means
// that it's possible to call it while a fullscreen transition is currently // that it's possible to call it while a fullscreen transition is currently
// in process. This can create weird behavior (incl. phantom windows), // in process. This can create weird behavior (incl. phantom windows),
@ -718,7 +715,8 @@ void NativeWindowMac::SetFullScreen(bool fullscreen) {
? FullScreenTransitionState::kEntering ? FullScreenTransitionState::kEntering
: FullScreenTransitionState::kExiting; : FullScreenTransitionState::kExiting;
[window_ toggleFullScreenMode:nil]; if (![window_ toggleFullScreenMode:nil])
fullscreen_transition_state_ = FullScreenTransitionState::kNone;
} }
bool NativeWindowMac::IsFullscreen() const { bool NativeWindowMac::IsFullscreen() const {

View file

@ -44,7 +44,7 @@ class ScopedDisableResize {
- (electron::NativeWindowMac*)shell; - (electron::NativeWindowMac*)shell;
- (id)accessibilityFocusedUIElement; - (id)accessibilityFocusedUIElement;
- (NSRect)originalContentRectForFrameRect:(NSRect)frameRect; - (NSRect)originalContentRectForFrameRect:(NSRect)frameRect;
- (void)toggleFullScreenMode:(id)sender; - (BOOL)toggleFullScreenMode:(id)sender;
- (NSImage*)_cornerMask; - (NSImage*)_cornerMask;
@end @end

View file

@ -334,7 +334,10 @@ void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) {
} }
} }
- (void)toggleFullScreenMode:(id)sender { - (BOOL)toggleFullScreenMode:(id)sender {
if (!shell_->has_frame() && !shell_->HasStyleMask(NSWindowStyleMaskTitled))
return NO;
bool is_simple_fs = shell_->IsSimpleFullScreen(); bool is_simple_fs = shell_->IsSimpleFullScreen();
bool always_simple_fs = shell_->always_simple_fullscreen(); bool always_simple_fs = shell_->always_simple_fullscreen();
@ -363,6 +366,8 @@ void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) {
bool maximizable = shell_->IsMaximizable(); bool maximizable = shell_->IsMaximizable();
shell_->SetMaximizable(maximizable); shell_->SetMaximizable(maximizable);
} }
return YES;
} }
- (void)performMiniaturize:(id)sender { - (void)performMiniaturize:(id)sender {