Changeset 260819 in webkit
- Timestamp:
- Apr 28, 2020 5:27:50 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r260818 r260819 1 2020-04-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK4] Add support for motion events 4 https://bugs.webkit.org/show_bug.cgi?id=211073 5 6 Reviewed by Adrian Perez de Castro. 7 8 Handle enter, leave and motion events using a GtkEventControllerMotion. 9 10 * Shared/NativeWebMouseEvent.h: 11 * Shared/gtk/NativeWebMouseEventGtk.cpp: 12 (WebKit::NativeWebMouseEvent::NativeWebMouseEvent): 13 * Shared/gtk/WebEventFactory.cpp: 14 (WebKit::WebEventFactory::createWebMouseEvent): 15 * Shared/gtk/WebEventFactory.h: 16 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 17 (webkitWebViewBaseEnter): 18 (webkitWebViewBaseMotion): 19 (webkitWebViewBaseLeave): 20 (webkitWebViewBaseConstructed): 21 1 22 2020-04-28 Adrian Perez de Castro <aperez@igalia.com> 2 23 -
trunk/Source/WebKit/Shared/NativeWebMouseEvent.h
r260752 r260819 66 66 NativeWebMouseEvent(const NativeWebMouseEvent&); 67 67 NativeWebMouseEvent(GdkEvent*, int, Optional<WebCore::IntPoint>); 68 NativeWebMouseEvent(GdkEvent*, const WebCore::IntPoint&, int, Optional<WebCore::IntPoint>); 69 explicit NativeWebMouseEvent(const WebCore::IntPoint&); 68 70 #elif PLATFORM(IOS_FAMILY) 69 71 NativeWebMouseEvent(::WebEvent *); -
trunk/Source/WebKit/Shared/gtk/NativeWebMouseEventGtk.cpp
r260752 r260819 38 38 } 39 39 40 NativeWebMouseEvent::NativeWebMouseEvent(GdkEvent* event, const WebCore::IntPoint& position, int eventClickCount, Optional<WebCore::IntPoint> delta) 41 : WebMouseEvent(WebEventFactory::createWebMouseEvent(event, position, position, eventClickCount, delta)) 42 , m_nativeEvent(gdk_event_copy(event)) 43 { 44 } 45 46 NativeWebMouseEvent::NativeWebMouseEvent(const WebCore::IntPoint& position) 47 : WebMouseEvent(WebEventFactory::createWebMouseEvent(position)) 48 { 49 } 50 40 51 NativeWebMouseEvent::NativeWebMouseEvent(const NativeWebMouseEvent& event) 41 : WebMouseEvent(WebEventFactory::createWebMouseEvent(event.nativeEvent(), event. clickCount(), WebCore::IntPoint(event.deltaX(), event.deltaY())))42 , m_nativeEvent( gdk_event_copy(const_cast<GdkEvent*>(event.nativeEvent())))52 : WebMouseEvent(WebEventFactory::createWebMouseEvent(event.nativeEvent(), event.position(), event.globalPosition(), event.clickCount(), WebCore::IntPoint(event.deltaX(), event.deltaY()))) 53 , m_nativeEvent(event.nativeEvent() ? gdk_event_copy(const_cast<GdkEvent*>(event.nativeEvent())) : nullptr) 43 54 { 44 55 } -
trunk/Source/WebKit/Shared/gtk/WebEventFactory.cpp
r260817 r260819 141 141 WebMouseEvent WebEventFactory::createWebMouseEvent(const GdkEvent* event, int currentClickCount, Optional<IntPoint> delta) 142 142 { 143 double x, y , xRoot, yRoot;143 double x, y; 144 144 gdk_event_get_coords(event, &x, &y); 145 double xRoot, yRoot; 145 146 gdk_event_get_root_coords(event, &xRoot, &yRoot); 147 148 return createWebMouseEvent(event, { clampToInteger(x), clampToInteger(y) }, { clampToInteger(xRoot), clampToInteger(yRoot) }, currentClickCount, delta); 149 } 150 151 WebMouseEvent WebEventFactory::createWebMouseEvent(const GdkEvent* event, const IntPoint& position, const IntPoint& globalPosition, int currentClickCount, Optional<IntPoint> delta) 152 { 153 #if USE(GTK4) 154 // This can happen when a NativeWebMouseEvent representing a crossing event is copied. 155 if (!event) 156 return createWebMouseEvent(position); 157 #endif 146 158 147 159 GdkModifierType state = static_cast<GdkModifierType>(0); 148 160 gdk_event_get_state(event, &state); 149 161 150 guint eventButton;151 gdk_event_get_button(event, &eventButton);152 153 162 WebEvent::Type type = static_cast<WebEvent::Type>(0); 154 163 IntPoint movementDelta; 155 164 156 GdkEventType eventType = gdk_event_get_event_type(const_cast<GdkEvent*>(event)); 157 switch (eventType) { 165 switch (gdk_event_get_event_type(const_cast<GdkEvent*>(event))) { 158 166 case GDK_MOTION_NOTIFY: 159 167 case GDK_ENTER_NOTIFY: … … 169 177 case GDK_BUTTON_PRESS: { 170 178 type = WebEvent::MouseDown; 179 guint eventButton; 180 gdk_event_get_button(event, &eventButton); 171 181 auto modifier = stateModifierForGdkButton(eventButton); 172 182 state = static_cast<GdkModifierType>(state | modifier); … … 175 185 case GDK_BUTTON_RELEASE: { 176 186 type = WebEvent::MouseUp; 187 guint eventButton; 188 gdk_event_get_button(event, &eventButton); 177 189 auto modifier = stateModifierForGdkButton(eventButton); 178 190 state = static_cast<GdkModifierType>(state & ~modifier); … … 186 198 buttonForEvent(event), 187 199 pressedMouseButtons(state), 188 IntPoint(x, y),189 IntPoint(xRoot, yRoot),200 position, 201 globalPosition, 190 202 movementDelta.x(), 191 203 movementDelta.y(), … … 194 206 modifiersForEvent(event), 195 207 wallTimeForEvent(event)); 208 } 209 210 WebMouseEvent WebEventFactory::createWebMouseEvent(const IntPoint& position) 211 { 212 // Mouse events without GdkEvent are crossing events, handled as a mouse move. 213 return WebMouseEvent(WebEvent::MouseMove, WebMouseEvent::NoButton, 0, position, position, 0, 0, 0, 0, { }, WallTime::now()); 196 214 } 197 215 -
trunk/Source/WebKit/Shared/gtk/WebEventFactory.h
r260817 r260819 40 40 public: 41 41 static WebMouseEvent createWebMouseEvent(const GdkEvent*, int, Optional<WebCore::IntPoint>); 42 static WebMouseEvent createWebMouseEvent(const GdkEvent*, const WebCore::IntPoint&, const WebCore::IntPoint&, int, Optional<WebCore::IntPoint>); 43 static WebMouseEvent createWebMouseEvent(const WebCore::IntPoint&); 42 44 static WebWheelEvent createWebWheelEvent(const GdkEvent*); 43 45 static WebWheelEvent createWebWheelEvent(const GdkEvent*, WebWheelEvent::Phase, WebWheelEvent::Phase momentumPhase); -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
r260817 r260819 1112 1112 #endif 1113 1113 1114 #if USE(GTK4) 1115 static void webkitWebViewBaseEnter(WebKitWebViewBase* webViewBase, double x, double y, GdkCrossingMode, GtkEventController*) 1116 { 1117 WebKitWebViewBasePrivate* priv = webViewBase->priv; 1118 if (priv->dialog) 1119 return; 1120 1121 #if ENABLE(DEVELOPER_MODE) 1122 // Do not send mouse move events to the WebProcess for crossing events during testing. 1123 // WTR never generates crossing events and they can confuse tests. 1124 // https://bugs.webkit.org/show_bug.cgi?id=185072. 1125 if (UNLIKELY(priv->pageProxy->process().processPool().configuration().fullySynchronousModeIsAllowedForTesting())) 1126 return; 1127 #endif 1128 1129 priv->pageProxy->handleMouseEvent(NativeWebMouseEvent({ clampToInteger(x), clampToInteger(y) })); 1130 } 1131 1132 static gboolean webkitWebViewBaseMotion(WebKitWebViewBase* webViewBase, double x, double y, GtkEventController* controller) 1133 { 1134 // FIXME: Forward event to dialog. 1135 // FIXME: Pointer lock. 1136 webViewBase->priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(gtk_event_controller_get_current_event(controller), { clampToInteger(x), clampToInteger(y) }, 0, WTF::nullopt)); 1137 1138 return GDK_EVENT_PROPAGATE; 1139 } 1140 1141 static void webkitWebViewBaseLeave(WebKitWebViewBase* webViewBase, GdkCrossingMode, GtkEventController*) 1142 { 1143 WebKitWebViewBasePrivate* priv = webViewBase->priv; 1144 if (priv->dialog) 1145 return; 1146 1147 #if ENABLE(DEVELOPER_MODE) 1148 // Do not send mouse move events to the WebProcess for crossing events during testing. 1149 // WTR never generates crossing events and they can confuse tests. 1150 // https://bugs.webkit.org/show_bug.cgi?id=185072. 1151 if (UNLIKELY(priv->pageProxy->process().processPool().configuration().fullySynchronousModeIsAllowedForTesting())) 1152 return; 1153 #endif 1154 1155 priv->pageProxy->handleMouseEvent(NativeWebMouseEvent({ -1, -1 })); 1156 } 1157 #endif 1158 1114 1159 #if ENABLE(TOUCH_EVENTS) && !USE(GTK4) 1115 1160 static void appendTouchEvent(Vector<WebPlatformTouchPoint>& touchPoints, const GdkEvent* event, WebPlatformTouchPoint::TouchPointState state) … … 1522 1567 g_signal_connect_object(controller, "scroll", G_CALLBACK(webkitWebViewBaseScroll), viewWidget, G_CONNECT_SWAPPED); 1523 1568 gtk_widget_add_controller(viewWidget, controller); 1569 1570 controller = gtk_event_controller_motion_new(); 1571 g_signal_connect_object(controller, "enter", G_CALLBACK(webkitWebViewBaseEnter), viewWidget, G_CONNECT_SWAPPED); 1572 g_signal_connect_object(controller, "motion", G_CALLBACK(webkitWebViewBaseMotion), viewWidget, G_CONNECT_SWAPPED); 1573 g_signal_connect_object(controller, "leave", G_CALLBACK(webkitWebViewBaseLeave), viewWidget, G_CONNECT_SWAPPED); 1574 gtk_widget_add_controller(viewWidget, controller); 1524 1575 #endif 1525 1576 } -
trunk/Tools/ChangeLog
r260816 r260819 1 2020-04-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK4] Add support for motion events 4 https://bugs.webkit.org/show_bug.cgi?id=211073 5 6 Reviewed by Adrian Perez de Castro. 7 8 Use the GtkOverlay in GTK4 too so that status label is shown when hovering elements. 9 10 * MiniBrowser/gtk/BrowserTab.c: 11 (browserTabConstructed): 12 1 13 2020-04-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 14 -
trunk/Tools/MiniBrowser/gtk/BrowserTab.c
r260816 r260819 399 399 tab->searchBar = BROWSER_SEARCH_BAR(browser_search_bar_new(tab->webView)); 400 400 gtk_box_pack_start(GTK_BOX(tab), GTK_WIDGET(tab->searchBar), FALSE, FALSE, 0); 401 #endif 401 402 402 403 GtkWidget *overlay = gtk_overlay_new(); 403 gtk_ box_pack_start(GTK_BOX(tab), overlay, TRUE, TRUE, 0);404 gtk_container_add(GTK_CONTAINER(tab), overlay); 404 405 gtk_widget_show(overlay); 405 406 … … 407 408 gtk_widget_set_halign(tab->statusLabel, GTK_ALIGN_START); 408 409 gtk_widget_set_valign(tab->statusLabel, GTK_ALIGN_END); 410 #if !GTK_CHECK_VERSION(3, 98, 0) 409 411 gtk_widget_set_margin_left(tab->statusLabel, 1); 410 412 gtk_widget_set_margin_right(tab->statusLabel, 1); 411 413 gtk_widget_set_margin_top(tab->statusLabel, 1); 412 414 gtk_widget_set_margin_bottom(tab->statusLabel, 1); 415 #endif 413 416 gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->statusLabel); 414 417 … … 416 419 gtk_widget_set_halign(tab->fullScreenMessageLabel, GTK_ALIGN_CENTER); 417 420 gtk_widget_set_valign(tab->fullScreenMessageLabel, GTK_ALIGN_CENTER); 421 #if !GTK_CHECK_VERSION(3, 98, 0) 418 422 gtk_widget_set_no_show_all(tab->fullScreenMessageLabel, TRUE); 423 #endif 419 424 gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->fullScreenMessageLabel); 420 425 … … 422 427 gtk_widget_set_halign(tab->pointerLockMessageLabel, GTK_ALIGN_CENTER); 423 428 gtk_widget_set_valign(tab->pointerLockMessageLabel, GTK_ALIGN_START); 429 #if !GTK_CHECK_VERSION(3, 98, 0) 424 430 gtk_widget_set_no_show_all(tab->pointerLockMessageLabel, TRUE); 431 #endif 425 432 gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->pointerLockMessageLabel); 426 433 434 gtk_widget_set_vexpand(GTK_WIDGET(tab->webView), TRUE); 427 435 gtk_container_add(GTK_CONTAINER(overlay), GTK_WIDGET(tab->webView)); 428 436 gtk_widget_show(GTK_WIDGET(tab->webView)); 429 #else430 gtk_widget_set_vexpand(GTK_WIDGET(tab->webView), TRUE);431 gtk_container_add(GTK_CONTAINER(tab), GTK_WIDGET(tab->webView));432 #endif433 437 434 438 #if !GTK_CHECK_VERSION(3, 98, 0)
Note: See TracChangeset
for help on using the changeset viewer.