File tree Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,9 @@ Detailed list of changes
115115- Wayland: Fix incorrect window size calculation when transitioning from
116116 fullscreen to non-fullscreen with client side decorations (:iss: `8826 `)
117117
118+ - macOS: Fix hiding quick access terminal window not restoring focus to
119+ previously active application (:disc: `8840 `)
120+
1181210.42.2 [2025-07-16]
119122~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120123
Original file line number Diff line number Diff line change @@ -301,6 +301,14 @@ @interface GLFWApplicationDelegate : NSObject <NSApplicationDelegate>
301301
302302@implementation GLFWApplicationDelegate
303303
304+ - (void )applicationDidActivate : (NSNotification *)notification {
305+ NSRunningApplication *app = notification.userInfo [NSWorkspaceApplicationKey ];
306+ if (app && app.processIdentifier != getpid ()) {
307+ _glfw.ns .previous_front_most_application = app.processIdentifier ;
308+ debug_rendering (" Front most application changed to: %s pid: %d \n " , app.bundleIdentifier .UTF8String , app.processIdentifier )
309+ }
310+ }
311+
304312- (NSApplicationTerminateReply )applicationShouldTerminate : (NSApplication *)sender
305313{
306314 (void )sender;
@@ -452,6 +460,7 @@ - (void)render_frame_received:(id)displayIDAsID
452460 CGDirectDisplayID displayID = [(NSNumber *)displayIDAsID unsignedIntValue ];
453461 _glfwDispatchRenderFrame (displayID);
454462}
463+
455464@end
456465
457466
@@ -816,6 +825,11 @@ int _glfwPlatformInit(bool *supports_window_occlusion)
816825 }
817826
818827 [NSApp setDelegate: _glfw.ns.delegate];
828+ [[[NSWorkspace sharedWorkspace ] notificationCenter ]
829+ addObserver: _glfw.ns.delegate
830+ selector: @selector (applicationDidActivate: )
831+ name: NSWorkspaceDidActivateApplicationNotification
832+ object: nil ];
819833 static struct {
820834 unsigned short virtual_key_code;
821835 NSEventModifierFlags input_source_switch_modifiers;
Original file line number Diff line number Diff line change @@ -125,7 +125,6 @@ typedef struct _GLFWwindowNS
125125 id delegate;
126126 id view;
127127 id layer;
128- pid_t previous_front_most_application;
129128
130129 bool maximized;
131130 bool retina;
@@ -189,6 +188,7 @@ typedef struct _GLFWlibraryNS
189188 double restoreCursorPosX, restoreCursorPosY;
190189 // The window whose disabled cursor mode is active
191190 _GLFWwindow* disabledCursorWindow;
191+ pid_t previous_front_most_application;
192192
193193 struct {
194194 CFBundleRef bundle;
Original file line number Diff line number Diff line change @@ -2228,20 +2228,15 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
22282228
22292229void _glfwPlatformShowWindow (_GLFWwindow* window)
22302230{
2231- NSRunningApplication *app = [[NSWorkspace sharedWorkspace ] frontmostApplication ];
2232- window->ns .previous_front_most_application = 0 ;
2233- if (app && app.processIdentifier != getpid ()) window->ns .previous_front_most_application = app.processIdentifier ;
22342231 if (window->ns .layer_shell .is_active && window->ns .layer_shell .config .type == GLFW_LAYER_SHELL_BACKGROUND) {
22352232 [window->ns.object orderBack: nil ];
22362233 } else [window->ns.object orderFront: nil ];
2237- debug (" Previously active application pid: %d bundle identifier: %s \n " ,
2238- window->ns .previous_front_most_application , app ? app.bundleIdentifier .UTF8String : " " );
22392234}
22402235
22412236void _glfwPlatformHideWindow (_GLFWwindow* window)
22422237{
22432238 [window->ns.object orderOut: nil ];
2244- pid_t prev_app_pid = window-> ns .previous_front_most_application ; window-> ns .previous_front_most_application = 0 ;
2239+ pid_t prev_app_pid = _glfw. ns .previous_front_most_application ; _glfw. ns .previous_front_most_application = 0 ;
22452240 NSRunningApplication *app;
22462241 if (window->ns .layer_shell .is_active && prev_app_pid > 0 && (app = [NSRunningApplication runningApplicationWithProcessIdentifier: prev_app_pid])) {
22472242 unsigned num_visible = 0 ;
You can’t perform that action at this time.
0 commit comments