No need to use scoped_nsobject for id

This commit is contained in:
Cheng Zhao 2016-01-25 15:02:43 +08:00
parent 059d97e1aa
commit a83aee90e5
3 changed files with 23 additions and 11 deletions

View file

@ -126,7 +126,9 @@ class NativeWindowMac : public NativeWindow {
base::scoped_nsobject<AtomNSWindow> window_;
base::scoped_nsobject<AtomNSWindowDelegate> window_delegate_;
base::scoped_nsobject<id> event_monitor_;
// Event monitor for scroll wheel event.
id wheel_event_monitor_;
// The view that will fill the whole frameless window.
base::scoped_nsobject<FullSizeContentView> content_view_;

View file

@ -499,32 +499,34 @@ NativeWindowMac::NativeWindowMac(
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
[view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
BOOL __block down = NO;
event_monitor_.reset([[NSEvent
// Use an NSEvent monitor to listen for the wheel event.
BOOL __block began = NO;
wheel_event_monitor_ = [NSEvent
addLocalMonitorForEventsMatchingMask:NSScrollWheelMask
handler:^NSEvent * _Nullable(NSEvent * event) {
handler:^(NSEvent* event) {
if ([[event window] windowNumber] != [window_ windowNumber])
return event;
if (!web_contents)
return event;
if (!down && (([event phase] == NSEventPhaseMayBegin) || ([event phase] == NSEventPhaseBegan))) {
if (!began && (([event phase] == NSEventPhaseMayBegin) ||
([event phase] == NSEventPhaseBegan))) {
this->NotifyWindowScrollTouchBegin();
down = YES;
}
if (down && (([event phase] == NSEventPhaseEnded) || ([event phase] == NSEventPhaseCancelled))) {
began = YES;
} else if (began && (([event phase] == NSEventPhaseEnded) ||
([event phase] == NSEventPhaseCancelled))) {
this->NotifyWindowScrollTouchEnd();
down = NO;
began = NO;
}
return event;
}] retain]);
}];
InstallView();
}
NativeWindowMac::~NativeWindowMac() {
[NSEvent removeMonitor: event_monitor_.get()];
[NSEvent removeMonitor:wheel_event_monitor_];
Observe(nullptr);
}

View file

@ -307,6 +307,14 @@ someWindow.on('app-command', function(e, cmd) {
});
```
### Event: 'scroll-touch-begin' _OS X_
Emitted when scroll wheel event phase has begun.
### Event: 'scroll-touch-end' _OS X_
Emitted when scroll wheel event phase has ended.
## Methods
The `BrowserWindow` object has the following methods: