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.
This commit is contained in:
Martin Gräßlin 2016-02-19 12:08:45 +01:00
parent 2e36c4b7ca
commit 83a4fe5408
3 changed files with 4 additions and 30 deletions

View file

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

View file

@ -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<Qt::Key>(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) {

View file

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