macOS: Quick access terminal: Restore focus to previously active window when hiding the quick access terminal window
Fixes #8627
This commit is contained in:
parent
eab298683d
commit
064bc963a8
3 changed files with 20 additions and 0 deletions
|
|
@ -111,6 +111,8 @@ Detailed list of changes
|
|||
|
||||
- Fix ambiguous width and private use characters not being rendered when used with variable width text-sizing protocol escape codes
|
||||
|
||||
- macOS: Quick access terminal: Restore focus to previously active window when hiding the quick access terminal window (:iss:`8627`)
|
||||
|
||||
0.42.0 [2025-05-11]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
|||
1
glfw/cocoa_platform.h
vendored
1
glfw/cocoa_platform.h
vendored
|
|
@ -125,6 +125,7 @@ typedef struct _GLFWwindowNS
|
|||
id delegate;
|
||||
id view;
|
||||
id layer;
|
||||
pid_t previous_front_most_application;
|
||||
|
||||
bool maximized;
|
||||
bool retina;
|
||||
|
|
|
|||
|
|
@ -2201,14 +2201,31 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
|||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
{
|
||||
NSRunningApplication *app = [[NSWorkspace sharedWorkspace] frontmostApplication];
|
||||
window->ns.previous_front_most_application = 0;
|
||||
if (app && app.processIdentifier != getpid()) window->ns.previous_front_most_application = app.processIdentifier;
|
||||
if (window->ns.layer_shell.is_active && window->ns.layer_shell.config.type == GLFW_LAYER_SHELL_BACKGROUND) {
|
||||
[window->ns.object orderBack:nil];
|
||||
} else [window->ns.object orderFront:nil];
|
||||
debug("Previously active application pid: %d bundle identifier: %s\n", window->ns.previous_front_most_application,
|
||||
window->ns.previous_front_most_application ? [NSRunningApplication runningApplicationWithProcessIdentifier:window->ns.previous_front_most_application].bundleIdentifier.UTF8String : "");
|
||||
}
|
||||
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
{
|
||||
[window->ns.object orderOut:nil];
|
||||
pid_t prev_app_pid = window->ns.previous_front_most_application; window->ns.previous_front_most_application = 0;
|
||||
NSRunningApplication *app;
|
||||
if (window->ns.layer_shell.is_active && prev_app_pid > 0 && (app = [NSRunningApplication runningApplicationWithProcessIdentifier:prev_app_pid])) {
|
||||
unsigned num_visible = 0;
|
||||
for (_GLFWwindow *w = _glfw.windowListHead; w; w = w->next) {
|
||||
if (_glfwPlatformWindowVisible(w)) num_visible++;
|
||||
}
|
||||
if (!num_visible) {
|
||||
[NSApp yieldActivationToApplication: app];
|
||||
[app activateWithOptions:0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window UNUSED)
|
||||
|
|
|
|||
Loading…
Reference in a new issue