From 301dc8a73615fc29f29ee31f68a1362e7d3119a4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 12 Nov 2025 09:46:13 +0530 Subject: [PATCH] macOS: Ignore Tahoe zombie windows when cycling through windows with cmd+`. Fixes #9215 --- kitty/cocoa_window.m | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/kitty/cocoa_window.m b/kitty/cocoa_window.m index 9ec07e30b..9d20468bc 100644 --- a/kitty/cocoa_window.m +++ b/kitty/cocoa_window.m @@ -926,14 +926,20 @@ cocoa_toggle_secure_keyboard_entry(void) { void cocoa_cycle_through_os_windows(void) { - NSArray *windows = [NSApp orderedWindows]; - if (windows.count < 2) return; - + NSArray *allWindows = [NSApp orderedWindows]; + if (allWindows.count < 2) return; + NSMutableArray *filteredWindows = [NSMutableArray array]; + for (NSWindow *window in allWindows) { + NSRect windowFrame = [window frame]; + // Exclude zero size windows which are likely zombie windows from the Tahoe bug + if (windowFrame.size.width > 0 && windowFrame.size.height > 0) [filteredWindows addObject:window]; + } + if (filteredWindows.count < 2) return; NSWindow *keyWindow = [NSApp keyWindow]; - NSUInteger index = [windows indexOfObject:keyWindow]; - NSUInteger nextIndex = (index + 1) % windows.count; - - NSWindow *nextWindow = windows[nextIndex]; + NSUInteger index = [filteredWindows indexOfObject:keyWindow]; + if (index < 0) return; + NSUInteger nextIndex = (index + 1) % filteredWindows.count; + NSWindow *nextWindow = filteredWindows[nextIndex]; [nextWindow makeKeyAndOrderFront:nil]; }