summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Chedaleux <cedric.chedaleux@orange.com>2015-05-26 10:57:41 +0200
committerCedric Chedaleux <cedric.chedaleux@orange.com>2015-06-16 08:41:23 +0000
commit2d9cd132061562902a9b347b87fd3ba20f434532 (patch)
treed9f4b6481553078e73782aedaa05b8c03193a253
parentaab7f80197c158a71ccf333b6636ec8e4526ad39 (diff)
downloadqtwayland-2d9cd132061562902a9b347b87fd3ba20f434532.tar.gz
qtwayland-2d9cd132061562902a9b347b87fd3ba20f434532.tar.bz2
qtwayland-2d9cd132061562902a9b347b87fd3ba20f434532.zip
update keymap right away when no key is currently pressed
Keymap update was only performed when a key was pressed. A key press right after a keymap update was pretty long. Keymap may therefore be updated if no key is currently pressed. It avoids waiting for the next key press. It must also be set when last key was released and do no need to wait for the next key press. Change-Id: I9646a02f3112c8beb0f1cf90139e2b69af55a9b0 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
-rw-r--r--src/compositor/wayland_wrapper/qwlkeyboard.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard.cpp b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
index a7889fd4..4f1c451b 100644
--- a/src/compositor/wayland_wrapper/qwlkeyboard.cpp
+++ b/src/compositor/wayland_wrapper/qwlkeyboard.cpp
@@ -145,7 +145,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)
@@ -217,11 +225,6 @@ void Keyboard::key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
void Keyboard::sendKeyEvent(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;
@@ -236,6 +239,10 @@ void Keyboard::sendKeyEvent(uint code, uint32_t state)
}
}
updateModifierState(code, state);
+
+ // If keys are no longer pressed, update the keymap
+ if (m_pendingKeymap && m_keys.isEmpty())
+ updateKeymap();
}
void Keyboard::modifiers(uint32_t serial, uint32_t mods_depressed,