mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 14:34:52 +02:00
macOS: Use a private API to ensure OS window is shown on the currently active space when toggled
Fixes #8740
This commit is contained in:
@@ -236,6 +236,8 @@ Detailed list of changes
|
||||
|
||||
- Add support for DECSTR soft screen reset escape code (:iss:`10263`)
|
||||
|
||||
- macOS: Fix quick-access-terminal appearing on the wrong space (the fullscreen app's space) when triggered from a different space on macOS Tahoe (:iss:`8740`)
|
||||
|
||||
0.47.4 [2026-06-15]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -3006,12 +3006,23 @@ void _glfwPlatformShowWindow(_GLFWwindow* window, bool move_to_active_screen)
|
||||
// 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.
|
||||
// fullscreen.
|
||||
// See https://github.com/kovidgoyal/kitty/issues/8740
|
||||
//
|
||||
// Work around this by explicitly assigning the window
|
||||
// to the current active space via the private CGS API before showing it.
|
||||
NSWindowCollectionBehavior old = nw.collectionBehavior;
|
||||
nw.collectionBehavior = (old & !NSWindowCollectionBehaviorCanJoinAllSpaces) | NSWindowCollectionBehaviorMoveToActiveSpace;
|
||||
nw.collectionBehavior = (old & ~NSWindowCollectionBehaviorCanJoinAllSpaces) | NSWindowCollectionBehaviorMoveToActiveSpace;
|
||||
extern int _CGSDefaultConnection(void);
|
||||
extern int CGSGetActiveSpace(int cid);
|
||||
extern void CGSAddWindowsToSpaces(int cid, CFArrayRef windows, CFArrayRef spaces);
|
||||
int cid = _CGSDefaultConnection();
|
||||
int activeSpace = CGSGetActiveSpace(cid);
|
||||
if (activeSpace > 0) {
|
||||
NSArray *windowArray = @[@([nw windowNumber])];
|
||||
NSArray *spaceArray = @[@(activeSpace)];
|
||||
CGSAddWindowsToSpaces(cid, (__bridge CFArrayRef)windowArray, (__bridge CFArrayRef)spaceArray);
|
||||
}
|
||||
[nw orderFront:nil];
|
||||
__block __typeof__(nw) weakSelf = nw;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
Reference in New Issue
Block a user