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
This commit is contained in:
Akemi 2017-01-14 21:12:16 +01:00
parent 4fe45fb3a1
commit 202f9b218a
1 changed files with 20 additions and 8 deletions

View File

@ -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