diff options
Diffstat (limited to 'src/compositor/wayland_wrapper/qwlkeyboard.cpp')
-rw-r--r-- | src/compositor/wayland_wrapper/qwlkeyboard.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard.cpp b/src/compositor/wayland_wrapper/qwlkeyboard.cpp index 59b69a3cf..060965663 100644 --- a/src/compositor/wayland_wrapper/qwlkeyboard.cpp +++ b/src/compositor/wayland_wrapper/qwlkeyboard.cpp @@ -146,7 +146,15 @@ void Keyboard::setFocus(Surface* surface) void Keyboard::setKeymap(const QWaylandKeymap &keymap) { m_keymap = keymap; - m_pendingKeymap = true; + + // If there is no key currently pressed, update right away the keymap + // Otherwise, delay the update when keys are released + // see http://lists.freedesktop.org/archives/wayland-devel/2013-October/011395.html + if (m_keys.isEmpty()) { + updateKeymap(); + } else { + m_pendingKeymap = true; + } } void Keyboard::focusDestroyed(void *data) @@ -216,17 +224,9 @@ void Keyboard::key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state) } } -void Keyboard::sendKeyEvent(uint code, uint32_t state) +void Keyboard::keyEvent(uint code, uint32_t state) { - // There must be no keys pressed when changing the keymap, - // see http://lists.freedesktop.org/archives/wayland-devel/2013-October/011395.html - if (m_pendingKeymap && m_keys.isEmpty()) - updateKeymap(); - - uint32_t time = m_compositor->currentTimeMsecs(); - uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); uint key = code - 8; - m_grab->key(serial, time, key, state); if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { m_keys << key; } else { @@ -236,7 +236,14 @@ void Keyboard::sendKeyEvent(uint code, uint32_t state) } } } - updateModifierState(code, state); +} + +void Keyboard::sendKeyEvent(uint code, uint32_t state) +{ + uint32_t time = m_compositor->currentTimeMsecs(); + uint32_t serial = wl_display_next_serial(m_compositor->wl_display()); + uint key = code - 8; + m_grab->key(serial, time, key, state); } void Keyboard::modifiers(uint32_t serial, uint32_t mods_depressed, @@ -280,6 +287,11 @@ void Keyboard::updateModifierState(uint code, uint32_t state) void Keyboard::updateKeymap() { + // There must be no keys pressed when changing the keymap, + // see http://lists.freedesktop.org/archives/wayland-devel/2013-October/011395.html + if (!m_pendingKeymap || !m_keys.isEmpty()) + return; + m_pendingKeymap = false; #ifndef QT_NO_WAYLAND_XKB if (!m_context) |