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.
This commit is contained in:
Martin Gräßlin 2016-02-19 10:56:17 +01:00
parent 44205fbdb4
commit 5caf331610
2 changed files with 10 additions and 1 deletions

View file

@ -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,

View file

@ -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();