diff options
Diffstat (limited to 'src/platformsupport/input')
5 files changed, 21 insertions, 14 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 47a65eded8..b21d5d9ef5 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -225,7 +225,8 @@ void QEvdevKeyboardHandler::readKeycode() void QEvdevKeyboardHandler::processKeyEvent(int nativecode, int unicode, int qtcode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat) { - QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(modifiers, qtcode); + if (!autoRepeat) + QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(QEvdevKeyboardHandler::toQtModifiers(m_modifiers)); QWindowSystemInterface::handleExtendedKeyEvent(0, (isPress ? QEvent::KeyPress : QEvent::KeyRelease), qtcode, modifiers, nativecode + 8, 0, int(modifiers), diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp index 5264736dd6..ae81bca00f 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp @@ -148,14 +148,13 @@ void QEvdevMouseManager::handleMouseEvent(int x, int y, bool abs, Qt::MouseButto QPoint pos(m_x + m_xoffset, m_y + m_yoffset); // Cannot track the keyboard modifiers ourselves here. Instead, report the // modifiers from the last key event that has been seen by QGuiApplication. - Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers(); - QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, button, type, mods); + QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, button, type, QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers()); } void QEvdevMouseManager::handleWheelEvent(QPoint delta) { QPoint pos(m_x + m_xoffset, m_y + m_yoffset); - QWindowSystemInterface::handleWheelEvent(0, pos, pos, QPoint(), delta, QGuiApplication::keyboardModifiers()); + QWindowSystemInterface::handleWheelEvent(0, pos, pos, QPoint(), delta, QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers()); } void QEvdevMouseManager::addMouse(const QString &deviceNode) diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp index ec01f95947..5152725468 100644 --- a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp +++ b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp @@ -135,7 +135,8 @@ QLibInputKeyboard::QLibInputKeyboard() #ifndef QT_NO_XKBCOMMON_EVDEV : m_ctx(0), m_keymap(0), - m_state(0) + m_state(0), + m_mods(Qt::NoModifier) #endif { #ifndef QT_NO_XKBCOMMON_EVDEV @@ -203,22 +204,27 @@ void QLibInputKeyboard::processKey(libinput_event_keyboard *e) Qt::KeyboardModifiers mods = Qt::NoModifier; const int qtkey = keysymToQtKey(sym, &mods, text); - xkb_state_component modtype = xkb_state_component(XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED); - if (xkb_state_mod_index_is_active(m_state, m_modindex[0], modtype) && (qtkey != Qt::Key_Control || !pressed)) + if (qtkey == Qt::Key_Control) mods |= Qt::ControlModifier; - if (xkb_state_mod_index_is_active(m_state, m_modindex[1], modtype) && (qtkey != Qt::Key_Alt || !pressed)) + if (qtkey == Qt::Key_Alt) mods |= Qt::AltModifier; - if (xkb_state_mod_index_is_active(m_state, m_modindex[2], modtype) && (qtkey != Qt::Key_Shift || !pressed)) + if (qtkey == Qt::Key_Shift) mods |= Qt::ShiftModifier; - if (xkb_state_mod_index_is_active(m_state, m_modindex[3], modtype) && (qtkey != Qt::Key_Meta || !pressed)) + if (qtkey == Qt::Key_Meta) mods |= Qt::MetaModifier; - xkb_state_update_key(m_state, k, pressed ? XKB_KEY_DOWN : XKB_KEY_UP); - QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(mods, qtkey); + if (mods != Qt::NoModifier) { + if (pressed) + m_mods |= mods; + else + m_mods &= ~mods; + + QGuiApplicationPrivate::inputDeviceManager()->setKeyboardModifiers(m_mods); + } QWindowSystemInterface::handleExtendedKeyEvent(nullptr, pressed ? QEvent::KeyPress : QEvent::KeyRelease, - qtkey, mods, k, sym, mods, text); + qtkey, m_mods, k, sym, m_mods, text); if (pressed && xkb_keymap_key_repeats(m_keymap, k)) { m_repeatData.qtkey = qtkey; diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h index b7ee8a363f..9e09bccd79 100644 --- a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h +++ b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h @@ -93,6 +93,7 @@ private: QString unicodeText; int repeatCount; } m_repeatData; + Qt::KeyboardModifiers m_mods; #endif }; diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp index cb08ab53b2..c54b61fc66 100644 --- a/src/platformsupport/input/libinput/qlibinputpointer.cpp +++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp @@ -125,7 +125,7 @@ void QLibInputPointer::processAxis(libinput_event_pointer *e) #endif const int factor = 8; angleDelta *= -factor; - Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers(); + Qt::KeyboardModifiers mods = QGuiApplicationPrivate::inputDeviceManager()->keyboardModifiers(); QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, QPoint(), angleDelta, mods); } |