WebKit Bugzilla
Attachment 346464 Details for
Bug 187998
: [WPE] Implement MouseEvent.buttons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
wpe-mouse-buttons.diff (text/plain), 19.43 KB, created by
Carlos Garcia Campos
on 2018-08-03 02:22:56 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2018-08-03 02:22:56 PDT
Size:
19.43 KB
patch
obsolete
>diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 83aedbdde54..5cd05bca72e 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,18 @@ >+2018-08-03 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [WPE] Implement MouseEvent.buttons >+ https://bugs.webkit.org/show_bug.cgi?id=187998 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Pass buttons currently pressed to WebMouseEvent. >+ >+ * Shared/wpe/WebEventFactory.cpp: >+ (WebKit::pressedMouseButtons): Helper to get the pressed buttons mask for the WPE modifiers. >+ (WebKit::WebEventFactory::createWebMouseEvent): Use pressedMouseButtons(). >+ * UIProcess/API/wpe/PageClientImpl.cpp: >+ (WebKit::PageClientImpl::doneWithTouchEvent): Update the event modifiers. >+ > 2018-08-03 Carlos Garcia Campos <cgarcia@igalia.com> > > [WPE] Use WPE key symbols and new API instead of xkbcommon and the key mapper >diff --git a/Source/WebKit/Shared/wpe/WebEventFactory.cpp b/Source/WebKit/Shared/wpe/WebEventFactory.cpp >index f3976c29f61..2a2f519f878 100644 >--- a/Source/WebKit/Shared/wpe/WebEventFactory.cpp >+++ b/Source/WebKit/Shared/wpe/WebEventFactory.cpp >@@ -81,6 +81,31 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(struct wpe_input_keyboa > wallTimeForEventTime(event->time)); > } > >+static inline short pressedMouseButtons(uint32_t modifiers) >+{ >+ // MouseEvent.buttons >+ // https://www.w3.org/TR/uievents/#ref-for-dom-mouseevent-buttons-1 >+ >+ // 0 MUST indicate no button is currently active. >+ short buttons = 0; >+ >+ // 1 MUST indicate the primary button of the device (in general, the left button or the only button on >+ // single-button devices, used to activate a user interface control or select text). >+ if (modifiers & wpe_input_pointer_modifier_button1) >+ buttons |= 1; >+ >+ // 2 MUST indicate the secondary button (in general, the right button, often used to display a context menu), >+ // if present. >+ if (modifiers & wpe_input_pointer_modifier_button2) >+ buttons |= 2; >+ >+ // 4 MUST indicate the auxiliary button (in general, the middle button, often combined with a mouse wheel). >+ if (modifiers & wpe_input_pointer_modifier_button3) >+ buttons |= 4; >+ >+ return buttons; >+} >+ > WebMouseEvent WebEventFactory::createWebMouseEvent(struct wpe_input_pointer_event* event, float deviceScaleFactor) > { > WebEvent::Type type = WebEvent::NoType; >@@ -115,7 +140,7 @@ WebMouseEvent WebEventFactory::createWebMouseEvent(struct wpe_input_pointer_even > // FIXME: Proper button support. Modifiers. deltaX/Y/Z. Click count. > WebCore::IntPoint position(event->x, event->y); > position.scale(1 / deviceScaleFactor); >- return WebMouseEvent(type, button, 0, position, position, >+ return WebMouseEvent(type, button, pressedMouseButtons(event->modifiers), position, position, > 0, 0, 0, clickCount, static_cast<WebEvent::Modifiers>(0), wallTimeForEventTime(event->time)); > } > >diff --git a/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp b/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp >index e7675ebe41c..d87f2fdbafe 100644 >--- a/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp >+++ b/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp >@@ -202,13 +202,14 @@ void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& touchEvent, b > struct wpe_input_pointer_event pointerEvent { > wpe_input_pointer_event_type_null, touchPoint->time, > touchPoint->x, touchPoint->y, >- 1, 0 >+ 1, 0, 0 > }; > > switch (touchPoint->type) { > case wpe_input_touch_event_type_down: > pointerEvent.type = wpe_input_pointer_event_type_button; > pointerEvent.state = 1; >+ pointerEvent.modifiers |= wpe_input_pointer_modifier_button1; > break; > case wpe_input_touch_event_type_motion: > pointerEvent.type = wpe_input_pointer_event_type_motion; >@@ -217,6 +218,7 @@ void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& touchEvent, b > case wpe_input_touch_event_type_up: > pointerEvent.type = wpe_input_pointer_event_type_button; > pointerEvent.state = 0; >+ pointerEvent.modifiers &= ~wpe_input_pointer_modifier_button1; > break; > case wpe_input_pointer_event_type_null: > ASSERT_NOT_REACHED(); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 0161dae410b..6cbfb0197de 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,29 @@ >+2018-08-03 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [WPE] Implement MouseEvent.buttons >+ https://bugs.webkit.org/show_bug.cgi?id=187998 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Pass modifiers to mouse events. >+ >+ * WebKitTestRunner/EventSenderProxy.h: >+ * WebKitTestRunner/wpe/EventSenderProxyWPE.cpp: >+ (WTR::senderButtonToWPEButton): >+ (WTR::modifierForButton): >+ (WTR::EventSenderProxy::mouseDown): >+ (WTR::EventSenderProxy::mouseUp): >+ (WTR::EventSenderProxy::mouseMoveTo): >+ (WTR::EventSenderProxy::mouseScrollBy): >+ (WTR::wkEventModifiersToWPE): >+ (WTR::wpeKeySymForKeyRef): >+ (WTR::EventSenderProxy::keyDown): >+ (WTR::EventSenderProxy::prepareAndDispatchTouchEvent): >+ * wpe/backends/WindowViewBackend.cpp: >+ (WPEToolingBackends::WindowViewBackend::handleKeyEvent): >+ (WPEToolingBackends::WindowViewBackend::modifiers const): >+ * wpe/backends/WindowViewBackend.h: >+ > 2018-08-03 Carlos Garcia Campos <cgarcia@igalia.com> > > [WPE] Use WPE key symbols and new API instead of xkbcommon and the key mapper >diff --git a/Tools/WebKitTestRunner/EventSenderProxy.h b/Tools/WebKitTestRunner/EventSenderProxy.h >index f6e34e46ba3..9d1e60b046f 100644 >--- a/Tools/WebKitTestRunner/EventSenderProxy.h >+++ b/Tools/WebKitTestRunner/EventSenderProxy.h >@@ -141,6 +141,7 @@ private: > #elif PLATFORM(WPE) > struct wpe_view_backend* m_viewBackend; > uint32_t m_buttonState; >+ uint32_t m_mouseButtonsCurrentlyDown { 0 }; > Vector<struct wpe_input_touch_event_raw> m_touchEvents; > HashSet<unsigned, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned>> m_updatedTouchEvents; > #endif >diff --git a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp b/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp >index 1d62f2bb66a..54b13ec6bcd 100644 >--- a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp >+++ b/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp >@@ -68,7 +68,7 @@ EventSenderProxy::~EventSenderProxy() > { > } > >-unsigned senderButtonToWPEButton(unsigned senderButton) >+static unsigned senderButtonToWPEButton(unsigned senderButton) > { > // Tests using the EventSender have a different numbering ordering than the one > // that the WPE port expects. Shuffle these here. >@@ -84,6 +84,33 @@ unsigned senderButtonToWPEButton(unsigned senderButton) > } > } > >+static uint32_t modifierForButton(unsigned button) >+{ >+ uint32_t modifier = 0; >+ >+ switch (button) { >+ case 1: >+ modifier = wpe_input_pointer_modifier_button1; >+ break; >+ case 2: >+ modifier = wpe_input_pointer_modifier_button2; >+ break; >+ case 3: >+ modifier = wpe_input_pointer_modifier_button3; >+ break; >+ case 4: >+ modifier = wpe_input_pointer_modifier_button4; >+ break; >+ case 5: >+ modifier = wpe_input_pointer_modifier_button5; >+ break; >+ default: >+ break; >+ } >+ >+ return modifier; >+} >+ > void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers) > { > m_clickButton = button; >@@ -91,7 +118,10 @@ void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers) > m_clickTime = m_time; > m_buttonState = ButtonPressed; > >- 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), senderButtonToWPEButton(button), m_buttonState}; >+ auto wpeButton = senderButtonToWPEButton(button); >+ m_mouseButtonsCurrentlyDown |= modifierForButton(wpeButton); >+ >+ 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 }; > wpe_view_backend_dispatch_pointer_event(m_viewBackend, &event); > } > >@@ -100,7 +130,10 @@ void EventSenderProxy::mouseUp(unsigned button, WKEventModifiers wkModifiers) > m_buttonState = ButtonReleased; > m_clickButton = kWKEventMouseButtonNoButton; > >- 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), senderButtonToWPEButton(button), m_buttonState}; >+ auto wpeButton = senderButtonToWPEButton(button); >+ m_mouseButtonsCurrentlyDown &= ~modifierForButton(wpeButton); >+ >+ 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 }; > wpe_view_backend_dispatch_pointer_event(m_viewBackend, &event); > } > >@@ -109,7 +142,7 @@ void EventSenderProxy::mouseMoveTo(double x, double y) > m_position.x = x; > m_position.y = y; > >- struct wpe_input_pointer_event event { wpe_input_pointer_event_type_motion, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), static_cast<uint32_t>(m_clickButton), m_buttonState}; >+ struct wpe_input_pointer_event event { wpe_input_pointer_event_type_motion, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), static_cast<uint32_t>(m_clickButton), m_buttonState, m_mouseButtonsCurrentlyDown }; > wpe_view_backend_dispatch_pointer_event(m_viewBackend, &event); > } > >@@ -120,11 +153,11 @@ void EventSenderProxy::mouseScrollBy(int horizontal, int vertical) > return; > > if (horizontal) { >- struct wpe_input_axis_event event = { wpe_input_axis_event_type_motion, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), HorizontalScroll, horizontal}; >+ struct wpe_input_axis_event event = { wpe_input_axis_event_type_motion, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), HorizontalScroll, horizontal, 0}; > wpe_view_backend_dispatch_axis_event(m_viewBackend, &event); > } > if (vertical) { >- struct wpe_input_axis_event event = { wpe_input_axis_event_type_motion, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), VerticalScroll, vertical}; >+ struct wpe_input_axis_event event = { wpe_input_axis_event_type_motion, static_cast<uint32_t>(m_time), static_cast<int>(m_position.x), static_cast<int>(m_position.y), VerticalScroll, vertical, 0}; > wpe_view_backend_dispatch_axis_event(m_viewBackend, &event); > } > } >@@ -143,9 +176,9 @@ void EventSenderProxy::leapForward(int milliseconds) > m_time += milliseconds / 1000.0; > } > >-static uint8_t wkEventModifiersToWPE(WKEventModifiers wkModifiers) >+static uint32_t wkEventModifiersToWPE(WKEventModifiers wkModifiers) > { >- uint8_t modifiers = 0; >+ uint32_t modifiers = 0; > if (wkModifiers & kWKEventModifiersShiftKey) > modifiers |= wpe_input_keyboard_modifier_shift; > if (wkModifiers & kWKEventModifiersControlKey) >@@ -158,7 +191,7 @@ static uint8_t wkEventModifiersToWPE(WKEventModifiers wkModifiers) > return modifiers; > } > >-static uint32_t wpeKeySymForKeyRef(WKStringRef keyRef, unsigned location, uint8_t* modifiers) >+static uint32_t wpeKeySymForKeyRef(WKStringRef keyRef, unsigned location, uint32_t* modifiers) > { > if (location == DOMKeyLocationNumpad) { > if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow")) >@@ -268,7 +301,7 @@ static uint32_t wpeKeySymForKeyRef(WKStringRef keyRef, unsigned location, uint8_ > > void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers wkModifiers, unsigned location) > { >- uint8_t modifiers = wkEventModifiersToWPE(wkModifiers); >+ uint32_t modifiers = wkEventModifiersToWPE(wkModifiers); > uint32_t keySym = wpeKeySymForKeyRef(keyRef, location, &modifiers); > // FIXME: we don't have a way to get hardware key code in WPE. > struct wpe_input_keyboard_event event { static_cast<uint32_t>(m_time), keySym, 0, true, modifiers}; >@@ -326,7 +359,7 @@ void EventSenderProxy::removeUpdatedTouchEvents() > void EventSenderProxy::prepareAndDispatchTouchEvent(enum wpe_input_touch_event_type eventType) > { > auto updatedEvents = getUpdatedTouchEvents(); >- struct wpe_input_touch_event event = { updatedEvents.data(), updatedEvents.size(), eventType, 0, static_cast<uint32_t>(m_time) }; >+ struct wpe_input_touch_event event = { updatedEvents.data(), updatedEvents.size(), eventType, 0, static_cast<uint32_t>(m_time), 0 }; > wpe_view_backend_dispatch_touch_event(m_viewBackend, &event); > if (eventType == wpe_input_touch_event_type_up) > removeUpdatedTouchEvents(); >diff --git a/Tools/wpe/backends/WindowViewBackend.cpp b/Tools/wpe/backends/WindowViewBackend.cpp >index ef5af4839e9..ab21e5ae269 100644 >--- a/Tools/wpe/backends/WindowViewBackend.cpp >+++ b/Tools/wpe/backends/WindowViewBackend.cpp >@@ -129,8 +129,10 @@ const struct wl_pointer_listener WindowViewBackend::s_pointerListener = { > [](void* data, struct wl_pointer*, uint32_t /*serial*/, struct wl_surface* surface, wl_fixed_t, wl_fixed_t) > { > auto& window = *static_cast<WindowViewBackend*>(data); >- if (window.m_surface == surface) >+ if (window.m_surface == surface) { > window.m_seatData.pointer.target = surface; >+ window.m_seatData.pointer.modifiers = 0; >+ } > }, > // leave > [](void* data, struct wl_pointer*, uint32_t /*serial*/, struct wl_surface* surface) >@@ -149,7 +151,7 @@ const struct wl_pointer_listener WindowViewBackend::s_pointerListener = { > > if (window.m_seatData.pointer.target) { > struct wpe_input_pointer_event event = { wpe_input_pointer_event_type_motion, >- time, x, y, window.m_seatData.pointer.button, window.m_seatData.pointer.state }; >+ time, x, y, window.m_seatData.pointer.button, window.m_seatData.pointer.state, window.modifiers() }; > window.dispatchInputPointerEvent(&event); > } > }, >@@ -165,9 +167,35 @@ const struct wl_pointer_listener WindowViewBackend::s_pointerListener = { > window.m_seatData.pointer.button = !!state ? button : 0; > window.m_seatData.pointer.state = state; > >+ uint32_t modifier = 0; >+ switch (button) { >+ case 1: >+ modifier = wpe_input_pointer_modifier_button1; >+ break; >+ case 2: >+ modifier = wpe_input_pointer_modifier_button2; >+ break; >+ case 3: >+ modifier = wpe_input_pointer_modifier_button3; >+ break; >+ case 4: >+ modifier = wpe_input_pointer_modifier_button4; >+ break; >+ case 5: >+ modifier = wpe_input_pointer_modifier_button5; >+ break; >+ default: >+ break; >+ } >+ >+ if (state) >+ window.m_seatData.pointer.modifiers |= modifier; >+ else >+ window.m_seatData.pointer.modifiers &= ~modifier; >+ > if (window.m_seatData.pointer.target) { > struct wpe_input_pointer_event event = { wpe_input_pointer_event_type_button, >- time, window.m_seatData.pointer.coords.first, window.m_seatData.pointer.coords.second, button, state }; >+ time, window.m_seatData.pointer.coords.first, window.m_seatData.pointer.coords.second, button, state, window.modifiers() }; > window.dispatchInputPointerEvent(&event); > } > }, >@@ -177,7 +205,7 @@ const struct wl_pointer_listener WindowViewBackend::s_pointerListener = { > auto& window = *static_cast<WindowViewBackend*>(data); > if (window.m_seatData.pointer.target) { > struct wpe_input_axis_event event = { wpe_input_axis_event_type_motion, >- time, window.m_seatData.pointer.coords.first, window.m_seatData.pointer.coords.second, axis, -wl_fixed_to_int(value) }; >+ time, window.m_seatData.pointer.coords.first, window.m_seatData.pointer.coords.second, axis, -wl_fixed_to_int(value), window.modifiers() }; > window.dispatchInputAxisEvent(&event); > } > }, >@@ -325,7 +353,7 @@ const struct wl_touch_listener WindowViewBackend::s_touchListener = { > memcpy(&seatData.touch.points[id], &rawEvent, sizeof(struct wpe_input_touch_event_raw)); > > struct wpe_input_touch_event event = { seatData.touch.points, 10, >- rawEvent.type, rawEvent.id, rawEvent.time }; >+ rawEvent.type, rawEvent.id, rawEvent.time, window.modifiers() }; > window.dispatchInputTouchEvent(&event); > }, > // up >@@ -343,7 +371,7 @@ const struct wl_touch_listener WindowViewBackend::s_touchListener = { > memcpy(&seatData.touch.points[id], &rawEvent, sizeof(struct wpe_input_touch_event_raw)); > > struct wpe_input_touch_event event = { seatData.touch.points, 10, >- rawEvent.type, rawEvent.id, rawEvent.time }; >+ rawEvent.type, rawEvent.id, rawEvent.time, window.modifiers() }; > window.dispatchInputTouchEvent(&event); > > memset(&seatData.touch.points[id], 0x00, sizeof(struct wpe_input_touch_event_raw)); >@@ -361,7 +389,7 @@ const struct wl_touch_listener WindowViewBackend::s_touchListener = { > memcpy(&seatData.touch.points[id], &rawEvent, sizeof(struct wpe_input_touch_event_raw)); > > struct wpe_input_touch_event event = { seatData.touch.points, 10, >- rawEvent.type, rawEvent.id, rawEvent.time }; >+ rawEvent.type, rawEvent.id, rawEvent.time, window.modifiers() }; > window.dispatchInputTouchEvent(&event); > }, > // frame >@@ -660,9 +688,17 @@ void WindowViewBackend::handleKeyEvent(uint32_t key, uint32_t state, uint32_t ti > } > > if (m_seatData.keyboard.target) { >- struct wpe_input_keyboard_event event = { time, keysym, key, !!state, xkb.modifiers }; >+ struct wpe_input_keyboard_event event = { time, keysym, key, !!state, modifiers() }; > dispatchInputKeyboardEvent(&event); > } > } > >+uint32_t WindowViewBackend::modifiers() const >+{ >+ uint32_t mask = m_seatData.xkb.modifiers; >+ if (m_seatData.pointer.object) >+ mask |= m_seatData.pointer.modifiers; >+ return mask; >+} >+ > } // namespace WPEToolingBackends >diff --git a/Tools/wpe/backends/WindowViewBackend.h b/Tools/wpe/backends/WindowViewBackend.h >index 134fe7c2b23..7aeb82a3218 100644 >--- a/Tools/wpe/backends/WindowViewBackend.h >+++ b/Tools/wpe/backends/WindowViewBackend.h >@@ -57,6 +57,7 @@ private: > static const struct zxdg_toplevel_v6_listener s_xdgToplevelListener; > > void handleKeyEvent(uint32_t key, uint32_t state, uint32_t time); >+ uint32_t modifiers() const; > > struct SeatData { > struct { >@@ -65,6 +66,7 @@ private: > std::pair<int, int> coords { 0, 0 }; > uint32_t button { 0 }; > uint32_t state { 0 }; >+ uint32_t modifiers { 0 }; > } pointer; > > struct { >@@ -87,7 +89,7 @@ private: > xkb_mod_index_t alt { 0 }; > xkb_mod_index_t shift { 0 }; > } indexes; >- uint8_t modifiers { 0 }; >+ uint32_t modifiers { 0 }; > struct xkb_compose_table* composeTable { nullptr }; > struct xkb_compose_state* composeState { nullptr }; > } xkb;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
zan
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187998
:
345753
| 346464