WebKit Bugzilla
Attachment 346268 Details for
Bug 188216
: [WPE] Use the new key mapper API from WPEBackend
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
wpe-key-mapper.diff (text/plain), 8.21 KB, created by
Carlos Garcia Campos
on 2018-08-01 03:12:21 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2018-08-01 03:12:21 PDT
Size:
8.21 KB
patch
obsolete
>diff --git a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp b/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp >index 54b13ec6bcd..69a4bd89ec5 100644 >--- a/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp >+++ b/Tools/WebKitTestRunner/wpe/EventSenderProxyWPE.cpp >@@ -303,11 +303,14 @@ void EventSenderProxy::keyDown(WKStringRef keyRef, WKEventModifiers 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}; >+ struct wpe_input_key_mapper_map_entry* entries; >+ uint32_t entriesCount; >+ wpe_input_key_mapper_get_entries_for_key_code(wpe_input_key_mapper_get_singleton(), keySym, &entries, &entriesCount); >+ struct wpe_input_keyboard_event event { static_cast<uint32_t>(m_time), keySym, entriesCount ? entries[0].hardware_key_code : 0, true, modifiers}; > wpe_view_backend_dispatch_keyboard_event(m_viewBackend, &event); > event.pressed = false; > wpe_view_backend_dispatch_keyboard_event(m_viewBackend, &event); >+ free(entries); > } > > void EventSenderProxy::addTouchPoint(int x, int y) >diff --git a/Tools/wpe/backends/WindowViewBackend.cpp b/Tools/wpe/backends/WindowViewBackend.cpp >index ab21e5ae269..54f44ff4cbe 100644 >--- a/Tools/wpe/backends/WindowViewBackend.cpp >+++ b/Tools/wpe/backends/WindowViewBackend.cpp >@@ -217,36 +217,9 @@ const struct wl_pointer_listener WindowViewBackend::s_pointerListener = { > > const struct wl_keyboard_listener WindowViewBackend::s_keyboardListener = { > // keymap >- [](void* data, struct wl_keyboard*, uint32_t format, int fd, uint32_t size) >+ [](void*, struct wl_keyboard*, uint32_t format, int fd, uint32_t size) > { >- auto& window = *static_cast<WindowViewBackend*>(data); >- if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { >- close(fd); >- return; >- } >- >- void* mapping = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); >- if (mapping == MAP_FAILED) { >- close(fd); >- return; >- } >- >- auto& xkb = window.m_seatData.xkb; >- xkb.keymap = xkb_keymap_new_from_string(xkb.context, static_cast<char*>(mapping), >- XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); >- munmap(mapping, size); >- close(fd); >- >- if (!xkb.keymap) >- return; >- >- xkb.state = xkb_state_new(xkb.keymap); >- if (!xkb.state) >- return; >- >- xkb.indexes.control = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_CTRL); >- xkb.indexes.alt = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_ALT); >- xkb.indexes.shift = xkb_keymap_mod_get_index(xkb.keymap, XKB_MOD_NAME_SHIFT); >+ wpe_input_key_mapper_update_from_fd(wpe_input_key_mapper_get_singleton(), format, fd, size); > }, > // enter > [](void* data, struct wl_keyboard*, uint32_t /*serial*/, struct wl_surface* surface, struct wl_array*) >@@ -282,7 +255,7 @@ const struct wl_keyboard_listener WindowViewBackend::s_keyboardListener = { > g_source_remove(seatData.repeatData.eventSource); > seatData.repeatData = { 0, 0, 0, 0 }; > } else if (state == WL_KEYBOARD_KEY_STATE_PRESSED >- && xkb_keymap_key_repeats(seatData.xkb.keymap, key)) { >+ && wpe_input_key_mapper_key_repeats(wpe_input_key_mapper_get_singleton(), key)) { > > if (seatData.repeatData.eventSource) > g_source_remove(seatData.repeatData.eventSource); >@@ -305,19 +278,8 @@ const struct wl_keyboard_listener WindowViewBackend::s_keyboardListener = { > // modifiers > [](void* data, struct wl_keyboard*, uint32_t /*serial*/, uint32_t depressedMods, uint32_t latchedMods, uint32_t lockedMods, uint32_t group) > { >- auto& xkb = static_cast<WindowViewBackend*>(data)->m_seatData.xkb; >- >- xkb_state_update_mask(xkb.state, depressedMods, latchedMods, lockedMods, 0, 0, group); >- >- auto& modifiers = xkb.modifiers; >- modifiers = 0; >- auto component = static_cast<xkb_state_component>(XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED); >- if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.control, component)) >- modifiers |= wpe_input_keyboard_modifier_control; >- if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.alt, component)) >- modifiers |= wpe_input_keyboard_modifier_alt; >- if (xkb_state_mod_index_is_active(xkb.state, xkb.indexes.shift, component)) >- modifiers |= wpe_input_keyboard_modifier_shift; >+ auto& keyboard = static_cast<WindowViewBackend*>(data)->m_seatData.keyboard; >+ keyboard.modifiers = wpe_input_key_mapper_get_modifiers(wpe_input_key_mapper_get_singleton(), depressedMods, latchedMods, lockedMods, group); > }, > // repeat_info > [](void* data, struct wl_keyboard*, int32_t rate, int32_t delay) >@@ -481,11 +443,6 @@ WindowViewBackend::WindowViewBackend(uint32_t width, uint32_t height) > > if (m_seat) > wl_seat_add_listener(m_seat, &s_seatListener, this); >- >- m_seatData.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); >- m_seatData.xkb.composeTable = xkb_compose_table_new_from_locale(m_seatData.xkb.context, setlocale(LC_CTYPE, nullptr), XKB_COMPOSE_COMPILE_NO_FLAGS); >- if (m_seatData.xkb.composeTable) >- m_seatData.xkb.composeState = xkb_compose_state_new(m_seatData.xkb.composeTable, XKB_COMPOSE_STATE_NO_FLAGS); > } > > m_eventSource = g_source_new(&EventSource::sourceFuncs, sizeof(EventSource)); >@@ -677,15 +634,9 @@ void WindowViewBackend::displayBuffer(EGLImageKHR image) > > void WindowViewBackend::handleKeyEvent(uint32_t key, uint32_t state, uint32_t time) > { >- auto& xkb = m_seatData.xkb; >- uint32_t keysym = xkb_state_key_get_one_sym(xkb.state, key); >- >- if (xkb.composeState >- && state == WL_KEYBOARD_KEY_STATE_PRESSED >- && xkb_compose_state_feed(xkb.composeState, keysym) == XKB_COMPOSE_FEED_ACCEPTED >- && xkb_compose_state_get_status(xkb.composeState) == XKB_COMPOSE_COMPOSED) { >- keysym = xkb_compose_state_get_one_sym(xkb.composeState); >- } >+ uint32_t keysym = wpe_input_key_mapper_get_key_code(wpe_input_key_mapper_get_singleton(), key, state == WL_KEYBOARD_KEY_STATE_PRESSED); >+ if (!keysym) >+ return; > > if (m_seatData.keyboard.target) { > struct wpe_input_keyboard_event event = { time, keysym, key, !!state, modifiers() }; >@@ -695,7 +646,7 @@ void WindowViewBackend::handleKeyEvent(uint32_t key, uint32_t state, uint32_t ti > > uint32_t WindowViewBackend::modifiers() const > { >- uint32_t mask = m_seatData.xkb.modifiers; >+ uint32_t mask = m_seatData.keyboard.modifiers; > if (m_seatData.pointer.object) > mask |= m_seatData.pointer.modifiers; > return mask; >diff --git a/Tools/wpe/backends/WindowViewBackend.h b/Tools/wpe/backends/WindowViewBackend.h >index 7aeb82a3218..b7737fc1069 100644 >--- a/Tools/wpe/backends/WindowViewBackend.h >+++ b/Tools/wpe/backends/WindowViewBackend.h >@@ -29,8 +29,6 @@ > #include "xdg-shell-unstable-v6-client-protocol.h" > #include <glib.h> > #include <unordered_map> >-#include <xkbcommon/xkbcommon.h> >-#include <xkbcommon/xkbcommon-compose.h> > > typedef void* EGLImageKHR; > typedef void* EGLSurface; >@@ -72,6 +70,7 @@ private: > struct { > struct wl_keyboard* object { nullptr }; > struct wl_surface* target { nullptr }; >+ uint32_t modifiers { 0 }; > } keyboard; > > struct { >@@ -80,20 +79,6 @@ private: > bool tracking { false }; > } touch; > >- struct { >- struct xkb_context* context { nullptr }; >- struct xkb_keymap* keymap { nullptr }; >- struct xkb_state* state { nullptr }; >- struct { >- xkb_mod_index_t control { 0 }; >- xkb_mod_index_t alt { 0 }; >- xkb_mod_index_t shift { 0 }; >- } indexes; >- uint32_t modifiers { 0 }; >- struct xkb_compose_table* composeTable { nullptr }; >- struct xkb_compose_state* composeState { nullptr }; >- } xkb; >- > struct { > int32_t rate { 0 }; > int32_t delay { 0 };
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 188216
:
346268
|
346467