XCB: Don't trigger less specific shortcuts

Without this patch some keycodes like Ctrl+Shift+= may generate several
similar key sequences like Ctrl++ and + but only more specific keys
should be returned by QXcbKeyboard::possibleKeys.

Task-number: QTBUG-38137
Change-Id: I23f6522eefaa3b83cfa639f76bdc6a19b450c6f9
Reviewed-by: Gatis Paeglis <gatis.paeglis@digia.com>
This commit is contained in:
Ruslan Nigmatullin 2014-09-27 00:19:36 +03:00 committed by Gatis Paeglis
parent 047f4c4d79
commit 449b62ed43

View File

@ -910,6 +910,18 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
if (qtKey == baseQtKey || qtKey == 0)
continue;
// catch only more specific shortcuts, i.e. Ctrl+Shift+= also generates Ctrl++ and +,
// but Ctrl++ is more specific than +, so we should skip the last one
bool ambiguous = false;
foreach (int shortcut, result) {
if (int(shortcut & ~Qt::KeyboardModifierMask) == qtKey && (shortcut & mods) == mods) {
ambiguous = true;
break;
}
}
if (ambiguous)
continue;
result += (qtKey + mods);
}
}