diff options
author | Inho Lee <inho.lee@qt.io> | 2022-06-16 13:42:55 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-29 10:20:58 +0000 |
commit | 0a5c3282fbc930ea4db83a5ea1c64bd3df2cfff2 (patch) | |
tree | 2adf876d3b2e55be1d1a8f783e70f64bc8f4e901 | |
parent | 20f3636a1376b9ea86cfe76d6a028f88bfbb5de0 (diff) | |
download | qtwayland-0a5c3282fbc930ea4db83a5ea1c64bd3df2cfff2.tar.gz |
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 <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 8a694b65f1d043e74d7398d9fea8ac951cd86109)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/compositor/extensions/qwaylandtextinput.cpp | 25 | ||||
-rw-r--r-- | 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 |