Title: [262374] trunk/Source/WebKit
Revision
262374
Author
[email protected]
Date
2020-06-01 05:55:50 -0700 (Mon, 01 Jun 2020)

Log Message

[GTK4] Wheel events are always handled by the main frame view
https://bugs.webkit.org/show_bug.cgi?id=212593

Reviewed by Adrian Perez de Castro.

It's not possible scroll other scrollable areas with the mouse wheel. This is because we are using the given x,
y delta in the scroll signal as the position. In GTK4 the scroll event doesn't include a position, so we have to
use the last motion event.

* Shared/NativeWebWheelEvent.h:
* Shared/gtk/NativeWebWheelEventGtk.cpp:
(WebKit::NativeWebWheelEvent::NativeWebWheelEvent): Add wheelTicks parameter.
* Shared/gtk/WebEventFactory.cpp:
(WebKit::WebEventFactory::createWebWheelEvent): New create function that receives the wheelTicks.
* Shared/gtk/WebEventFactory.h:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseScroll): Use the x, y parameters as the delta and take the position from the last motion event.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (262373 => 262374)


--- trunk/Source/WebKit/ChangeLog	2020-06-01 12:38:16 UTC (rev 262373)
+++ trunk/Source/WebKit/ChangeLog	2020-06-01 12:55:50 UTC (rev 262374)
@@ -1,5 +1,25 @@
 2020-06-01  Carlos Garcia Campos  <[email protected]>
 
+        [GTK4] Wheel events are always handled by the main frame view
+        https://bugs.webkit.org/show_bug.cgi?id=212593
+
+        Reviewed by Adrian Perez de Castro.
+
+        It's not possible scroll other scrollable areas with the mouse wheel. This is because we are using the given x,
+        y delta in the scroll signal as the position. In GTK4 the scroll event doesn't include a position, so we have to
+        use the last motion event.
+
+        * Shared/NativeWebWheelEvent.h:
+        * Shared/gtk/NativeWebWheelEventGtk.cpp:
+        (WebKit::NativeWebWheelEvent::NativeWebWheelEvent): Add wheelTicks parameter.
+        * Shared/gtk/WebEventFactory.cpp:
+        (WebKit::WebEventFactory::createWebWheelEvent): New create function that receives the wheelTicks.
+        * Shared/gtk/WebEventFactory.h:
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseScroll): Use the x, y parameters as the delta and take the position from the last motion event.
+
+2020-06-01  Carlos Garcia Campos  <[email protected]>
+
         [GTK4] Monitor root window to update activity state
         https://bugs.webkit.org/show_bug.cgi?id=212581
 

Modified: trunk/Source/WebKit/Shared/NativeWebWheelEvent.h (262373 => 262374)


--- trunk/Source/WebKit/Shared/NativeWebWheelEvent.h	2020-06-01 12:38:16 UTC (rev 262373)
+++ trunk/Source/WebKit/Shared/NativeWebWheelEvent.h	2020-06-01 12:55:50 UTC (rev 262374)
@@ -60,7 +60,7 @@
     NativeWebWheelEvent(const NativeWebWheelEvent&);
     NativeWebWheelEvent(GdkEvent*);
     NativeWebWheelEvent(GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
-    NativeWebWheelEvent(GdkEvent*, const WebCore::IntPoint&);
+    NativeWebWheelEvent(GdkEvent*, const WebCore::IntPoint&, const WebCore::FloatSize& wheelTicks);
     NativeWebWheelEvent(const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, const WebCore::FloatSize& delta, const WebCore::FloatSize& wheelTicks, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
 #elif USE(LIBWPE)
     NativeWebWheelEvent(struct wpe_input_axis_event*, float deviceScaleFactor, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);

Modified: trunk/Source/WebKit/Shared/gtk/NativeWebWheelEventGtk.cpp (262373 => 262374)


--- trunk/Source/WebKit/Shared/gtk/NativeWebWheelEventGtk.cpp	2020-06-01 12:38:16 UTC (rev 262373)
+++ trunk/Source/WebKit/Shared/gtk/NativeWebWheelEventGtk.cpp	2020-06-01 12:55:50 UTC (rev 262374)
@@ -43,8 +43,8 @@
 {
 }
 
-NativeWebWheelEvent::NativeWebWheelEvent(GdkEvent* event, const WebCore::IntPoint& position)
-    : WebWheelEvent(WebEventFactory::createWebWheelEvent(event, position, position, WebWheelEvent::Phase::PhaseChanged, WebWheelEvent::Phase::PhaseNone))
+NativeWebWheelEvent::NativeWebWheelEvent(GdkEvent* event, const WebCore::IntPoint& position, const WebCore::FloatSize& wheelTicks)
+    : WebWheelEvent(WebEventFactory::createWebWheelEvent(event, position, position, wheelTicks, WebWheelEvent::Phase::PhaseChanged, WebWheelEvent::Phase::PhaseNone))
     , m_nativeEvent(gdk_event_copy(event))
 {
 }

Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp (262373 => 262374)


--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp	2020-06-01 12:38:16 UTC (rev 262373)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp	2020-06-01 12:55:50 UTC (rev 262374)
@@ -262,16 +262,21 @@
         }
     }
 
+    return createWebWheelEvent(event, position, globalPosition, wheelTicks.value(), phase, momentumPhase);
+}
+
+WebWheelEvent WebEventFactory::createWebWheelEvent(const GdkEvent* event, const IntPoint& position, const IntPoint& globalPosition, const FloatSize& wheelTicks, WebWheelEvent::Phase phase, WebWheelEvent::Phase momentumPhase)
+{
     // FIXME: [GTK] Add a setting to change the pixels per line used for scrolling
     // https://bugs.webkit.org/show_bug.cgi?id=54826
     float step = static_cast<float>(Scrollbar::pixelsPerLineStep());
-    FloatSize delta(wheelTicks->width() * step, wheelTicks->height() * step);
+    FloatSize delta(wheelTicks.width() * step, wheelTicks.height() * step);
 
     return WebWheelEvent(WebEvent::Wheel,
         position,
         globalPosition,
         delta,
-        wheelTicks.value(),
+        wheelTicks,
         phase,
         momentumPhase,
         WebWheelEvent::ScrollByPixelWheelEvent,

Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.h (262373 => 262374)


--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.h	2020-06-01 12:38:16 UTC (rev 262373)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.h	2020-06-01 12:55:50 UTC (rev 262374)
@@ -44,6 +44,7 @@
     static WebWheelEvent createWebWheelEvent(const GdkEvent*);
     static WebWheelEvent createWebWheelEvent(const GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
     static WebWheelEvent createWebWheelEvent(const GdkEvent*, const WebCore::IntPoint&, const WebCore::IntPoint&, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
+    static WebWheelEvent createWebWheelEvent(const GdkEvent*, const WebCore::IntPoint&, const WebCore::IntPoint&, const WebCore::FloatSize& wheelTicks, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase);
     static WebKeyboardEvent createWebKeyboardEvent(const GdkEvent*, const String&, bool handledByInputMethod, Optional<Vector<WebCore::CompositionUnderline>>&&, Optional<EditingRange>&&, Vector<String>&& commands);
 #if ENABLE(TOUCH_EVENTS)
     static WebTouchEvent createWebTouchEvent(const GdkEvent*, Vector<WebPlatformTouchPoint>&&);

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (262373 => 262374)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2020-06-01 12:38:16 UTC (rev 262373)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp	2020-06-01 12:55:50 UTC (rev 262374)
@@ -1256,14 +1256,20 @@
 #endif
 
 #if USE(GTK4)
-static gboolean webkitWebViewBaseScroll(WebKitWebViewBase* webViewBase, double x, double y, GtkEventController* controller)
+static gboolean webkitWebViewBaseScroll(WebKitWebViewBase* webViewBase, double deltaX, double deltaY, GtkEventController* controller)
 {
-    if (webViewBase->priv->dialog)
+    WebKitWebViewBasePrivate* priv = webViewBase->priv;
+    if (priv->dialog)
         return GDK_EVENT_PROPAGATE;
 
-    // FIXME: invert axis in case of SHIFT.
-    webViewBase->priv->pageProxy->handleWheelEvent(NativeWebWheelEvent(gtk_event_controller_get_current_event(controller), { clampToInteger(x), clampToInteger(y) }));
+    auto* event = gtk_event_controller_get_current_event(controller);
 
+    // Shift+Wheel scrolls in the perpendicular direction.
+    if (gdk_event_get_modifier_state(event) & GDK_SHIFT_MASK)
+        std::swap(deltaX, deltaY);
+
+    priv->pageProxy->handleWheelEvent(NativeWebWheelEvent(event, priv->lastMotionEvent ? IntPoint(priv->lastMotionEvent->position) : IntPoint(), FloatSize(-deltaX, -deltaY)));
+
     return GDK_EVENT_STOP;
 }
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to