diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-01-11 20:43:29 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-01-11 23:25:12 +0200 |
commit | 927105692fe42fb0192a190f20e662c94060194c (patch) | |
tree | 5e98499373015f6c99516aee81e755603700c318 /platform/osx | |
parent | b6bdbd2650f48a1c98040317a857786680a6f203 (diff) |
[macOS] Improve window activation hack.
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/os_osx.mm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 7d07b0076b..821036de9c 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -82,9 +82,9 @@ @implementation GodotApplicationDelegate - (void)forceUnbundledWindowActivationHackStep1 { - // Step1: Switch focus to macOS Dock. + // Step 1: Switch focus to macOS SystemUIServer process. // Required to perform step 2, TransformProcessType will fail if app is already the in focus. - for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) { + for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.systemuiserver"]) { [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; break; } @@ -107,8 +107,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notice { NSString *nsappname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; - if (nsappname == nil) { - // If executable is not a bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored). + if (nsappname == nil || isatty(STDOUT_FILENO) || isatty(STDIN_FILENO) || isatty(STDERR_FILENO)) { + // If the executable is started from terminal or is not bundled, macOS WindowServer won't register and activate app window correctly (menu and title bar are grayed out and input ignored). [self performSelector:@selector(forceUnbundledWindowActivationHackStep1) withObject:nil afterDelay:0.02]; } } |