macOS: Elaborate dance to work around yet another Cocoa bug

Fixes #8740
This commit is contained in:
Kovid Goyal 2025-08-18 16:01:51 +05:30
parent b8b7592b40
commit 3638adda6c
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 24 additions and 3 deletions

View file

@ -141,6 +141,10 @@ Detailed list of changes
- macOS: Fix hiding quick access terminal window not restoring focus to
previously active application (:disc:`8840`)
- macOS: Fix showing the quick access terminal on a space other than the space
it was last active on, after full screening some application causes the quick
access terminal to appear on the old space (:iss:`8740`)
- Allow using backspace to move the cursor onto the previous line in cooked mode. This is indicated by the `bw` property in kitty's terminfo (:iss:`8841`)
- Watchers: A new event for global watchers corresponding to the tab bar being changed (:disc:`8842`)

View file

@ -2229,9 +2229,26 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
void _glfwPlatformShowWindow(_GLFWwindow* window)
{
if (window->ns.layer_shell.is_active && window->ns.layer_shell.config.type == GLFW_LAYER_SHELL_BACKGROUND) {
[window->ns.object orderBack:nil];
} else [window->ns.object orderFront:nil];
const bool is_background = window->ns.layer_shell.is_active && window->ns.layer_shell.config.type == GLFW_LAYER_SHELL_BACKGROUND;
NSWindow *nw = window->ns.object;
if (is_background) {
[nw orderBack:nil];
} else {
// Cocoa has a bug where when showing a hidden window after
// fullscreening an application, the window does not get added
// to the current space even though it has NSWindowCollectionBehaviorCanJoinAllSpaces
// probably because it wasnt added to the temp space used for
// fullscreen. So to work around that, we change the collection
// behavior temporarily to NSWindowCollectionBehaviorMoveToActiveSpace
// and then change it back asynchronously.
// See https://github.com/kovidgoyal/kitty/issues/8740
NSWindowCollectionBehavior old = nw.collectionBehavior;
nw.collectionBehavior = (old & !NSWindowCollectionBehaviorCanJoinAllSpaces) | NSWindowCollectionBehaviorMoveToActiveSpace;
[nw orderFront:nil];
dispatch_async(dispatch_get_main_queue(), ^{
nw.collectionBehavior = old;
});
}
}
void _glfwPlatformHideWindow(_GLFWwindow* window)