From 83a4fe54084278be80b485134d1d3c1ddf166bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 19 Feb 2016 12:08:45 +0100 Subject: [PATCH] Update keyboard modifier state on seat after each key event The layout might have changed, thus we should notify the client about it. The server ensures that on no state change it's not sent to the client. --- input.cpp | 11 ----------- keyboard_input.cpp | 20 ++++---------------- keyboard_input.h | 3 --- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/input.cpp b/input.cpp index d4c2b3e1ba..bc48b7e6a2 100644 --- a/input.cpp +++ b/input.cpp @@ -792,17 +792,6 @@ void InputRedirection::setupWorkspace() ); } ); - connect(this, &InputRedirection::keyboardModifiersChanged, waylandServer(), - [this] { - if (!waylandServer()->seat()) { - return; - } - waylandServer()->seat()->updateKeyboardModifiers(m_keyboard->xkb()->getMods(XKB_STATE_MODS_DEPRESSED), - m_keyboard->xkb()->getMods(XKB_STATE_MODS_LATCHED), - m_keyboard->xkb()->getMods(XKB_STATE_MODS_LOCKED), - m_keyboard->xkb()->getGroup()); - } - ); connect(workspace(), &Workspace::configChanged, this, &InputRedirection::reconfigure); m_keyboard->init(); diff --git a/keyboard_input.cpp b/keyboard_input.cpp index 5e5eeb2c3b..faf2d4cb76 100644 --- a/keyboard_input.cpp +++ b/keyboard_input.cpp @@ -279,6 +279,10 @@ void Xkb::updateModifiers() mods |= Qt::MetaModifier; } m_modifiers = mods; + waylandServer()->seat()->updateKeyboardModifiers(xkb_state_serialize_mods(m_state, xkb_state_component(XKB_STATE_MODS_DEPRESSED)), + xkb_state_serialize_mods(m_state, xkb_state_component(XKB_STATE_MODS_LATCHED)), + xkb_state_serialize_mods(m_state, xkb_state_component(XKB_STATE_MODS_LOCKED)), + xkb_state_serialize_layout(m_state, XKB_STATE_LAYOUT_EFFECTIVE)); } xkb_keysym_t Xkb::toKeysym(uint32_t key) @@ -309,22 +313,6 @@ Qt::Key Xkb::toQtKey(xkb_keysym_t keysym) return static_cast(key); } -quint32 Xkb::getMods(quint32 components) -{ - if (!m_state) { - return 0; - } - return xkb_state_serialize_mods(m_state, xkb_state_component(components)); -} - -quint32 Xkb::getGroup() -{ - if (!m_state) { - return 0; - } - return xkb_state_serialize_layout(m_state, XKB_STATE_LAYOUT_EFFECTIVE); -} - bool Xkb::shouldKeyRepeat(quint32 key) const { if (!m_keymap) { diff --git a/keyboard_input.h b/keyboard_input.h index cee9ce69ff..ed080f9346 100644 --- a/keyboard_input.h +++ b/keyboard_input.h @@ -58,9 +58,6 @@ public: Qt::KeyboardModifiers modifiers() const; bool shouldKeyRepeat(quint32 key) const; - quint32 getMods(quint32 components); - quint32 getGroup(); - private: xkb_keymap *loadKeymapFromConfig(); xkb_keymap *loadDefaultKeymap();