Diff
Modified: trunk/Source/WebKit/ChangeLog (234540 => 234541)
--- trunk/Source/WebKit/ChangeLog 2018-08-03 09:16:18 UTC (rev 234540)
+++ trunk/Source/WebKit/ChangeLog 2018-08-03 09:38:18 UTC (rev 234541)
@@ -1,5 +1,20 @@
2018-08-03 Carlos Garcia Campos <cgar...@igalia.com>
+ [WPE] Implement MouseEvent.buttons
+ https://bugs.webkit.org/show_bug.cgi?id=187998
+
+ Reviewed by Žan Doberšek.
+
+ 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 <cgar...@igalia.com>
+
[WPE] Use WPE key symbols and new API instead of xkbcommon and the key mapper
https://bugs.webkit.org/show_bug.cgi?id=188093
Modified: trunk/Source/WebKit/Shared/wpe/WebEventFactory.cpp (234540 => 234541)
--- trunk/Source/WebKit/Shared/wpe/WebEventFactory.cpp 2018-08-03 09:16:18 UTC (rev 234540)
+++ trunk/Source/WebKit/Shared/wpe/WebEventFactory.cpp 2018-08-03 09:38:18 UTC (rev 234541)
@@ -81,6 +81,31 @@
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 @@
// 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));
}
Modified: trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp (234540 => 234541)
--- trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp 2018-08-03 09:16:18 UTC (rev 234540)
+++ trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp 2018-08-03 09:38:18 UTC (rev 234541)
@@ -197,7 +197,7 @@
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) {
@@ -204,6 +204,7 @@
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;
@@ -212,6 +213,7 @@
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();
Modified: trunk/Tools/ChangeLog (234540 => 234541)
--- trunk/Tools/ChangeLog 2018-08-03 09:16:18 UTC (rev 234540)
+++ trunk/Tools/ChangeLog 2018-08-03 09:38:18 UTC (rev 234541)
@@ -1,5 +1,31 @@
2018-08-03 Carlos Garcia Campos <cgar...@igalia.com>
+ [WPE] Implement MouseEvent.buttons
+ https://bugs.webkit.org/show_bug.cgi?id=187998
+
+ Reviewed by Žan Doberšek.
+
+ 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 <cgar...@igalia.com>
+
[WPE] Use WPE key symbols and new API instead of xkbcommon and the key mapper
https://bugs.webkit.org/show_bug.cgi?id=188093
Modified: trunk/Tools/WebKitTestRunner/EventSenderProxy.h (234540 => 234541)
--- trunk/Tools/WebKitTestRunner/EventSenderProxy.h 2018-08-03 09:16:18 UTC (rev 234540)
+++ trunk/Tools/WebKitTestRunner/EventSenderProxy.h 2018-08-03 09:38:18 UTC (rev 234541)
@@ -141,6 +141,7 @@
#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
Modified: trunk/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp (234540 => 234541)
--- trunk/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp 2018-08-03 09:16:18 UTC (rev 234540)
+++ trunk/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp 2018-08-03 09:38:18 UTC (rev 234541)
@@ -68,7 +68,7 @@
{
}
-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,26 @@
}
}
+static uint32_t modifierForButton(unsigned button)
+{
+ switch (button) {
+ case 1:
+ return wpe_input_pointer_modifier_button1;
+ case 2:
+ return wpe_input_pointer_modifier_button2;
+ case 3:
+ return wpe_input_pointer_modifier_button3;
+ case 4:
+ return wpe_input_pointer_modifier_button4;
+ case 5:
+ return wpe_input_pointer_modifier_button5;
+ default:
+ return 0;
+ }
+
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
void EventSenderProxy::mouseDown(unsigned button, WKEventModifiers wkModifiers)
{
m_clickButton = button;
@@ -91,7 +111,10 @@
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 +123,10 @@
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 +135,7 @@
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 +146,11 @@
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 +169,9 @@
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 +184,7 @@
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 +294,7 @@
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 +352,7 @@
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();
Modified: trunk/Tools/wpe/backends/WindowViewBackend.cpp (234540 => 234541)
--- trunk/Tools/wpe/backends/WindowViewBackend.cpp 2018-08-03 09:16:18 UTC (rev 234540)
+++ trunk/Tools/wpe/backends/WindowViewBackend.cpp 2018-08-03 09:38:18 UTC (rev 234541)
@@ -129,8 +129,10 @@
[](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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
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
Modified: trunk/Tools/wpe/backends/WindowViewBackend.h (234540 => 234541)
--- trunk/Tools/wpe/backends/WindowViewBackend.h 2018-08-03 09:16:18 UTC (rev 234540)
+++ trunk/Tools/wpe/backends/WindowViewBackend.h 2018-08-03 09:38:18 UTC (rev 234541)
@@ -57,6 +57,7 @@
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 @@
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 @@
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;