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.
This commit is contained in:
Bhushan Shah 2020-10-15 10:26:01 +05:30
parent 4da1822100
commit 0117122679
2 changed files with 6 additions and 2 deletions

View file

@ -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];
}

View file

@ -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);