mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: Do not activate app when calling focus on inactive panel window (#40307)
* fix: Do not activate app when calling focus on inactive panel window * Use activate * Use "activate" for all windows
This commit is contained in:
@@ -469,7 +469,20 @@ void NativeWindowMac::Focus(bool focus) {
|
||||
return;
|
||||
|
||||
if (focus) {
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:NO];
|
||||
// On macOS < Sonoma, "activateIgnoringOtherApps:NO" would not
|
||||
// activate apps if focusing a window that is inActive. That
|
||||
// changed with macOS Sonoma.
|
||||
//
|
||||
// There's a slim chance we should have never called
|
||||
// activateIgnoringOtherApps, but we tried that many years ago
|
||||
// and saw weird focus bugs on other macOS versions. So, to make
|
||||
// this safe, we're gating by versions.
|
||||
if (@available(macOS 14.0, *)) {
|
||||
[[NSApplication sharedApplication] activate];
|
||||
} else {
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:NO];
|
||||
}
|
||||
|
||||
[window_ makeKeyAndOrderFront:nil];
|
||||
} else {
|
||||
[window_ orderOut:nil];
|
||||
|
||||
Reference in New Issue
Block a user