Use EventDispatchingWindow from brightray

This commit is contained in:
Kevin Sawicki 2016-06-17 10:58:04 -07:00
parent 3bc4f188ef
commit 0e65977a3c
4 changed files with 19 additions and 43 deletions

View file

@ -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];
}
}

View file

@ -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_

View file

@ -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

@ -1 +1 @@
Subproject commit 30b18de454d1c57818ffd9545556affb6f500061
Subproject commit 7e62baf17832736205a4136d182f1c9457281e89