Fix phantom window appears when executing full screen in transition

This commit is contained in:
pagedown 2022-02-17 15:47:03 +08:00
parent 7a156d5ef3
commit 6d0721341b
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB
2 changed files with 16 additions and 1 deletions

View File

@ -131,6 +131,7 @@ typedef struct _GLFWwindowNS
bool maximized;
bool retina;
bool in_traditional_fullscreen;
bool in_fullscreen_transition;
bool titlebar_hidden;
unsigned long pre_full_screen_style_mask;

View File

@ -722,6 +722,18 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
}
}
- (void)windowDidEnterFullScreen:(NSNotification *)notification
{
(void)notification;
window->ns.in_fullscreen_transition = false;
}
- (void)windowDidExitFullScreen:(NSNotification *)notification
{
(void)notification;
window->ns.in_fullscreen_transition = false;
}
@end // }}}
// Text input context class for the GLFW content view {{{
@ -1554,8 +1566,10 @@ void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
- (void)toggleFullScreen:(nullable id)sender
{
if (glfw_window->ns.in_fullscreen_transition) return;
if (glfw_window && glfw_window->ns.toggleFullscreenCallback && glfw_window->ns.toggleFullscreenCallback((GLFWwindow*)glfw_window) == 1)
return;
return;
glfw_window->ns.in_fullscreen_transition = true;
// When resizeIncrements is set, Cocoa cannot restore the original window size after returning from fullscreen.
const NSSize original = [self resizeIncrements];
[self setResizeIncrements:NSMakeSize(1.0, 1.0)];