fix: restore window event redispatching on mac (#27769)

Co-authored-by: clavin <cwatford@slack-corp.com>
This commit is contained in:
trop[bot]
2021-02-19 15:41:35 +09:00
committed by GitHub
parent 1b6e3596f2
commit 84a4a7a944

View File

@@ -6,6 +6,7 @@
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
#include "shell/browser/web_contents_preferences.h"
#include "ui/base/cocoa/command_dispatcher.h"
#include "ui/events/keycodes/keyboard_codes.h"
#import <Cocoa/Cocoa.h>
@@ -58,6 +59,7 @@ bool WebContents::PlatformHandleKeyboardEvent(
[[NSApp mainMenu] performKeyEquivalent:event.os_event])
return true;
// Let the window redispatch the OS event
if (event.os_event.window &&
[event.os_event.window isKindOfClass:[EventDispatchingWindow class]]) {
[event.os_event.window redispatchKeyEvent:event.os_event];
@@ -65,6 +67,16 @@ bool WebContents::PlatformHandleKeyboardEvent(
// devtools windows as Widgets in order to take advantage of the
// pre-existing redispatch code in bridged_native_widget.
return false;
} else if (event.os_event.window &&
[event.os_event.window
conformsToProtocol:@protocol(CommandDispatchingWindow)]) {
NSObject<CommandDispatchingWindow>* window =
static_cast<NSObject<CommandDispatchingWindow>*>(event.os_event.window);
[[window commandDispatcher] redispatchKeyEvent:event.os_event];
// FIXME(clavin): Not exactly sure what to return here, likely the same
// situation as the branch above. If a future refactor removes
// |EventDispatchingWindow| then only this branch will need to remain.
return false;
}
return false;