diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 91368304b2..4d8134cfcc 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -16,6 +16,7 @@ #include "atom/common/native_mate_converters/value_converter.h" #include "atom/common/options_switches.h" #include "base/command_line.h" +#include "base/values.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" @@ -274,8 +275,13 @@ void Window::OnWindowScrollTouchEnd() { Emit("scroll-touch-end"); } -void Window::OnWindowScrollTouchEdge() { - Emit("scroll-touch-edge"); +void Window::OnWindowScrollTouchEdge(const blink::WebGestureEvent& event) { + base::DictionaryValue dict; + dict.SetDouble("deltaX", event.data.scroll_update.delta_x); + dict.SetDouble("deltaY", event.data.scroll_update.delta_y); + dict.SetDouble("velocityX", event.data.scroll_update.velocity_x); + dict.SetDouble("velocityY", event.data.scroll_update.velocity_y); + Emit("scroll-touch-edge", dict); } void Window::OnWindowSwipe(const std::string& direction) { diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 993b97381e..5cfd633603 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -80,7 +80,7 @@ class Window : public mate::TrackableObject, void OnWindowMoved() override; void OnWindowScrollTouchBegin() override; void OnWindowScrollTouchEnd() override; - void OnWindowScrollTouchEdge() override; + void OnWindowScrollTouchEdge(const blink::WebGestureEvent&) override; void OnWindowSwipe(const std::string& direction) override; void OnWindowEnterFullScreen() override; void OnWindowLeaveFullScreen() override; diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 1badaa67e4..5eba503a00 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -521,9 +521,10 @@ void NativeWindow::NotifyWindowScrollTouchEnd() { observer.OnWindowScrollTouchEnd(); } -void NativeWindow::NotifyWindowScrollTouchEdge() { +void NativeWindow::NotifyWindowScrollTouchEdge( + const blink::WebGestureEvent& event) { for (NativeWindowObserver& observer : observers_) - observer.OnWindowScrollTouchEdge(); + observer.OnWindowScrollTouchEdge(event); } void NativeWindow::NotifyWindowSwipe(const std::string& direction) { diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 186f3b3561..30e79cec7c 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -21,6 +21,7 @@ #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" #include "extensions/browser/app_window/size_constraints.h" +#include "third_party/blink/public/platform/web_gesture_event.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_skia.h" @@ -219,7 +220,7 @@ class NativeWindow : public base::SupportsUserData, void NotifyWindowMoved(); void NotifyWindowScrollTouchBegin(); void NotifyWindowScrollTouchEnd(); - void NotifyWindowScrollTouchEdge(); + void NotifyWindowScrollTouchEdge(const blink::WebGestureEvent&); void NotifyWindowSwipe(const std::string& direction); void NotifyWindowEnterFullScreen(); void NotifyWindowLeaveFullScreen(); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index cb9dfe8d41..97b282ff94 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -1205,11 +1205,13 @@ void ClearControlRegions(NSView* view) { void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) { switch (event.GetType()) { - case blink::WebInputEvent::kGestureScrollBegin: case blink::WebInputEvent::kGestureScrollUpdate: - case blink::WebInputEvent::kGestureScrollEnd: - this->NotifyWindowScrollTouchEdge(); - break; + { + const blink::WebGestureEvent& gesture_event = + static_cast(event); + this->NotifyWindowScrollTouchEdge(gesture_event); + break; + } default: break; } diff --git a/atom/browser/native_window_observer.h b/atom/browser/native_window_observer.h index 42d6b0287f..33aafa1019 100644 --- a/atom/browser/native_window_observer.h +++ b/atom/browser/native_window_observer.h @@ -15,6 +15,10 @@ #include #endif +namespace blink { +class WebGestureEvent; +} + namespace atom { class NativeWindowObserver { @@ -64,7 +68,7 @@ class NativeWindowObserver { virtual void OnWindowMoved() {} virtual void OnWindowScrollTouchBegin() {} virtual void OnWindowScrollTouchEnd() {} - virtual void OnWindowScrollTouchEdge() {} + virtual void OnWindowScrollTouchEdge(const blink::WebGestureEvent&) {} virtual void OnWindowSwipe(const std::string& direction) {} virtual void OnWindowEnterFullScreen() {} virtual void OnWindowLeaveFullScreen() {}