Use EventDispatchingWindow from brightray
authorKevin Sawicki <kevinsawicki@gmail.com>
Fri, 17 Jun 2016 17:58:04 +0000 (10:58 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Fri, 17 Jun 2016 18:11:50 +0000 (11:11 -0700)
atom/browser/common_web_contents_delegate_mac.mm
atom/browser/native_window_mac.h
atom/browser/native_window_mac.mm
vendor/brightray

index 7b17c22..39ba3cf 100644 (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];
   }
 }
 
index 6a954aa..899043f 100644 (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_
index a0b58d0..c103108 100644 (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
index 30b18de..7e62baf 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 30b18de454d1c57818ffd9545556affb6f500061
+Subproject commit 7e62baf17832736205a4136d182f1c9457281e89