Commit cd72d896 authored by Bhushan Shah's avatar Bhushan Shah 📱

input-method-v1: Fix bug regarding the modifier handling

modifiers request by the input method is supposed to send the raw
modifiers based on the keymap of the keyboard grabbed as result of the
grab_keyboard request. If input method client is not using the keysym
functionality it can decide to not send out the modifiers_map, since it
is already known to compositor as part of keymap event sent by it.

While at it also guard against empty modifiers_map, if this happens
ideally compositor should handle that information based on the keymap
sent out using grab_keyboard function, but since currently, we do not
have the grab_keyboard implemented in here, send out the NoModifier if
that happens.
parent 8dae655b
......@@ -90,7 +90,7 @@ public:
}
void zwp_input_method_context_v1_modifiers(Resource *, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) override
{
Q_EMIT q->modifiers(serial, toQtModifiers(mods_depressed), toQtModifiers(mods_latched), toQtModifiers(mods_locked), group);
Q_EMIT q->modifiers(serial, mods_depressed, mods_latched, mods_locked, group);
}
void zwp_input_method_context_v1_language(Resource *, uint32_t serial, const QString &language) override
{
......@@ -116,6 +116,10 @@ public:
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];
}
......
......@@ -84,7 +84,7 @@ Q_SIGNALS:
void keysym(quint32 serial, quint32 time, quint32 sym, bool pressed, Qt::KeyboardModifiers modifiers);
void grabKeyboard(quint32 keyboard);
void key(quint32 serial, quint32 time, quint32 key, bool pressed);
void modifiers(quint32 serial, Qt::KeyboardModifiers mods_depressed, Qt::KeyboardModifiers mods_latched, Qt::KeyboardModifiers mods_locked, quint32 group);
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment