diff --git a/glfw/cocoa_platform.h b/glfw/cocoa_platform.h index 08be21b5e..36b318e23 100644 --- a/glfw/cocoa_platform.h +++ b/glfw/cocoa_platform.h @@ -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; diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 16b24f71f..aee7b4661 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -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)];