#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"
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];
}
}
} // 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_
#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"
@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 {
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