macos: prohibit fullscreen transition if in transtion

This prevents performing additional fullscreen transitions while
a transition is already in progress.
This commit is contained in:
sumibi-yakitori 2022-04-03 22:14:52 +00:00 committed by Christian Hergert
parent d1ce514260
commit 146bb70c2e
3 changed files with 19 additions and 6 deletions

View File

@ -171,6 +171,11 @@ typedef NSString *CALayerContentsGravity;
return inMove; return inMove;
} }
- (BOOL)inFullscreenTransition;
{
return inFullscreenTransition;
}
-(void)checkSendEnterNotify -(void)checkSendEnterNotify
{ {
/* When a new window has been created, and the mouse is in the window /* When a new window has been created, and the mouse is in the window
@ -759,31 +764,37 @@ typedef NSString *CALayerContentsGravity;
-(void)windowWillEnterFullScreen:(NSNotification *)aNotification -(void)windowWillEnterFullScreen:(NSNotification *)aNotification
{ {
inFullscreenTransition = YES;
lastUnfullscreenFrame = [self frame]; lastUnfullscreenFrame = [self frame];
} }
-(void)windowDidEnterFullScreen:(NSNotification *)aNotification -(void)windowDidEnterFullScreen:(NSNotification *)aNotification
{ {
inFullscreenTransition = NO;
initialPositionKnown = NO; initialPositionKnown = NO;
[self checkSendEnterNotify]; [self checkSendEnterNotify];
} }
-(void)windowWillExitFullScreen:(NSNotification *)aNotification -(void)windowWillExitFullScreen:(NSNotification *)aNotification
{ {
inFullscreenTransition = YES;
} }
-(void)windowDidExitFullScreen:(NSNotification *)aNotification -(void)windowDidExitFullScreen:(NSNotification *)aNotification
{ {
inFullscreenTransition = NO;
initialPositionKnown = NO; initialPositionKnown = NO;
[self checkSendEnterNotify]; [self checkSendEnterNotify];
} }
-(void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification -(void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification
{ {
inFullscreenTransition = NO;
} }
-(void)windowDidFailToExitFullScreen:(NSNotification *)aNotification -(void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
{ {
inFullscreenTransition = NO;
} }
-(void)windowDidChangeScreen:(NSNotification *)aNotification -(void)windowDidChangeScreen:(NSNotification *)aNotification

View File

@ -53,6 +53,7 @@
NSRect lastMaximizedFrame; NSRect lastMaximizedFrame;
NSRect lastUnfullscreenFrame; NSRect lastUnfullscreenFrame;
BOOL inMaximizeTransition; BOOL inMaximizeTransition;
BOOL inFullscreenTransition;
} }
-(void)beginManualMove; -(void)beginManualMove;
@ -70,5 +71,6 @@
-(void)setDecorated:(BOOL)decorated; -(void)setDecorated:(BOOL)decorated;
-(void)swapBuffer:(GdkMacosBuffer *)buffer withDamage:(const cairo_region_t *)damage; -(void)swapBuffer:(GdkMacosBuffer *)buffer withDamage:(const cairo_region_t *)damage;
-(BOOL)needsMouseDownQuirk; -(BOOL)needsMouseDownQuirk;
-(BOOL)inFullscreenTransition;
@end @end

View File

@ -33,26 +33,26 @@
static void static void
_gdk_macos_toplevel_surface_fullscreen (GdkMacosToplevelSurface *self) _gdk_macos_toplevel_surface_fullscreen (GdkMacosToplevelSurface *self)
{ {
NSWindow *window; GdkMacosWindow *window;
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self)); g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
window = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self)); window = (GdkMacosWindow *)_gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
if (([window styleMask] & NSWindowStyleMaskFullScreen) == 0) if (![window inFullscreenTransition] && ([window styleMask] & NSWindowStyleMaskFullScreen) == 0)
[window toggleFullScreen:window]; [window toggleFullScreen:window];
} }
static void static void
_gdk_macos_toplevel_surface_unfullscreen (GdkMacosToplevelSurface *self) _gdk_macos_toplevel_surface_unfullscreen (GdkMacosToplevelSurface *self)
{ {
NSWindow *window; GdkMacosWindow *window;
g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self)); g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
window = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self)); window = (GdkMacosWindow *)_gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
if (([window styleMask] & NSWindowStyleMaskFullScreen) != 0) if (![window inFullscreenTransition] && ([window styleMask] & NSWindowStyleMaskFullScreen) != 0)
[window toggleFullScreen:window]; [window toggleFullScreen:window];
} }