mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Use EventDispatchingWindow from brightray
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "atom/browser/native_window_mac.h"
|
||||
#include "brightray/browser/mac/event_dispatching_window.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "ui/events/keycodes/keyboard_codes.h"
|
||||
|
||||
@@ -24,8 +24,9 @@ void CommonWebContentsDelegate::HandleKeyboardEvent(
|
||||
ExitFullscreenModeForTab(source);
|
||||
|
||||
NSWindow* window = event.os_event.window;
|
||||
if ([window respondsToSelector:@selector(redispatchKeyEvent:)]) {
|
||||
[(id)window redispatchKeyEvent:event.os_event];
|
||||
if (window && [window isKindOfClass:[EventDispatchingWindow class]]) {
|
||||
EventDispatchingWindow* native_window = static_cast<EventDispatchingWindow*>(window);
|
||||
[native_window redispatchKeyEvent:event.os_event];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,19 +152,4 @@ class NativeWindowMac : public NativeWindow {
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@interface AtomNSWindow : NSWindow {
|
||||
@private
|
||||
atom::NativeWindowMac* shell_;
|
||||
bool enable_larger_than_screen_;
|
||||
BOOL redispatchingEvent_;
|
||||
}
|
||||
@property BOOL acceptsFirstMouse;
|
||||
@property BOOL disableAutoHideCursor;
|
||||
@property BOOL disableKeyOrMainWindow;
|
||||
|
||||
- (void)setShell:(atom::NativeWindowMac*)shell;
|
||||
- (void)setEnableLargerThanScreen:(bool)enable;
|
||||
- (void)redispatchKeyEvent:(NSEvent*)event;
|
||||
@end
|
||||
|
||||
#endif // ATOM_BROWSER_NATIVE_WINDOW_MAC_H_
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "brightray/browser/mac/event_dispatching_window.h"
|
||||
#include "content/public/browser/browser_accessibility_state.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
@@ -270,6 +271,19 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
|
||||
@end
|
||||
|
||||
@interface AtomNSWindow : EventDispatchingWindow {
|
||||
@private
|
||||
atom::NativeWindowMac* shell_;
|
||||
bool enable_larger_than_screen_;
|
||||
}
|
||||
@property BOOL acceptsFirstMouse;
|
||||
@property BOOL disableAutoHideCursor;
|
||||
@property BOOL disableKeyOrMainWindow;
|
||||
|
||||
- (void)setShell:(atom::NativeWindowMac*)shell;
|
||||
- (void)setEnableLargerThanScreen:(bool)enable;
|
||||
@end
|
||||
|
||||
@implementation AtomNSWindow
|
||||
|
||||
- (void)setShell:(atom::NativeWindowMac*)shell {
|
||||
@@ -334,30 +348,6 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||
return !self.disableKeyOrMainWindow;
|
||||
}
|
||||
|
||||
- (void)sendEvent:(NSEvent*)event {
|
||||
if (!redispatchingEvent_)
|
||||
[super sendEvent:event];
|
||||
}
|
||||
|
||||
- (BOOL)performKeyEquivalent:(NSEvent*)event {
|
||||
if (redispatchingEvent_)
|
||||
return NO;
|
||||
else
|
||||
return [super performKeyEquivalent:event];
|
||||
}
|
||||
|
||||
- (void)redispatchKeyEvent:(NSEvent*)event {
|
||||
NSEventType eventType = [event type];
|
||||
if (eventType != NSKeyDown && eventType != NSKeyUp &&
|
||||
eventType != NSFlagsChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Redispatch the event.
|
||||
redispatchingEvent_ = YES;
|
||||
[NSApp sendEvent:event];
|
||||
redispatchingEvent_ = NO;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface ControlRegionView : NSView
|
||||
|
||||
2
vendor/brightray
vendored
2
vendor/brightray
vendored
Submodule vendor/brightray updated: 30b18de454...7e62baf178
Reference in New Issue
Block a user