diff --git a/src/wayland/inputmethod_v1_interface.cpp b/src/wayland/inputmethod_v1_interface.cpp index de65d2bd4f..349e4773cf 100644 --- a/src/wayland/inputmethod_v1_interface.cpp +++ b/src/wayland/inputmethod_v1_interface.cpp @@ -130,28 +130,13 @@ public: } void zwp_input_method_context_v1_modifiers_map(Resource *, wl_array *map) override { - const QList modifiersMap = QByteArray::fromRawData(static_cast(map->data), map->size).split('\0'); + const auto mods = QByteArray::fromRawData(static_cast(map->data), map->size); - mods.clear(); - for (const QByteArray &modifier : modifiersMap) { - if (modifier == "Shift") { - mods << Qt::ShiftModifier; - } else if (modifier == "Alt") { - mods << Qt::AltModifier; - } else if (modifier == "Control") { - mods << Qt::ControlModifier; - } else if (modifier == "Mod1") { - mods << Qt::AltModifier; - } else if (modifier == "Mod4") { - mods << Qt::MetaModifier; - } else { - mods << Qt::NoModifier; - } - } + Q_EMIT q->modifiersMap(mods); } void zwp_input_method_context_v1_keysym(Resource *, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) override { - Q_EMIT q->keysym(serial, time, sym, state == WL_KEYBOARD_KEY_STATE_PRESSED, toQtModifiers(modifiers)); + Q_EMIT q->keysym(serial, time, sym, state == WL_KEYBOARD_KEY_STATE_PRESSED, modifiers); } void zwp_input_method_context_v1_grab_keyboard(Resource *resource, uint32_t id) override { @@ -196,19 +181,6 @@ public: Q_EMIT q->textDirection(serial, qtDirection); } - Qt::KeyboardModifiers toQtModifiers(uint32_t modifiers) - { - Qt::KeyboardModifiers ret = Qt::NoModifier; - // if we never got the modifier map from the input method, return empty modifier - if (mods.isEmpty()) { - return ret; - } - for (int i = 0; modifiers >>= 1; ++i) { - ret |= mods[i]; - } - return ret; - } - void zwp_input_method_context_v1_destroy(Resource *resource) override { wl_resource_destroy(resource->handle); @@ -216,7 +188,6 @@ public: InputMethodContextV1Interface *const q; QScopedPointer m_keyboardGrab; - QVector mods; }; InputMethodContextV1Interface::InputMethodContextV1Interface(InputMethodV1Interface *parent) diff --git a/src/wayland/inputmethod_v1_interface.h b/src/wayland/inputmethod_v1_interface.h index cba858b2bc..fb58f1603c 100644 --- a/src/wayland/inputmethod_v1_interface.h +++ b/src/wayland/inputmethod_v1_interface.h @@ -87,12 +87,13 @@ Q_SIGNALS: void preeditCursor(qint32 index); void deleteSurroundingText(qint32 index, quint32 length); void cursorPosition(qint32 index, qint32 anchor); - void keysym(quint32 serial, quint32 time, quint32 sym, bool pressed, Qt::KeyboardModifiers modifiers); + void keysym(quint32 serial, quint32 time, quint32 sym, bool pressed, quint32 modifiers); void key(quint32 serial, quint32 time, quint32 key, bool pressed); void modifiers(quint32 serial, quint32 mods_depressed, quint32 mods_latched, quint32 mods_locked, quint32 group); void language(quint32 serial, const QString &language); void textDirection(quint32 serial, Qt::LayoutDirection direction); void keyboardGrabRequested(InputMethodGrabV1 *keyboardGrab); + void modifiersMap(const QByteArray &map); private: friend class InputMethodV1Interface;