mirror of https://github.com/mpv-player/mpv
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:
parent
4fe45fb3a1
commit
202f9b218a
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue