Fix for mouse with modifiers handling
Modifier keys are saved in qinputdevicemanager such way that both evdev and libinput can use it the same way, it is also handling the repeating modifier key events. Evdev support is important for VxWorks support because it is using it. Task-number: QTBUG-60694 Change-Id: I49038cb7fe2ad5134b3a37167c19953867ea31c3 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>bb10
parent
ae618e0694
commit
2803cdf758
|
|
@ -109,30 +109,9 @@ Qt::KeyboardModifiers QInputDeviceManager::keyboardModifiers() const
|
|||
return d->keyboardModifiers;
|
||||
}
|
||||
|
||||
void QInputDeviceManager::setKeyboardModifiers(Qt::KeyboardModifiers modsBeforeEvent, int key)
|
||||
void QInputDeviceManager::setKeyboardModifiers(Qt::KeyboardModifiers mods)
|
||||
{
|
||||
Q_D(QInputDeviceManager);
|
||||
Qt::KeyboardModifiers mods;
|
||||
switch (key) {
|
||||
case Qt::Key_Shift:
|
||||
mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::ShiftModifier);
|
||||
break;
|
||||
case Qt::Key_Control:
|
||||
mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::ControlModifier);
|
||||
break;
|
||||
case Qt::Key_Alt:
|
||||
mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::AltModifier);
|
||||
break;
|
||||
case Qt::Key_Meta:
|
||||
mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::MetaModifier);
|
||||
break;
|
||||
case Qt::Key_AltGr:
|
||||
mods = Qt::KeyboardModifiers(modsBeforeEvent ^ Qt::GroupSwitchModifier);
|
||||
break;
|
||||
default:
|
||||
mods = modsBeforeEvent;
|
||||
break;
|
||||
}
|
||||
d->keyboardModifiers = mods;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public:
|
|||
void setCursorPos(const QPoint &pos);
|
||||
|
||||
Qt::KeyboardModifiers keyboardModifiers() const;
|
||||
void setKeyboardModifiers(Qt::KeyboardModifiers modsBeforeEvent, int key);
|
||||
void setKeyboardModifiers(Qt::KeyboardModifiers mods);
|
||||
|
||||
signals:
|
||||
void deviceListChanged(QInputDeviceManager::DeviceType type);
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ private:
|
|||
QString unicodeText;
|
||||
int repeatCount;
|
||||
} m_repeatData;
|
||||
Qt::KeyboardModifiers m_mods;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue