From c41b65af9745854cfd46629f25b3de75086c8600 Mon Sep 17 00:00:00 2001 From: pagedown Date: Sun, 12 Feb 2023 13:45:27 +0800 Subject: [PATCH] macOS: Update window button visibility after toggling full screen --- docs/changelog.rst | 2 ++ glfw/cocoa_window.m | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5311dc73c..d8cea1171 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -50,6 +50,8 @@ Detailed list of changes - Linux: Reduce minimum required OpenGL version from 3.3 to 3.1 + extensions (:iss:`2790`) +- macOS: Fix the window buttons not being hidden after exiting the traditional full screen (:iss:`6009`) + 0.27.1 [2023-02-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 1a750f952..390983694 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2568,6 +2568,19 @@ bool _glfwPlatformToggleFullscreen(_GLFWwindow* w, unsigned int flags) { if (in_fullscreen) made_fullscreen = false; [window toggleFullScreen: nil]; } + // Update window button visibility + if (w->ns.titlebar_hidden) { + // The hidden buttons might be automatically reset to be visible after going full screen + // to show up in the auto-hide title bar, so they need to be set back to hidden. + BOOL button_hidden = YES; + // When title bar is configured to be hidden, it should be shown with buttons (auto-hide) after going to full screen. + if (!traditional) { + button_hidden = (BOOL) !made_fullscreen; + } + [[window standardWindowButton: NSWindowCloseButton] setHidden:button_hidden]; + [[window standardWindowButton: NSWindowMiniaturizeButton] setHidden:button_hidden]; + [[window standardWindowButton: NSWindowZoomButton] setHidden:button_hidden]; + } return made_fullscreen; }