diff options
author | Inho Lee <inho.lee@qt.io> | 2022-06-16 13:42:55 +0200 |
---|---|---|
committer | Inho Lee <inho.lee@qt.io> | 2022-06-29 11:44:49 +0200 |
commit | 8a694b65f1d043e74d7398d9fea8ac951cd86109 (patch) | |
tree | 58209f2905262510a219bdc7bca43223da6345da | |
parent | 0909a047b15982f9e39865f9d8058cd6d22b789d (diff) | |
download | qtwayland-8a694b65f1d043e74d7398d9fea8ac951cd86109.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.
Pick-to: 6.4 6.3 6.2 5.15
Fixes: QTBUG-104227
Change-Id: I78ff56f84b5380e74649a0a8de99eaffd8a359ab
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
-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 |