From 202f9b218af093e2002bf2551b44afffcba26f7d Mon Sep 17 00:00:00 2001 From: Akemi Date: Sat, 14 Jan 2017 21:12:16 +0100 Subject: cocoa: properly recover from toggleFullscreen fail in some circumstances cocoa isn't able to enter or exit fullscreen but we still set window sizes and flags accordingly. this leaves us in a hanging state between fullscreen and window. it also prevents the toggleFullscreen method and its events to work properly afterwards. in that state it's impossible to enter or exit this 'semi-fullscreen'. add a proper fallback to recover from this state. Fixes #4035 --- video/out/cocoa/window.m | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/video/out/cocoa/window.m b/video/out/cocoa/window.m index a661565c1d..770469bf38 100644 --- a/video/out/cocoa/window.m +++ b/video/out/cocoa/window.m @@ -97,18 +97,28 @@ [super toggleFullScreen:sender]; if (![self.adapter isInFullScreenMode]) { - [self setStyleMask:([self styleMask] | NSWindowStyleMaskFullScreen)]; - NSRect frame = [[self targetScreen] frame]; - [self setFrame:frame display:YES]; + [self setToFullScreen]; } else { - [self setStyleMask:([self styleMask] & ~NSWindowStyleMaskFullScreen)]; - NSRect frame = [self calculateWindowPositionForScreen:[self targetScreen]]; - [self setFrame:frame display:YES]; - [self setContentAspectRatio:_unfs_content_frame.size]; - [self setCenteredContentSize:_unfs_content_frame.size]; + [self setToWindow]; } } +- (void)setToFullScreen +{ + [self setStyleMask:([self styleMask] | NSWindowStyleMaskFullScreen)]; + NSRect frame = [[self targetScreen] frame]; + [self setFrame:frame display:YES]; +} + +- (void)setToWindow +{ + [self setStyleMask:([self styleMask] & ~NSWindowStyleMaskFullScreen)]; + NSRect frame = [self calculateWindowPositionForScreen:[self targetScreen]]; + [self setFrame:frame display:YES]; + [self setContentAspectRatio:_unfs_content_frame.size]; + [self setCenteredContentSize:_unfs_content_frame.size]; +} + - (NSArray *)customWindowsToEnterFullScreenForWindow:(NSWindow *)window { return [NSArray arrayWithObject:window]; @@ -139,11 +149,13 @@ - (void)windowDidFailToEnterFullScreen:(NSWindow *)window { _is_animating = 0; + [self setToWindow]; } - (void)windowDidFailToExitFullScreen:(NSWindow *)window { _is_animating = 0; + [self setToFullScreen]; } - (void)windowDidChangeBackingProperties:(NSNotification *)notification -- cgit v1.2.3