From 42f6dd89261ef94099f05f9f813a25d0cce8d8ac Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 19 May 2012 19:31:36 +0300 Subject: [PATCH] Fix stuck modifier keys MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Storing the modifier state as a member is not needed. Updating it in the keyboard_enter does not make sense as the xkb state can only change in the key event handler. The logic for updating the modifiers was somewhat broken. Change-Id: I7d9378af6f3775a6954a9747cab0e93a549fa62a Reviewed-by: Jørgen Lind --- .../platforms/wayland/qwaylandinputdevice.cpp | 39 ++++++++-------------- .../platforms/wayland/qwaylandinputdevice.h | 1 - 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index f835eb2..d0c6d79 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -424,20 +424,13 @@ void QWaylandInputDevice::keyboard_enter(void *data, { Q_UNUSED(keyboard); Q_UNUSED(time); - QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; - QWaylandWindow *window; - - inputDevice->mModifiers = 0; - Q_UNUSED(keys); -#ifndef QT_NO_WAYLAND_XKB - inputDevice->mModifiers |= translateModifiers(inputDevice->mXkbState); -#endif if (!surface) return; - window = (QWaylandWindow *) wl_surface_get_user_data(surface); + QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data; + QWaylandWindow *window = (QWaylandWindow *) wl_surface_get_user_data(surface); inputDevice->mKeyboardFocus = window; inputDevice->mQDisplay->setLastKeyboardFocusInputDevice(inputDevice); QWindowSystemInterface::handleWindowActivated(window->window()); @@ -475,11 +468,8 @@ void QWaylandInputDevice::keyboard_key(void *data, QEvent::Type type; char s[2]; - if (window == NULL || !inputDevice->mXkbMap) { - // We destroyed the keyboard focus surface, but the server - // didn't get the message yet. + if (!inputDevice->mXkbMap) return; - } code = key + 8; bool isDown = state != 0; @@ -487,26 +477,23 @@ void QWaylandInputDevice::keyboard_key(void *data, xkb_state_update_key(inputDevice->mXkbState, code, isDown ? XKB_KEY_DOWN : XKB_KEY_UP); - xkb_keysym_t sym; - if (numSyms == 1) { - sym = syms[0]; - - modifiers = translateModifiers(inputDevice->mXkbState); + if (!window) { + // We destroyed the keyboard focus surface, but the server + // didn't get the message yet. + return; + } - if (isDown) { - inputDevice->mModifiers |= modifiers; - type = QEvent::KeyPress; - } else { - inputDevice->mModifiers &= ~modifiers; - type = QEvent::KeyRelease; - } + if (numSyms == 1) { + xkb_keysym_t sym = syms[0]; + Qt::KeyboardModifiers modifiers = translateModifiers(inputDevice->mXkbState); + type = isDown ? QEvent::KeyPress : QEvent::KeyRelease; sym = translateKey(sym, s, sizeof s); if (window) QWindowSystemInterface::handleExtendedKeyEvent(window->window(), time, type, sym, - inputDevice->mModifiers, + modifiers, code, 0, 0, QString::fromLatin1(s)); } diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h index f6eb66c..e4a4838 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.h +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h @@ -101,7 +101,6 @@ private: Qt::MouseButtons mButtons; QPointF mSurfacePos; QPointF mGlobalPos; - Qt::KeyboardModifiers mModifiers; uint32_t mTime; static const struct wl_seat_listener seatListener; -- 2.7.4