Break out EventDispatchingWindow into separate class
This commit is contained in:
parent
df726d0f41
commit
8bee2d7b7f
4 changed files with 56 additions and 38 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include "browser/inspectable_web_contents_impl.h"
|
#include "browser/inspectable_web_contents_impl.h"
|
||||||
#include "browser/inspectable_web_contents_view_delegate.h"
|
#include "browser/inspectable_web_contents_view_delegate.h"
|
||||||
#include "browser/inspectable_web_contents_view_mac.h"
|
#include "browser/inspectable_web_contents_view_mac.h"
|
||||||
|
#include "browser/mac/event_dispatching_window.h"
|
||||||
|
|
||||||
#include "content/public/browser/render_widget_host_view.h"
|
#include "content/public/browser/render_widget_host_view.h"
|
||||||
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
||||||
|
@ -10,44 +11,6 @@
|
||||||
|
|
||||||
using namespace brightray;
|
using namespace brightray;
|
||||||
|
|
||||||
@interface EventDispatchingWindow : UnderlayOpenGLHostingWindow {
|
|
||||||
@private
|
|
||||||
BOOL redispatchingEvent_;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)redispatchKeyEvent:(NSEvent*)event;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation EventDispatchingWindow
|
|
||||||
|
|
||||||
- (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
|
|
||||||
|
|
||||||
@implementation BRYInspectableWebContentsView
|
@implementation BRYInspectableWebContentsView
|
||||||
|
|
||||||
- (instancetype)initWithInspectableWebContentsViewMac:(InspectableWebContentsViewMac*)view {
|
- (instancetype)initWithInspectableWebContentsViewMac:(InspectableWebContentsViewMac*)view {
|
||||||
|
|
19
brightray/browser/mac/event_dispatching_window.h
Normal file
19
brightray/browser/mac/event_dispatching_window.h
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright (c) 2016 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef BROWSER_EVENT_DISPATCHING_WINDOW_H_
|
||||||
|
#define BROWSER_EVENT_DISPATCHING_WINDOW_H_
|
||||||
|
|
||||||
|
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
||||||
|
|
||||||
|
@interface EventDispatchingWindow : UnderlayOpenGLHostingWindow {
|
||||||
|
@private
|
||||||
|
BOOL redispatchingEvent_;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)redispatchKeyEvent:(NSEvent*)event;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif // BROWSER_EVENT_DISPATCHING_WINDOW_H_
|
34
brightray/browser/mac/event_dispatching_window.mm
Normal file
34
brightray/browser/mac/event_dispatching_window.mm
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright (c) 2016 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "browser/mac/event_dispatching_window.h"
|
||||||
|
|
||||||
|
@implementation EventDispatchingWindow
|
||||||
|
|
||||||
|
- (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
|
|
@ -35,6 +35,8 @@
|
||||||
'browser/mac/bry_inspectable_web_contents_view.mm',
|
'browser/mac/bry_inspectable_web_contents_view.mm',
|
||||||
'browser/mac/cocoa_notification.h',
|
'browser/mac/cocoa_notification.h',
|
||||||
'browser/mac/cocoa_notification.mm',
|
'browser/mac/cocoa_notification.mm',
|
||||||
|
'browser/mac/event_dispatching_window.h',
|
||||||
|
'browser/mac/event_dispatching_window.mm',
|
||||||
'browser/mac/notification_center_delegate.h',
|
'browser/mac/notification_center_delegate.h',
|
||||||
'browser/mac/notification_center_delegate.mm',
|
'browser/mac/notification_center_delegate.mm',
|
||||||
'browser/mac/notification_presenter_mac.h',
|
'browser/mac/notification_presenter_mac.h',
|
||||||
|
|
Loading…
Add table
Reference in a new issue