Diff
Modified: trunk/Source/WebKit/ChangeLog (260818 => 260819)
--- trunk/Source/WebKit/ChangeLog 2020-04-28 11:57:47 UTC (rev 260818)
+++ trunk/Source/WebKit/ChangeLog 2020-04-28 12:27:50 UTC (rev 260819)
@@ -1,3 +1,24 @@
+2020-04-27 Carlos Garcia Campos <[email protected]>
+
+ [GTK4] Add support for motion events
+ https://bugs.webkit.org/show_bug.cgi?id=211073
+
+ Reviewed by Adrian Perez de Castro.
+
+ Handle enter, leave and motion events using a GtkEventControllerMotion.
+
+ * Shared/NativeWebMouseEvent.h:
+ * Shared/gtk/NativeWebMouseEventGtk.cpp:
+ (WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
+ * Shared/gtk/WebEventFactory.cpp:
+ (WebKit::WebEventFactory::createWebMouseEvent):
+ * Shared/gtk/WebEventFactory.h:
+ * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+ (webkitWebViewBaseEnter):
+ (webkitWebViewBaseMotion):
+ (webkitWebViewBaseLeave):
+ (webkitWebViewBaseConstructed):
+
2020-04-28 Adrian Perez de Castro <[email protected]>
Non-unified build fixes late April 2020 edition
Modified: trunk/Source/WebKit/Shared/NativeWebMouseEvent.h (260818 => 260819)
--- trunk/Source/WebKit/Shared/NativeWebMouseEvent.h 2020-04-28 11:57:47 UTC (rev 260818)
+++ trunk/Source/WebKit/Shared/NativeWebMouseEvent.h 2020-04-28 12:27:50 UTC (rev 260819)
@@ -65,6 +65,8 @@
#elif PLATFORM(GTK)
NativeWebMouseEvent(const NativeWebMouseEvent&);
NativeWebMouseEvent(GdkEvent*, int, Optional<WebCore::IntPoint>);
+ NativeWebMouseEvent(GdkEvent*, const WebCore::IntPoint&, int, Optional<WebCore::IntPoint>);
+ explicit NativeWebMouseEvent(const WebCore::IntPoint&);
#elif PLATFORM(IOS_FAMILY)
NativeWebMouseEvent(::WebEvent *);
NativeWebMouseEvent(Type, Button, unsigned short buttons, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, OptionSet<Modifier>, WallTime timestamp, double force);
Modified: trunk/Source/WebKit/Shared/gtk/NativeWebMouseEventGtk.cpp (260818 => 260819)
--- trunk/Source/WebKit/Shared/gtk/NativeWebMouseEventGtk.cpp 2020-04-28 11:57:47 UTC (rev 260818)
+++ trunk/Source/WebKit/Shared/gtk/NativeWebMouseEventGtk.cpp 2020-04-28 12:27:50 UTC (rev 260819)
@@ -37,9 +37,20 @@
{
}
+NativeWebMouseEvent::NativeWebMouseEvent(GdkEvent* event, const WebCore::IntPoint& position, int eventClickCount, Optional<WebCore::IntPoint> delta)
+ : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, position, position, eventClickCount, delta))
+ , m_nativeEvent(gdk_event_copy(event))
+{
+}
+
+NativeWebMouseEvent::NativeWebMouseEvent(const WebCore::IntPoint& position)
+ : WebMouseEvent(WebEventFactory::createWebMouseEvent(position))
+{
+}
+
NativeWebMouseEvent::NativeWebMouseEvent(const NativeWebMouseEvent& event)
- : WebMouseEvent(WebEventFactory::createWebMouseEvent(event.nativeEvent(), event.clickCount(), WebCore::IntPoint(event.deltaX(), event.deltaY())))
- , m_nativeEvent(gdk_event_copy(const_cast<GdkEvent*>(event.nativeEvent())))
+ : WebMouseEvent(WebEventFactory::createWebMouseEvent(event.nativeEvent(), event.position(), event.globalPosition(), event.clickCount(), WebCore::IntPoint(event.deltaX(), event.deltaY())))
+ , m_nativeEvent(event.nativeEvent() ? gdk_event_copy(const_cast<GdkEvent*>(event.nativeEvent())) : nullptr)
{
}
Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp (260818 => 260819)
--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp 2020-04-28 11:57:47 UTC (rev 260818)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp 2020-04-28 12:27:50 UTC (rev 260819)
@@ -140,21 +140,29 @@
WebMouseEvent WebEventFactory::createWebMouseEvent(const GdkEvent* event, int currentClickCount, Optional<IntPoint> delta)
{
- double x, y, xRoot, yRoot;
+ double x, y;
gdk_event_get_coords(event, &x, &y);
+ double xRoot, yRoot;
gdk_event_get_root_coords(event, &xRoot, &yRoot);
+ return createWebMouseEvent(event, { clampToInteger(x), clampToInteger(y) }, { clampToInteger(xRoot), clampToInteger(yRoot) }, currentClickCount, delta);
+}
+
+WebMouseEvent WebEventFactory::createWebMouseEvent(const GdkEvent* event, const IntPoint& position, const IntPoint& globalPosition, int currentClickCount, Optional<IntPoint> delta)
+{
+#if USE(GTK4)
+ // This can happen when a NativeWebMouseEvent representing a crossing event is copied.
+ if (!event)
+ return createWebMouseEvent(position);
+#endif
+
GdkModifierType state = static_cast<GdkModifierType>(0);
gdk_event_get_state(event, &state);
- guint eventButton;
- gdk_event_get_button(event, &eventButton);
-
WebEvent::Type type = static_cast<WebEvent::Type>(0);
IntPoint movementDelta;
- GdkEventType eventType = gdk_event_get_event_type(const_cast<GdkEvent*>(event));
- switch (eventType) {
+ switch (gdk_event_get_event_type(const_cast<GdkEvent*>(event))) {
case GDK_MOTION_NOTIFY:
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
@@ -168,6 +176,8 @@
#endif
case GDK_BUTTON_PRESS: {
type = WebEvent::MouseDown;
+ guint eventButton;
+ gdk_event_get_button(event, &eventButton);
auto modifier = stateModifierForGdkButton(eventButton);
state = static_cast<GdkModifierType>(state | modifier);
break;
@@ -174,6 +184,8 @@
}
case GDK_BUTTON_RELEASE: {
type = WebEvent::MouseUp;
+ guint eventButton;
+ gdk_event_get_button(event, &eventButton);
auto modifier = stateModifierForGdkButton(eventButton);
state = static_cast<GdkModifierType>(state & ~modifier);
break;
@@ -185,8 +197,8 @@
return WebMouseEvent(type,
buttonForEvent(event),
pressedMouseButtons(state),
- IntPoint(x, y),
- IntPoint(xRoot, yRoot),
+ position,
+ globalPosition,
movementDelta.x(),
movementDelta.y(),
0 /* deltaZ */,
@@ -195,6 +207,12 @@
wallTimeForEvent(event));
}
+WebMouseEvent WebEventFactory::createWebMouseEvent(const IntPoint& position)
+{
+ // Mouse events without GdkEvent are crossing events, handled as a mouse move.
+ return WebMouseEvent(WebEvent::MouseMove, WebMouseEvent::NoButton, 0, position, position, 0, 0, 0, 0, { }, WallTime::now());
+}
+
WebWheelEvent WebEventFactory::createWebWheelEvent(const GdkEvent* event)
{
WebWheelEvent::Phase phase = gdk_event_is_scroll_stop_event(event) ?
Modified: trunk/Source/WebKit/Shared/gtk/WebEventFactory.h (260818 => 260819)
--- trunk/Source/WebKit/Shared/gtk/WebEventFactory.h 2020-04-28 11:57:47 UTC (rev 260818)
+++ trunk/Source/WebKit/Shared/gtk/WebEventFactory.h 2020-04-28 12:27:50 UTC (rev 260819)
@@ -39,6 +39,8 @@
class WebEventFactory {
public:
static WebMouseEvent createWebMouseEvent(const GdkEvent*, int, Optional<WebCore::IntPoint>);
+ static WebMouseEvent createWebMouseEvent(const GdkEvent*, const WebCore::IntPoint&, const WebCore::IntPoint&, int, Optional<WebCore::IntPoint>);
+ static WebMouseEvent createWebMouseEvent(const WebCore::IntPoint&);
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);
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (260818 => 260819)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2020-04-28 11:57:47 UTC (rev 260818)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp 2020-04-28 12:27:50 UTC (rev 260819)
@@ -1111,6 +1111,51 @@
}
#endif
+#if USE(GTK4)
+static void webkitWebViewBaseEnter(WebKitWebViewBase* webViewBase, double x, double y, GdkCrossingMode, GtkEventController*)
+{
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+ if (priv->dialog)
+ return;
+
+#if ENABLE(DEVELOPER_MODE)
+ // Do not send mouse move events to the WebProcess for crossing events during testing.
+ // WTR never generates crossing events and they can confuse tests.
+ // https://bugs.webkit.org/show_bug.cgi?id=185072.
+ if (UNLIKELY(priv->pageProxy->process().processPool().configuration().fullySynchronousModeIsAllowedForTesting()))
+ return;
+#endif
+
+ priv->pageProxy->handleMouseEvent(NativeWebMouseEvent({ clampToInteger(x), clampToInteger(y) }));
+}
+
+static gboolean webkitWebViewBaseMotion(WebKitWebViewBase* webViewBase, double x, double y, GtkEventController* controller)
+{
+ // FIXME: Forward event to dialog.
+ // FIXME: Pointer lock.
+ webViewBase->priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(gtk_event_controller_get_current_event(controller), { clampToInteger(x), clampToInteger(y) }, 0, WTF::nullopt));
+
+ return GDK_EVENT_PROPAGATE;
+}
+
+static void webkitWebViewBaseLeave(WebKitWebViewBase* webViewBase, GdkCrossingMode, GtkEventController*)
+{
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+ if (priv->dialog)
+ return;
+
+#if ENABLE(DEVELOPER_MODE)
+ // Do not send mouse move events to the WebProcess for crossing events during testing.
+ // WTR never generates crossing events and they can confuse tests.
+ // https://bugs.webkit.org/show_bug.cgi?id=185072.
+ if (UNLIKELY(priv->pageProxy->process().processPool().configuration().fullySynchronousModeIsAllowedForTesting()))
+ return;
+#endif
+
+ priv->pageProxy->handleMouseEvent(NativeWebMouseEvent({ -1, -1 }));
+}
+#endif
+
#if ENABLE(TOUCH_EVENTS) && !USE(GTK4)
static void appendTouchEvent(Vector<WebPlatformTouchPoint>& touchPoints, const GdkEvent* event, WebPlatformTouchPoint::TouchPointState state)
{
@@ -1521,6 +1566,12 @@
auto* controller = gtk_event_controller_scroll_new(GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES);
g_signal_connect_object(controller, "scroll", G_CALLBACK(webkitWebViewBaseScroll), viewWidget, G_CONNECT_SWAPPED);
gtk_widget_add_controller(viewWidget, controller);
+
+ controller = gtk_event_controller_motion_new();
+ g_signal_connect_object(controller, "enter", G_CALLBACK(webkitWebViewBaseEnter), viewWidget, G_CONNECT_SWAPPED);
+ g_signal_connect_object(controller, "motion", G_CALLBACK(webkitWebViewBaseMotion), viewWidget, G_CONNECT_SWAPPED);
+ g_signal_connect_object(controller, "leave", G_CALLBACK(webkitWebViewBaseLeave), viewWidget, G_CONNECT_SWAPPED);
+ gtk_widget_add_controller(viewWidget, controller);
#endif
}
Modified: trunk/Tools/ChangeLog (260818 => 260819)
--- trunk/Tools/ChangeLog 2020-04-28 11:57:47 UTC (rev 260818)
+++ trunk/Tools/ChangeLog 2020-04-28 12:27:50 UTC (rev 260819)
@@ -1,3 +1,15 @@
+2020-04-27 Carlos Garcia Campos <[email protected]>
+
+ [GTK4] Add support for motion events
+ https://bugs.webkit.org/show_bug.cgi?id=211073
+
+ Reviewed by Adrian Perez de Castro.
+
+ Use the GtkOverlay in GTK4 too so that status label is shown when hovering elements.
+
+ * MiniBrowser/gtk/BrowserTab.c:
+ (browserTabConstructed):
+
2020-04-28 Carlos Garcia Campos <[email protected]>
[GTK4][Wayland] Add support for rendering web view contents
Modified: trunk/Tools/MiniBrowser/gtk/BrowserTab.c (260818 => 260819)
--- trunk/Tools/MiniBrowser/gtk/BrowserTab.c 2020-04-28 11:57:47 UTC (rev 260818)
+++ trunk/Tools/MiniBrowser/gtk/BrowserTab.c 2020-04-28 12:27:50 UTC (rev 260819)
@@ -398,38 +398,42 @@
#if !GTK_CHECK_VERSION(3, 98, 0)
tab->searchBar = BROWSER_SEARCH_BAR(browser_search_bar_new(tab->webView));
gtk_box_pack_start(GTK_BOX(tab), GTK_WIDGET(tab->searchBar), FALSE, FALSE, 0);
+#endif
GtkWidget *overlay = gtk_overlay_new();
- gtk_box_pack_start(GTK_BOX(tab), overlay, TRUE, TRUE, 0);
+ gtk_container_add(GTK_CONTAINER(tab), overlay);
gtk_widget_show(overlay);
tab->statusLabel = gtk_label_new(NULL);
gtk_widget_set_halign(tab->statusLabel, GTK_ALIGN_START);
gtk_widget_set_valign(tab->statusLabel, GTK_ALIGN_END);
+#if !GTK_CHECK_VERSION(3, 98, 0)
gtk_widget_set_margin_left(tab->statusLabel, 1);
gtk_widget_set_margin_right(tab->statusLabel, 1);
gtk_widget_set_margin_top(tab->statusLabel, 1);
gtk_widget_set_margin_bottom(tab->statusLabel, 1);
+#endif
gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->statusLabel);
tab->fullScreenMessageLabel = gtk_label_new(NULL);
gtk_widget_set_halign(tab->fullScreenMessageLabel, GTK_ALIGN_CENTER);
gtk_widget_set_valign(tab->fullScreenMessageLabel, GTK_ALIGN_CENTER);
+#if !GTK_CHECK_VERSION(3, 98, 0)
gtk_widget_set_no_show_all(tab->fullScreenMessageLabel, TRUE);
+#endif
gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->fullScreenMessageLabel);
tab->pointerLockMessageLabel = gtk_label_new(NULL);
gtk_widget_set_halign(tab->pointerLockMessageLabel, GTK_ALIGN_CENTER);
gtk_widget_set_valign(tab->pointerLockMessageLabel, GTK_ALIGN_START);
+#if !GTK_CHECK_VERSION(3, 98, 0)
gtk_widget_set_no_show_all(tab->pointerLockMessageLabel, TRUE);
+#endif
gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->pointerLockMessageLabel);
+ gtk_widget_set_vexpand(GTK_WIDGET(tab->webView), TRUE);
gtk_container_add(GTK_CONTAINER(overlay), GTK_WIDGET(tab->webView));
gtk_widget_show(GTK_WIDGET(tab->webView));
-#else
- gtk_widget_set_vexpand(GTK_WIDGET(tab->webView), TRUE);
- gtk_container_add(GTK_CONTAINER(tab), GTK_WIDGET(tab->webView));
-#endif
#if !GTK_CHECK_VERSION(3, 98, 0)
tab->titleBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);