This reverts commit 2bc85b2579
.
This commit is contained in:
parent
6516110c70
commit
a1edf5cf94
1 changed files with 5 additions and 34 deletions
|
@ -41,10 +41,7 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
||||||
@end
|
@end
|
||||||
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
|
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
|
||||||
|
|
||||||
@implementation ElectronApplicationDelegate {
|
@implementation ElectronApplicationDelegate
|
||||||
@private
|
|
||||||
bool isFirstActivation_;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setApplicationDockMenu:(electron::ElectronMenuModel*)model {
|
- (void)setApplicationDockMenu:(electron::ElectronMenuModel*)model {
|
||||||
menu_controller_.reset([[ElectronMenuController alloc] initWithModel:model
|
menu_controller_.reset([[ElectronMenuController alloc] initWithModel:model
|
||||||
|
@ -80,8 +77,6 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
||||||
@selector(_coreAttributesFromRange:whichAttributes:completionHandler:));
|
@selector(_coreAttributesFromRange:whichAttributes:completionHandler:));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
isFirstActivation_ = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMenu*)applicationDockMenu:(NSApplication*)sender {
|
- (NSMenu*)applicationDockMenu:(NSApplication*)sender {
|
||||||
|
@ -96,35 +91,11 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
|
||||||
return electron::Browser::Get()->OpenFile(filename_str) ? YES : NO;
|
return electron::Browser::Get()->OpenFile(filename_str) ? YES : NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidBecomeActive:(NSNotification*)notify {
|
- (BOOL)applicationShouldHandleReopen:(NSApplication*)theApplication
|
||||||
// Originally `applicationShouldHandleReopen:hasVisibleWindows:` was used to
|
hasVisibleWindows:(BOOL)flag {
|
||||||
// emit Activate event. But the message is sent only when application is
|
|
||||||
// activated via Dock or Finder ignoring the App Switcher (cmd+tab).
|
|
||||||
//
|
|
||||||
// Using `applicationDidBecomeActive' is more reliable but to maintain
|
|
||||||
// compatibility with previous implementation we ignore activation
|
|
||||||
// immediately after the application launch, and compute the
|
|
||||||
// hasVisibleWindows on our own.
|
|
||||||
//
|
|
||||||
// Details in https://github.com/electron/electron/pull/23727.
|
|
||||||
|
|
||||||
if (isFirstActivation_) {
|
|
||||||
isFirstActivation_ = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSApplication* app = notify.object;
|
|
||||||
bool hasVisibleWindows = false;
|
|
||||||
|
|
||||||
for (NSWindow* win in app.windows) {
|
|
||||||
if (win.isVisible || win.miniaturized) {
|
|
||||||
hasVisibleWindows = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
electron::Browser* browser = electron::Browser::Get();
|
electron::Browser* browser = electron::Browser::Get();
|
||||||
browser->Activate(hasVisibleWindows);
|
browser->Activate(static_cast<bool>(flag));
|
||||||
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)application:(NSApplication*)sender
|
- (BOOL)application:(NSApplication*)sender
|
||||||
|
|
Loading…
Reference in a new issue