mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 02:02:14 +02:00
macOS: Quick access terminal: Restore focus to previously active window when hiding the quick access terminal window
Fixes #8627
This commit is contained in:
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)
|
||||
|
||||
Reference in New Issue
Block a user