macOS: Fix an abort when changing OS window chrome for a full screen window via remote control or the themes kitten

Fixes #7106
This commit is contained in:
Kovid Goyal 2024-02-09 15:32:09 +05:30
parent 62347d7e97
commit 7c14e0d666
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 1 deletions

View File

@ -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]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -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];
}}