WebKit Bugzilla
Attachment 345753 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]
WIP
wpe-mouse-buttons-wip.diff (text/plain), 10.26 KB, created by
Carlos Garcia Campos
on 2018-07-25 04:52:56 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2018-07-25 04:52:56 PDT
Size:
10.26 KB
patch
obsolete
>diff --git a/Source/WebKit/Shared/wpe/WebEventFactory.cpp b/Source/WebKit/Shared/wpe/WebEventFactory.cpp >index 7ceaf6697b2..2f37bfa6aed 100644 >--- a/Source/WebKit/Shared/wpe/WebEventFactory.cpp >+++ b/Source/WebKit/Shared/wpe/WebEventFactory.cpp >@@ -94,6 +94,31 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(struct wpe_input_keyboa > modifiersForEvent(event), wallTimeForEventTime(event->time)); > } > >+static inline short pressedMouseButtons(uint8_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; >@@ -128,7 +153,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 921e17fc522..0817f021bbb 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/WebKitTestRunner/EventSenderProxy.h b/Tools/WebKitTestRunner/EventSenderProxy.h >index f6e34e46ba3..824cc222aec 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; >+ uint8_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 aab11e75515..bb7365ad11d 100644 >--- a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp >+++ b/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp >@@ -70,7 +70,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. >@@ -86,6 +86,33 @@ unsigned senderButtonToWPEButton(unsigned senderButton) > } > } > >+static uint8_t modifierForButton(unsigned button) >+{ >+ uint8_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; >@@ -93,7 +120,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); > } > >@@ -102,7 +132,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); > } > >@@ -111,7 +144,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); > } > >diff --git a/Tools/wpe/backends/WindowViewBackend.cpp b/Tools/wpe/backends/WindowViewBackend.cpp >index f1e6bd59e2a..9860b70e7a4 100644 >--- a/Tools/wpe/backends/WindowViewBackend.cpp >+++ b/Tools/wpe/backends/WindowViewBackend.cpp >@@ -130,8 +130,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) >@@ -166,9 +168,35 @@ const struct wl_pointer_listener WindowViewBackend::s_pointerListener = { > window.m_seatData.pointer.button = !!state ? button : 0; > window.m_seatData.pointer.state = state; > >+ uint8_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.m_seatData.pointer.modifiers }; > window.dispatchInputPointerEvent(&event); > } > }, >diff --git a/Tools/wpe/backends/WindowViewBackend.h b/Tools/wpe/backends/WindowViewBackend.h >index 3f134a939f1..cc7e6452f1a 100644 >--- a/Tools/wpe/backends/WindowViewBackend.h >+++ b/Tools/wpe/backends/WindowViewBackend.h >@@ -65,6 +65,7 @@ private: > std::pair<int, int> coords { 0, 0 }; > uint32_t button { 0 }; > uint32_t state { 0 }; >+ uint8_t modifiers { 0 }; > } pointer; > > struct { >
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187998
:
345753
|
346464