mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 01:08:10 +02:00
Fix macOS keyboard focus not restored when switching back from another space
Fixes #9665 Fixes #9666
This commit is contained in:
committed by
Kovid Goyal
parent
b3b7d0596d
commit
66ffb6895c
@@ -311,6 +311,24 @@ static NSDictionary<NSString*,NSNumber*> *global_shortcuts = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)notification {
|
||||
(void)notification;
|
||||
// When the application becomes active after switching spaces (e.g., swiping
|
||||
// back from a fullscreen app on another space), macOS may not send
|
||||
// windowDidBecomeKey: for the already-key window. This leaves GLFW thinking
|
||||
// no window has focus (since windowDidResignKey: was sent when leaving).
|
||||
// Ensure GLFW's focus state is updated to match the actual key window.
|
||||
NSWindow *keyWindow = [NSApp keyWindow];
|
||||
if (keyWindow && !_glfw.focusedWindowId) {
|
||||
for (_GLFWwindow *window = _glfw.windowListHead; window; window = window->next) {
|
||||
if (window->ns.object == keyWindow) {
|
||||
if (_glfw.focusedWindowId != window->id) _glfwInputWindowFocus(window, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
(void)sender;
|
||||
|
||||
Reference in New Issue
Block a user