Add interface and Mac implementation for responsiveness::NativeEventObserver.
1157235
/
This commit is contained in:
parent
4089620729
commit
374406375b
1 changed files with 21 additions and 0 deletions
|
@ -8,8 +8,11 @@
|
|||
#import "atom/browser/mac/atom_application_delegate.h"
|
||||
#include "atom/browser/mac/dict_util.h"
|
||||
#include "base/auto_reset.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "content/public/browser/browser_accessibility_state.h"
|
||||
#include "content/public/browser/native_event_processor_mac.h"
|
||||
#include "content/public/browser/native_event_processor_observer_mac.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -22,6 +25,12 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
|||
|
||||
} // namespace
|
||||
|
||||
@interface AtomApplication () <NativeEventProcessor> {
|
||||
base::ObserverList<content::NativeEventProcessorObserver>::Unchecked
|
||||
observers_;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation AtomApplication
|
||||
|
||||
+ (AtomApplication*)sharedApplication {
|
||||
|
@ -48,6 +57,8 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
|||
|
||||
- (void)sendEvent:(NSEvent*)event {
|
||||
base::AutoReset<BOOL> scoper(&handlingSendEvent_, YES);
|
||||
content::ScopedNotifyNativeEventProcessorObserver scopedObserverNotifier(
|
||||
&observers_, event);
|
||||
[super sendEvent:event];
|
||||
}
|
||||
|
||||
|
@ -188,4 +199,14 @@ inline void dispatch_sync_main(dispatch_block_t block) {
|
|||
atom::Browser::Get()->ShowAboutPanel();
|
||||
}
|
||||
|
||||
- (void)addNativeEventProcessorObserver:
|
||||
(content::NativeEventProcessorObserver*)observer {
|
||||
observers_.AddObserver(observer);
|
||||
}
|
||||
|
||||
- (void)removeNativeEventProcessorObserver:
|
||||
(content::NativeEventProcessorObserver*)observer {
|
||||
observers_.RemoveObserver(observer);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue