diff options
4 files changed, 15 insertions, 16 deletions
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp index aee9e7e7..97cc3138 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.cpp +++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp @@ -513,12 +513,11 @@ void QWaylandKeyboard::sendKeyReleaseEvent(uint code) d->sendKeyEvent(code, WL_KEYBOARD_KEY_STATE_RELEASED); } -void QWaylandKeyboard::checkAndRepairModifierState(QKeyEvent *ke) +void QWaylandKeyboardPrivate::checkAndRepairModifierState(QKeyEvent *ke) { #if QT_CONFIG(xkbcommon) - Q_D(QWaylandKeyboard); - if (ke->modifiers() != d->currentModifierState) { - if (d->focusResource && ke->key() != Qt::Key_Shift + if (ke->modifiers() != currentModifierState) { + if (focusResource && ke->key() != Qt::Key_Shift && ke->key() != Qt::Key_Control && ke->key() != Qt::Key_Alt) { // Only repair the state for non-modifier keys // ### slightly awkward because the standard modifier handling @@ -526,19 +525,19 @@ void QWaylandKeyboard::checkAndRepairModifierState(QKeyEvent *ke) // key event is delivered uint32_t mods = 0; - if (d->shiftIndex == 0 && d->controlIndex == 0) - d->maybeUpdateXkbScanCodeTable(); + if (shiftIndex == 0 && controlIndex == 0) + maybeUpdateXkbScanCodeTable(); if (ke->modifiers() & Qt::ShiftModifier) - mods |= 1 << d->shiftIndex; + mods |= 1 << shiftIndex; if (ke->modifiers() & Qt::ControlModifier) - mods |= 1 << d->controlIndex; + mods |= 1 << controlIndex; if (ke->modifiers() & Qt::AltModifier) - mods |= 1 << d->altIndex; - qCDebug(qLcWaylandCompositor) << "Keyboard modifier state mismatch detected for event" << ke << "state:" << d->currentModifierState << "repaired:" << Qt::hex << mods; - d->send_modifiers(d->focusResource->handle, compositor()->nextSerial(), mods, - 0, 0, d->group); - d->currentModifierState = ke->modifiers(); + mods |= 1 << altIndex; + qCDebug(qLcWaylandCompositor) << "Keyboard modifier state mismatch detected for event" << ke << "state:" << currentModifierState << "repaired:" << Qt::hex << mods; + send_modifiers(focusResource->handle, compositor()->nextSerial(), mods, + 0, 0, group); + currentModifierState = ke->modifiers(); } } #else diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h index 9f7287a2..834260e3 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.h +++ b/src/compositor/compositor_api/qwaylandkeyboard.h @@ -67,8 +67,6 @@ public: virtual void sendKeyPressEvent(uint code); virtual void sendKeyReleaseEvent(uint code); - void checkAndRepairModifierState(QKeyEvent *ke); - QWaylandSurface *focus() const; QWaylandClient *focusClient() const; diff --git a/src/compositor/compositor_api/qwaylandkeyboard_p.h b/src/compositor/compositor_api/qwaylandkeyboard_p.h index 6ae0b441..942e4191 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard_p.h +++ b/src/compositor/compositor_api/qwaylandkeyboard_p.h @@ -88,6 +88,7 @@ public: void keyEvent(uint code, uint32_t state); void sendKeyEvent(uint code, uint32_t state); void updateModifierState(uint code, uint32_t state); + void checkAndRepairModifierState(QKeyEvent *ke); void maybeUpdateKeymap(); void checkFocusResource(Resource *resource); diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp index 6c080b82..20459dc2 100644 --- a/src/compositor/compositor_api/qwaylandseat.cpp +++ b/src/compositor/compositor_api/qwaylandseat.cpp @@ -41,6 +41,7 @@ #include <QtWaylandCompositor/QWaylandKeymap> #include <QtWaylandCompositor/private/qwaylandseat_p.h> #include <QtWaylandCompositor/private/qwaylandcompositor_p.h> +#include <QtWaylandCompositor/private/qwaylandkeyboard_p.h> #if QT_CONFIG(wayland_datadevice) #include <QtWaylandCompositor/private/qwldatadevice_p.h> #endif @@ -518,7 +519,7 @@ void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event) } if (event->type() == QEvent::KeyPress) { - d->keyboard->checkAndRepairModifierState(event); + QWaylandKeyboardPrivate::get(d->keyboard.data())->checkAndRepairModifierState(event); d->keyboard->sendKeyPressEvent(scanCode); } else if (event->type() == QEvent::KeyRelease) { d->keyboard->sendKeyReleaseEvent(scanCode); |