From 7c14e0d66672aee258d27d5eed1b464b472289b1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 9 Feb 2024 15:32:09 +0530 Subject: [PATCH] macOS: Fix an abort when changing OS window chrome for a full screen window via remote control or the themes kitten Fixes #7106 --- docs/changelog.rst | 2 ++ glfw/cocoa_window.m | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b2a149d6d..f80970236 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -66,6 +66,8 @@ Detailed list of changes - hints kitten: Respect the kitty :opt:`url_excluded_characters` option (:iss:`7075`) +- macOS: Fix an abort when changing OS window chrome for a full screen window via remote control or the themes kitten (:iss:`7106`) + 0.32.1 [2024-01-26] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 938b6bac1..9fe090f49 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2292,6 +2292,7 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled UNUSED) { [window->ns.object setStyleMask:getStyleMask(window)]; + [window->ns.object makeFirstResponder:window->ns.view]; } void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, bool enabled UNUSED) @@ -3133,8 +3134,11 @@ GLFWAPI void glfwCocoaSetWindowChrome(GLFWwindow *w, unsigned int color, bool us [[window->ns.object standardWindowButton: NSWindowCloseButton] setHidden:hide_titlebar_buttons]; [[window->ns.object standardWindowButton: NSWindowMiniaturizeButton] setHidden:hide_titlebar_buttons]; [[window->ns.object standardWindowButton: NSWindowZoomButton] setHidden:hide_titlebar_buttons]; + // Apple throws a hissy fit if one attempts to clear the value of NSWindowStyleMaskFullScreen outside of a full screen transition + // event. See https://github.com/kovidgoyal/kitty/issues/7106 + NSWindowStyleMask fsmask = current_style_mask & NSWindowStyleMaskFullScreen; window->ns.pre_full_screen_style_mask = getStyleMask(window); - [window->ns.object setStyleMask:window->ns.pre_full_screen_style_mask]; + [window->ns.object setStyleMask:window->ns.pre_full_screen_style_mask | fsmask]; // HACK: Changing the style mask can cause the first responder to be cleared [window->ns.object makeFirstResponder:window->ns.view]; }}