From 0965fc45f2fbac06649b1d7ed4fda5ab66dbbecc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 13 Nov 2021 14:20:18 +0530 Subject: [PATCH] macOS: Fix keyboard input not working after toggling traditional fullscreen till the window is clicked in --- docs/changelog.rst | 3 +++ glfw/cocoa_init.m | 2 +- glfw/cocoa_window.m | 5 ++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index f25a0e203..5d24abe58 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -143,6 +143,9 @@ To update |kitty|, :doc:`follow the instructions `. - When remembering OS window sizes for full screen windows use the size before the window became fullscreen (:iss:`4221`) +- macOS: Fix keyboard input not working after toggling traditional fullscreen + till the window is clicked in + 0.23.1 [2021-08-17] ---------------------- diff --git a/glfw/cocoa_init.m b/glfw/cocoa_init.m index 6b4f0b78c..72fd24ec5 100644 --- a/glfw/cocoa_init.m +++ b/glfw/cocoa_init.m @@ -470,7 +470,7 @@ is_modified_tab(NSEvent *event, NSEventModifierFlags modifierFlags) { // ctrl+whatever+tab, option+cmd+tab if ( ( - (modifierFlags & NSEventModifierFlagControl) || + (modifierFlags & NSEventModifierFlagControl) || modifierFlags == (NSEventModifierFlagOption | NSEventModifierFlagCommand) ) && [event.charactersIgnoringModifiers isEqualToString:@"\t"] ) return true; diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 6b925df90..e673d8c95 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2464,9 +2464,6 @@ bool _glfwPlatformToggleFullscreen(_GLFWwindow* w, unsigned int flags) { [[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationDefault]; w->ns.in_traditional_fullscreen = false; } - // At this point keyboard input does not work even though isKeyWindow returns true - // Calling makeKeyAndOrderFront also has no effect. Neither does calling becomeKeyWindow - // Calling them after an interval with performSelector also has no effect } else { bool in_fullscreen = sm & NSWindowStyleMaskFullScreen; if (!(in_fullscreen)) { @@ -2479,6 +2476,8 @@ bool _glfwPlatformToggleFullscreen(_GLFWwindow* w, unsigned int flags) { } [window setStyleMask: sm]; } + // Changing the style mask causes the first responder to be cleared + [window makeFirstResponder:w->ns.view]; // If the dock and menubar are hidden going from maximized to fullscreen doesnt change the window size // and macOS forgets to trigger windowDidResize, so call it ourselves NSNotification *notification = [NSNotification notificationWithName:NSWindowDidResizeNotification object:window];