From 5caf33161069d528e8c26bc58e458d7e0d51720a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 19 Feb 2016 10:56:17 +0100 Subject: [PATCH] Ask Xkb before starting to repeat a key The keymap knows whether the key should repeat or not. E.g. no need to trigger repeat for modifier keys. --- keyboard_input.cpp | 10 +++++++++- keyboard_input.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/keyboard_input.cpp b/keyboard_input.cpp index c496ef46fa..fd98d0820f 100644 --- a/keyboard_input.cpp +++ b/keyboard_input.cpp @@ -291,6 +291,14 @@ quint32 Xkb::getGroup() return xkb_state_serialize_layout(m_state, XKB_STATE_LAYOUT_EFFECTIVE); } +bool Xkb::shouldKeyRepeat(quint32 key) const +{ + if (!m_keymap) { + return false; + } + return xkb_keymap_key_repeats(m_keymap, key) != 0; +} + KeyboardInputRedirection::KeyboardInputRedirection(InputRedirection *parent) : QObject(parent) , m_input(parent) @@ -397,7 +405,7 @@ void KeyboardInputRedirection::processKey(uint32_t key, InputRedirection::Keyboa autoRepeat); event.setTimestamp(time); if (state == InputRedirection::KeyboardKeyPressed) { - if (waylandServer()->seat()->keyRepeatDelay() != 0) { + if (m_xkb->shouldKeyRepeat(key) && waylandServer()->seat()->keyRepeatDelay() != 0) { QTimer *timer = new QTimer; timer->setInterval(waylandServer()->seat()->keyRepeatDelay()); connect(timer, &QTimer::timeout, this, diff --git a/keyboard_input.h b/keyboard_input.h index dbbb75e98f..7b11c41af3 100644 --- a/keyboard_input.h +++ b/keyboard_input.h @@ -54,6 +54,7 @@ public: QString toString(xkb_keysym_t keysym); Qt::Key toQtKey(xkb_keysym_t keysym); Qt::KeyboardModifiers modifiers() const; + bool shouldKeyRepeat(quint32 key) const; quint32 getMods(quint32 components); quint32 getGroup();