[WPE] Implement mouse event modifiers
authorcsaavedra@igalia.com <csaavedra@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Sep 2018 13:44:29 +0000 (13:44 +0000)
committercsaavedra@igalia.com <csaavedra@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Sep 2018 13:44:29 +0000 (13:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189697

Reviewed by Carlos Garcia Campos.

Source/WebKit:

Only "CapsLocks" is missing, as WPE doesn't support that modifier.
* Shared/wpe/WebEventFactory.cpp:
(WebKit::modifiersForEventModifiers):
(WebKit::WebEventFactory::createWebKeyboardEvent):
(WebKit::WebEventFactory::createWebMouseEvent):
(WebKit::modifiersForEvent): Deleted.

Tools:

* WebKitTestRunner/wpe/EventSenderProxyWPE.cpp:
(WTR::wkEventModifiersToWPE):
(WTR::EventSenderProxy::mouseDown):
(WTR::EventSenderProxy::mouseUp):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236124 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Shared/wpe/WebEventFactory.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp

index 988d388..1a3de03 100644 (file)
@@ -1,3 +1,17 @@
+2018-09-18  Claudio Saavedra  <csaavedra@igalia.com>
+
+        [WPE] Implement mouse event modifiers
+        https://bugs.webkit.org/show_bug.cgi?id=189697
+
+        Reviewed by Carlos Garcia Campos.
+
+        Only "CapsLocks" is missing, as WPE doesn't support that modifier.
+        * Shared/wpe/WebEventFactory.cpp:
+        (WebKit::modifiersForEventModifiers):
+        (WebKit::WebEventFactory::createWebKeyboardEvent):
+        (WebKit::WebEventFactory::createWebMouseEvent):
+        (WebKit::modifiersForEvent): Deleted.
+
 2018-09-17  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed build fix after r236101.
index 2a2f519..b718c90 100644 (file)
@@ -38,10 +38,9 @@ static inline bool isWPEKeyCodeFromKeyPad(unsigned keyCode)
     return keyCode >= WPE_KEY_KP_Space && keyCode <= WPE_KEY_KP_9;
 }
 
-static WebEvent::Modifiers modifiersForEvent(struct wpe_input_keyboard_event* event)
+static WebEvent::Modifiers modifiersForEventModifiers(unsigned eventModifiers)
 {
     unsigned modifiers = 0;
-    unsigned eventModifiers = event->modifiers;
 
     if (eventModifiers & wpe_input_keyboard_modifier_control)
         modifiers |= WebEvent::ControlKey;
@@ -77,7 +76,7 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(struct wpe_input_keyboa
         WebCore::PlatformKeyboardEvent::windowsKeyCodeForWPEKeyCode(event->key_code),
         event->key_code,
         isWPEKeyCodeFromKeyPad(event->key_code),
-        modifiersForEvent(event),
+        modifiersForEventModifiers(event->modifiers),
         wallTimeForEventTime(event->time));
 }
 
@@ -137,11 +136,11 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(struct wpe_input_pointer_even
 
     unsigned clickCount = (type == WebEvent::MouseDown) ? 1 : 0;
 
-    // FIXME: Proper button support. Modifiers. deltaX/Y/Z. Click count.
+    // FIXME: Proper button support. deltaX/Y/Z. Click count.
     WebCore::IntPoint position(event->x, event->y);
     position.scale(1 / deviceScaleFactor);
     return WebMouseEvent(type, button, pressedMouseButtons(event->modifiers), position, position,
-        0, 0, 0, clickCount, static_cast<WebEvent::Modifiers>(0), wallTimeForEventTime(event->time));
+        0, 0, 0, clickCount, modifiersForEventModifiers(event->modifiers), wallTimeForEventTime(event->time));
 }
 
 WebWheelEvent WebEventFactory::createWebWheelEvent(struct wpe_input_axis_event* event, float deviceScaleFactor)
index 4eddb3e..1e4236c 100644 (file)
@@ -1,3 +1,15 @@
+2018-09-18  Claudio Saavedra  <csaavedra@igalia.com>
+
+        [WPE] Implement mouse event modifiers
+        https://bugs.webkit.org/show_bug.cgi?id=189697
+
+        Reviewed by Carlos Garcia Campos.
+
+        * WebKitTestRunner/wpe/EventSenderProxyWPE.cpp:
+        (WTR::wkEventModifiersToWPE):
+        (WTR::EventSenderProxy::mouseDown):
+        (WTR::EventSenderProxy::mouseUp):
+
 2018-09-17  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [WTF] Use Semaphore and BinarySemaphore instead of dispatch_semaphore_t
index 92a3e44..a80d16b 100644 (file)
@@ -104,6 +104,21 @@ static uint32_t modifierForButton(unsigned button)
     RELEASE_ASSERT_NOT_REACHED();
 }
 
+static uint32_t wkEventModifiersToWPE(WKEventModifiers wkModifiers)
+{
+    uint32_t modifiers = 0;
+    if (wkModifiers & kWKEventModifiersShiftKey)
+        modifiers |=  wpe_input_keyboard_modifier_shift;
+    if (wkModifiers & kWKEventModifiersControlKey)
+        modifiers |= wpe_input_keyboard_modifier_control;
+    if (wkModifiers & kWKEventModifiersAltKey)
+        modifiers |= wpe_input_keyboard_modifier_alt;
+    if (wkModifiers & kWKEventModifiersMetaKey)
+        modifiers |= wpe_input_keyboard_modifier_meta;
+
+    return modifiers;
+}
+
 void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers)
 {
     m_clickButton = button;
@@ -113,8 +128,9 @@ void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers)
 
     auto wpeButton = senderButtonToWPEButton(button);
     m_mouseButtonsCurrentlyDown |= modifierForButton(wpeButton);
+    uint32_t modifiers = wkEventModifiersToWPE(wkModifiers);
 
-    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_button, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), wpeButton, m_buttonState, m_mouseButtonsCurrentlyDown };
+    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_button, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), wpeButton, m_buttonState, m_mouseButtonsCurrentlyDown | modifiers };
     wpe_view_backend_dispatch_pointer_event(m_viewBackend, &event);
 }
 
@@ -125,8 +141,9 @@ void EventSenderProxy::mouseUp(unsigned button, WKEventModifiers wkModifiers)
 
     auto wpeButton = senderButtonToWPEButton(button);
     m_mouseButtonsCurrentlyDown &= ~modifierForButton(wpeButton);
+    uint32_t modifiers = wkEventModifiersToWPE(wkModifiers);
 
-    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_button, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), wpeButton, m_buttonState, m_mouseButtonsCurrentlyDown };
+    struct wpe_input_pointer_event event { wpe_input_pointer_event_type_button, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), wpeButton, m_buttonState, m_mouseButtonsCurrentlyDown | modifiers };
     wpe_view_backend_dispatch_pointer_event(m_viewBackend, &event);
 }
 
@@ -169,21 +186,6 @@ void EventSenderProxy::leapForward(int milliseconds)
     m_time += milliseconds / 1000.0;
 }
 
-static uint32_t wkEventModifiersToWPE(WKEventModifiers wkModifiers)
-{
-    uint32_t modifiers = 0;
-    if (wkModifiers & kWKEventModifiersShiftKey)
-        modifiers |=  wpe_input_keyboard_modifier_shift;
-    if (wkModifiers & kWKEventModifiersControlKey)
-        modifiers |= wpe_input_keyboard_modifier_control;
-    if (wkModifiers & kWKEventModifiersAltKey)
-        modifiers |= wpe_input_keyboard_modifier_alt;
-    if (wkModifiers & kWKEventModifiersMetaKey)
-        modifiers |= wpe_input_keyboard_modifier_meta;
-
-    return modifiers;
-}
-
 static uint32_t wpeKeySymForKeyRef(WKStringRef keyRef, unsigned location, uint32_t* modifiers)
 {
     if (location == DOMKeyLocationNumpad) {