Merge pull request #4843 from jwheare/mac-swipe-events
OSX: Expose 3-finger swipe events in browser-window
This commit is contained in:
commit
0e3737423b
7 changed files with 33 additions and 0 deletions
|
@ -248,6 +248,10 @@ void Window::OnWindowScrollTouchEnd() {
|
||||||
Emit("scroll-touch-end");
|
Emit("scroll-touch-end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::OnWindowSwipe(const std::string& direction) {
|
||||||
|
Emit("swipe", direction);
|
||||||
|
}
|
||||||
|
|
||||||
void Window::OnWindowEnterHtmlFullScreen() {
|
void Window::OnWindowEnterHtmlFullScreen() {
|
||||||
Emit("enter-html-full-screen");
|
Emit("enter-html-full-screen");
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
void OnWindowMoved() override;
|
void OnWindowMoved() override;
|
||||||
void OnWindowScrollTouchBegin() override;
|
void OnWindowScrollTouchBegin() override;
|
||||||
void OnWindowScrollTouchEnd() override;
|
void OnWindowScrollTouchEnd() override;
|
||||||
|
void OnWindowSwipe(const std::string& direction) override;
|
||||||
void OnWindowEnterFullScreen() override;
|
void OnWindowEnterFullScreen() override;
|
||||||
void OnWindowLeaveFullScreen() override;
|
void OnWindowLeaveFullScreen() override;
|
||||||
void OnWindowEnterHtmlFullScreen() override;
|
void OnWindowEnterHtmlFullScreen() override;
|
||||||
|
|
|
@ -480,6 +480,11 @@ void NativeWindow::NotifyWindowScrollTouchEnd() {
|
||||||
OnWindowScrollTouchEnd());
|
OnWindowScrollTouchEnd());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::NotifyWindowSwipe(const std::string& direction) {
|
||||||
|
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||||
|
OnWindowSwipe(direction));
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::NotifyWindowLeaveFullScreen() {
|
void NativeWindow::NotifyWindowLeaveFullScreen() {
|
||||||
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
FOR_EACH_OBSERVER(NativeWindowObserver, observers_,
|
||||||
OnWindowLeaveFullScreen());
|
OnWindowLeaveFullScreen());
|
||||||
|
|
|
@ -221,6 +221,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
void NotifyWindowMoved();
|
void NotifyWindowMoved();
|
||||||
void NotifyWindowScrollTouchBegin();
|
void NotifyWindowScrollTouchBegin();
|
||||||
void NotifyWindowScrollTouchEnd();
|
void NotifyWindowScrollTouchEnd();
|
||||||
|
void NotifyWindowSwipe(const std::string& direction);
|
||||||
void NotifyWindowEnterFullScreen();
|
void NotifyWindowEnterFullScreen();
|
||||||
void NotifyWindowLeaveFullScreen();
|
void NotifyWindowLeaveFullScreen();
|
||||||
void NotifyWindowEnterHtmlFullScreen();
|
void NotifyWindowEnterHtmlFullScreen();
|
||||||
|
|
|
@ -267,6 +267,18 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
|
|
||||||
// NSWindow overrides.
|
// NSWindow overrides.
|
||||||
|
|
||||||
|
- (void)swipeWithEvent:(NSEvent *)event {
|
||||||
|
if (event.deltaY == 1.0) {
|
||||||
|
shell_->NotifyWindowSwipe("up");
|
||||||
|
} else if (event.deltaX == -1.0) {
|
||||||
|
shell_->NotifyWindowSwipe("right");
|
||||||
|
} else if (event.deltaY == -1.0) {
|
||||||
|
shell_->NotifyWindowSwipe("down");
|
||||||
|
} else if (event.deltaX == 1.0) {
|
||||||
|
shell_->NotifyWindowSwipe("left");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {
|
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {
|
||||||
// Resizing is disabled.
|
// Resizing is disabled.
|
||||||
if (ScopedDisableResize::IsResizeDisabled())
|
if (ScopedDisableResize::IsResizeDisabled())
|
||||||
|
|
|
@ -58,6 +58,7 @@ class NativeWindowObserver {
|
||||||
virtual void OnWindowMoved() {}
|
virtual void OnWindowMoved() {}
|
||||||
virtual void OnWindowScrollTouchBegin() {}
|
virtual void OnWindowScrollTouchBegin() {}
|
||||||
virtual void OnWindowScrollTouchEnd() {}
|
virtual void OnWindowScrollTouchEnd() {}
|
||||||
|
virtual void OnWindowSwipe(const std::string& direction) {}
|
||||||
virtual void OnWindowEnterFullScreen() {}
|
virtual void OnWindowEnterFullScreen() {}
|
||||||
virtual void OnWindowLeaveFullScreen() {}
|
virtual void OnWindowLeaveFullScreen() {}
|
||||||
virtual void OnWindowEnterHtmlFullScreen() {}
|
virtual void OnWindowEnterHtmlFullScreen() {}
|
||||||
|
|
|
@ -322,6 +322,15 @@ Emitted when scroll wheel event phase has begun.
|
||||||
|
|
||||||
Emitted when scroll wheel event phase has ended.
|
Emitted when scroll wheel event phase has ended.
|
||||||
|
|
||||||
|
### Event: 'swipe' _OS X_
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
* `event` Event
|
||||||
|
* `direction` String
|
||||||
|
|
||||||
|
Emitted on 3-finger swipe. Possible directions are `up`, `right`, `down`, `left`.
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
The `BrowserWindow` object has the following methods:
|
The `BrowserWindow` object has the following methods:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue