From 0a5c3282fbc930ea4db83a5ea1c64bd3df2cfff2 Mon Sep 17 00:00:00 2001 From: Inho Lee Date: Thu, 16 Jun 2022 13:42:55 +0200 Subject: Implement send_modifiers_map for zwp_text_input_v2 zwp_text_input_v2's modifiers_map was used in client but QWaylandCompositor does not care about it. Fixes: QTBUG-104227 Change-Id: I78ff56f84b5380e74649a0a8de99eaffd8a359ab Reviewed-by: Eskil Abrahamsen Blomfeldt (cherry picked from commit 8a694b65f1d043e74d7398d9fea8ac951cd86109) Reviewed-by: Qt Cherry-pick Bot --- src/compositor/extensions/qwaylandtextinput.cpp | 25 ++++++++++++++++++++++--- src/compositor/extensions/qwaylandtextinput_p.h | 6 ++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/compositor/extensions/qwaylandtextinput.cpp b/src/compositor/extensions/qwaylandtextinput.cpp index 76d807dc..2920f0d7 100644 --- a/src/compositor/extensions/qwaylandtextinput.cpp +++ b/src/compositor/extensions/qwaylandtextinput.cpp @@ -169,13 +169,22 @@ void QWaylandTextInputPrivate::sendKeyEvent(QKeyEvent *event) if (!focusResource || !focusResource->handle) return; - // TODO add support for modifiers + uint mods = 0; + const auto &qtMods = event->modifiers(); + if (qtMods & Qt::ShiftModifier) + mods |= shiftModifierMask; + if (qtMods & Qt::ControlModifier) + mods |= controlModifierMask; + if (qtMods & Qt::AltModifier) + mods |= altModifierMask; + if (qtMods & Qt::MetaModifier) + mods |= metaModifierMask; #if QT_CONFIG(xkbcommon) for (xkb_keysym_t keysym : QXkbCommon::toKeysym(event)) { send_keysym(focusResource->handle, event->timestamp(), keysym, event->type() == QEvent::KeyPress ? WL_KEYBOARD_KEY_STATE_PRESSED : WL_KEYBOARD_KEY_STATE_RELEASED, - 0); + mods); } #else Q_UNUSED(event); @@ -288,9 +297,19 @@ void QWaylandTextInputPrivate::setFocus(QWaylandSurface *surface) focus = surface; } +#if !QT_CONFIG(xkbcommon) +#define XKB_MOD_NAME_SHIFT "Shift" +#define XKB_MOD_NAME_CTRL "Control" +#define XKB_MOD_NAME_ALT "Mod1" +#define XKB_MOD_NAME_LOGO "Mod4" +#endif void QWaylandTextInputPrivate::zwp_text_input_v2_bind_resource(Resource *resource) { - send_modifiers_map(resource->handle, QByteArray("")); + QByteArray modifiers = XKB_MOD_NAME_SHIFT + QByteArray(1, '\0'); + modifiers += XKB_MOD_NAME_CTRL + QByteArray(1, '\0'); + modifiers += XKB_MOD_NAME_ALT + QByteArray(1, '\0'); + modifiers += XKB_MOD_NAME_LOGO + QByteArray(1, '\0'); + send_modifiers_map(resource->handle, modifiers); } void QWaylandTextInputPrivate::zwp_text_input_v2_destroy_resource(Resource *resource) diff --git a/src/compositor/extensions/qwaylandtextinput_p.h b/src/compositor/extensions/qwaylandtextinput_p.h index 408a95e6..c60659de 100644 --- a/src/compositor/extensions/qwaylandtextinput_p.h +++ b/src/compositor/extensions/qwaylandtextinput_p.h @@ -95,6 +95,12 @@ protected: void zwp_text_input_v2_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; void zwp_text_input_v2_set_preferred_language(Resource *resource, const QString &language) override; void zwp_text_input_v2_update_state(Resource *resource, uint32_t serial, uint32_t flags) override; + +private: + quint32 shiftModifierMask = 1; + quint32 controlModifierMask = 2; + quint32 altModifierMask = 4; + quint32 metaModifierMask = 8; }; QT_END_NAMESPACE -- cgit v1.2.1