From 413a2b96e235bebb7f287c7eb9ebaa6f7bab20a0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 23 Apr 2025 13:16:01 +0530 Subject: [PATCH] Prevent background panel launch taking focus from key window --- glfw/cocoa_window.m | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index edd3d0647..509beaa1f 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1981,8 +1981,6 @@ _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig [nswindow setLevel:level]; [nswindow setCollectionBehavior: (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary | NSWindowCollectionBehaviorIgnoresCycle)]; [nswindow setFrame:NSMakeRect(x, y, width, height) display:YES animate:config.type != GLFW_LAYER_SHELL_BACKGROUND]; - if (config.type == GLFW_LAYER_SHELL_BACKGROUND) [nswindow orderBack:nil]; - else [nswindow orderFrontRegardless]; return true; #undef config #undef nswindow @@ -2181,11 +2179,10 @@ int _glfwPlatformWindowBell(_GLFWwindow* window UNUSED) void _glfwPlatformFocusWindow(_GLFWwindow* window) { // Make us the active application - // HACK: This is here to prevent applications using only hidden windows from - // being activated, but should probably not be done every time any - // window is shown - [NSApp activateIgnoringOtherApps:YES]; - [window->ns.object makeKeyAndOrderFront:nil]; + if ([window->ns.object canBecomeKeyWindow]) { + [NSApp activateIgnoringOtherApps:YES]; + [window->ns.object makeKeyAndOrderFront:nil]; + } } void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,