fix: restore window event redispatching on mac (#27701)
This commit is contained in:
parent
b0a6eb6a53
commit
64eb02b671
1 changed files with 12 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue