[input] Try updating the modifiers after each key press

TODO: send new modifier information to wayland server.
This commit is contained in:
Martin Gräßlin 2015-03-27 14:15:25 +01:00
parent b824175e05
commit 2a39e6290b
2 changed files with 19 additions and 8 deletions

View file

@ -129,6 +129,20 @@ void Xkb::updateModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t
return; return;
} }
xkb_state_update_mask(m_state, modsDepressed, modsLatched, modsLocked, 0, 0, group); xkb_state_update_mask(m_state, modsDepressed, modsLatched, modsLocked, 0, 0, group);
updateModifiers();
}
void Xkb::updateKey(uint32_t key, InputRedirection::KeyboardKeyState state)
{
if (!m_keymap || !m_state) {
return;
}
xkb_state_update_key(m_state, key + 8, static_cast<xkb_key_direction>(state));
updateModifiers();
}
void Xkb::updateModifiers()
{
Qt::KeyboardModifiers mods = Qt::NoModifier; Qt::KeyboardModifiers mods = Qt::NoModifier;
if (xkb_state_mod_index_is_active(m_state, m_shiftModifier, XKB_STATE_MODS_EFFECTIVE) == 1) { if (xkb_state_mod_index_is_active(m_state, m_shiftModifier, XKB_STATE_MODS_EFFECTIVE) == 1) {
mods |= Qt::ShiftModifier; mods |= Qt::ShiftModifier;
@ -145,14 +159,6 @@ void Xkb::updateModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t
m_modifiers = mods; m_modifiers = mods;
} }
void Xkb::updateKey(uint32_t key, InputRedirection::KeyboardKeyState state)
{
if (!m_keymap || !m_state) {
return;
}
xkb_state_update_key(m_state, key + 8, static_cast<xkb_key_direction>(state));
}
xkb_keysym_t Xkb::toKeysym(uint32_t key) xkb_keysym_t Xkb::toKeysym(uint32_t key)
{ {
if (!m_state) { if (!m_state) {
@ -448,7 +454,11 @@ void InputRedirection::processPointerAxis(InputRedirection::PointerAxis axis, qr
void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time) void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time)
{ {
#if HAVE_XKB #if HAVE_XKB
const Qt::KeyboardModifiers oldMods = keyboardModifiers();
m_xkb->updateKey(key, state); m_xkb->updateKey(key, state);
if (oldMods != keyboardModifiers()) {
emit keyboardModifiersChanged(keyboardModifiers(), oldMods);
}
// TODO: pass to internal parts of KWin // TODO: pass to internal parts of KWin
#ifdef KWIN_BUILD_TABBOX #ifdef KWIN_BUILD_TABBOX
if (TabBox::TabBox::self()->isGrabbed()) { if (TabBox::TabBox::self()->isGrabbed()) {

View file

@ -216,6 +216,7 @@ public:
Qt::KeyboardModifiers modifiers() const; Qt::KeyboardModifiers modifiers() const;
private: private:
void updateKeymap(xkb_keymap *keymap); void updateKeymap(xkb_keymap *keymap);
void updateModifiers();
xkb_context *m_context; xkb_context *m_context;
xkb_keymap *m_keymap; xkb_keymap *m_keymap;
xkb_state *m_state; xkb_state *m_state;