Title: [245065] trunk/Source/WebKit
- Revision
- 245065
- Author
- [email protected]
- Date
- 2019-05-08 13:28:22 -0700 (Wed, 08 May 2019)
Log Message
[GTK] Support navigation gesture on touchscreens
https://bugs.webkit.org/show_bug.cgi?id=197690
Patch by Alexander Mikhaylenko <[email protected]> on 2019-05-08
Reviewed by Michael Catanzaro.
Touch events generate scroll events that are handled in webkitWebViewBaseHandleWheelEvent(),
bypassing webkitWebViewBaseScrollEvent(). Because of that, ViewGestureController never receives
them. Hence pass scroll events to ViewGestureController in webkitWebViewBaseHandleWheelEvent()
instead.
For touch events, gesture progress calculation has to take window width into account to make
the page perfectly follow finger, and deltas are additionally divided by Scrollbar::pixelsPerLineStep(),
so compensate for that.
For touchpad events, change delta multiplier to 10 to match GTK behavior, and introduce a 400px
base width so the swipe speed doesn't change from the previous behavior.
Because of the multiplier change, threshold for triggering the gesture with touchpad is now 4
times larger.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseHandleWheelEvent): Move ViewGestureController bits here.
(webkitWebViewBaseScrollEvent): Removed ViewGestureController bits.
* UIProcess/gtk/ViewGestureControllerGtk.cpp:
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanInfluenceSwipe):
Allow events from touchscreen devices.
(WebKit::isTouchEvent): Added.
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas):
Change delta multipliers.
(WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
Change delta multipliers, account for view width for touchscreen events.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (245064 => 245065)
--- trunk/Source/WebKit/ChangeLog 2019-05-08 20:07:53 UTC (rev 245064)
+++ trunk/Source/WebKit/ChangeLog 2019-05-08 20:28:22 UTC (rev 245065)
@@ -1,3 +1,37 @@
+2019-05-08 Alexander Mikhaylenko <[email protected]>
+
+ [GTK] Support navigation gesture on touchscreens
+ https://bugs.webkit.org/show_bug.cgi?id=197690
+
+ Reviewed by Michael Catanzaro.
+
+ Touch events generate scroll events that are handled in webkitWebViewBaseHandleWheelEvent(),
+ bypassing webkitWebViewBaseScrollEvent(). Because of that, ViewGestureController never receives
+ them. Hence pass scroll events to ViewGestureController in webkitWebViewBaseHandleWheelEvent()
+ instead.
+
+ For touch events, gesture progress calculation has to take window width into account to make
+ the page perfectly follow finger, and deltas are additionally divided by Scrollbar::pixelsPerLineStep(),
+ so compensate for that.
+
+ For touchpad events, change delta multiplier to 10 to match GTK behavior, and introduce a 400px
+ base width so the swipe speed doesn't change from the previous behavior.
+
+ Because of the multiplier change, threshold for triggering the gesture with touchpad is now 4
+ times larger.
+
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseHandleWheelEvent): Move ViewGestureController bits here.
+ (webkitWebViewBaseScrollEvent): Removed ViewGestureController bits.
+ * UIProcess/gtk/ViewGestureControllerGtk.cpp:
+ (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanInfluenceSwipe):
+ Allow events from touchscreen devices.
+ (WebKit::isTouchEvent): Added.
+ (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas):
+ Change delta multipliers.
+ (WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
+ Change delta multipliers, account for view width for touchscreen events.
+
2019-05-08 Wenson Hsieh <[email protected]>
[iOS] Add a quirk to synthesize mouse events when modifying the selection
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (245064 => 245065)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2019-05-08 20:07:53 UTC (rev 245064)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2019-05-08 20:28:22 UTC (rev 245065)
@@ -850,6 +850,10 @@
static void webkitWebViewBaseHandleWheelEvent(WebKitWebViewBase* webViewBase, GdkEvent* event, Optional<WebWheelEvent::Phase> phase = WTF::nullopt, Optional<WebWheelEvent::Phase> momentum = WTF::nullopt)
{
+ ViewGestureController* controller = webkitWebViewBaseViewGestureController(webViewBase);
+ if (controller && controller->isSwipeGestureEnabled() && controller->handleScrollWheelEvent(reinterpret_cast<GdkEventScroll*>(event)))
+ return;
+
WebKitWebViewBasePrivate* priv = webViewBase->priv;
ASSERT(!priv->dialog);
if (phase)
@@ -890,10 +894,6 @@
}
}
- ViewGestureController* controller = webkitWebViewBaseViewGestureController(webViewBase);
- if (controller && controller->isSwipeGestureEnabled() && controller->handleScrollWheelEvent(event))
- return GDK_EVENT_STOP;
-
webkitWebViewBaseHandleWheelEvent(webViewBase, reinterpret_cast<GdkEvent*>(event));
return GDK_EVENT_STOP;
Modified: trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp (245064 => 245065)
--- trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2019-05-08 20:07:53 UTC (rev 245064)
+++ trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp 2019-05-08 20:28:22 UTC (rev 245065)
@@ -36,6 +36,10 @@
static const Seconds swipeMaxAnimationDuration = 400_ms;
static const double swipeAnimationBaseVelocity = 0.002;
+// GTK divides all scroll deltas by 10, compensate for that
+static const double gtkScrollDeltaMultiplier = 10;
+static const double swipeTouchpadBaseWidth = 400;
+
// This is derivative of the easing function at t=0
static const double swipeAnimationDurationMultiplier = 3;
@@ -82,13 +86,23 @@
// FIXME: Should it maybe be allowed on mice/trackpoints as well? The GDK_SCROLL_SMOOTH
// requirement already filters out most mice, and it works pretty well on a trackpoint
- return event->direction == GDK_SCROLL_SMOOTH && source == GDK_SOURCE_TOUCHPAD;
+ return event->direction == GDK_SCROLL_SMOOTH && (source == GDK_SOURCE_TOUCHPAD || source == GDK_SOURCE_TOUCHSCREEN);
}
+static bool isTouchEvent(GdkEventScroll* event)
+{
+ GdkDevice* device = gdk_event_get_source_device(reinterpret_cast<GdkEvent*>(event));
+ GdkInputSource source = gdk_device_get_source(device);
+
+ return source == GDK_SOURCE_TOUCHSCREEN;
+}
+
FloatSize ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas(GdkEventScroll* event)
{
+ double multiplier = isTouchEvent(event) ? Scrollbar::pixelsPerLineStep() : gtkScrollDeltaMultiplier;
+
// GdkEventScroll deltas are inverted compared to NSEvent, so invert them again
- return -FloatSize(event->delta_x, event->delta_y) * Scrollbar::pixelsPerLineStep();
+ return -FloatSize(event->delta_x, event->delta_y) * multiplier;
}
bool ViewGestureController::handleScrollWheelEvent(GdkEventScroll* event)
@@ -169,7 +183,11 @@
return false;
}
- double deltaX = -event->delta_x / Scrollbar::pixelsPerLineStep();
+ double deltaX = -event->delta_x;
+ if (isTouchEvent(event))
+ deltaX *= (double) Scrollbar::pixelsPerLineStep() / m_webPageProxy.viewSize().width();
+ else
+ deltaX *= gtkScrollDeltaMultiplier / swipeTouchpadBaseWidth;
Seconds time = Seconds::fromMilliseconds(event->time);
if (time != m_prevTime)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes