inputmethod&plugins/buttonrebinds: use new KKeyServer API
To correctly handle Qt::Key_Calculator corresponding to both XF86Calculator and XF86Calculater.
This commit is contained in:
parent
795b619704
commit
ae7fb3885b
2 changed files with 21 additions and 7 deletions
|
@ -60,12 +60,19 @@ static std::vector<quint32> textToKey(const QString &text)
|
|||
return {};
|
||||
}
|
||||
|
||||
int sym;
|
||||
if (!KKeyServer::keyQtToSymX(sequence[0], &sym)) {
|
||||
const QList<int> syms(KKeyServer::keyQtToSymXs(sequence[0]));
|
||||
if (syms.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto keyCode = input()->keyboard()->xkb()->keycodeFromKeysym(sym);
|
||||
std::optional<int> keyCode;
|
||||
for (int sym : syms) {
|
||||
auto code = input()->keyboard()->xkb()->keycodeFromKeysym(sym);
|
||||
if (code) {
|
||||
keyCode = code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!keyCode) {
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -305,15 +305,22 @@ bool ButtonRebindsFilter::sendKeySequence(const QKeySequence &keys, bool pressed
|
|||
}
|
||||
}
|
||||
|
||||
int sym = -1;
|
||||
if (!KKeyServer::keyQtToSymX(keys[0], &sym)) {
|
||||
const QList<int> syms(KKeyServer::keyQtToSymXs(keys[0]));
|
||||
if (syms.empty()) {
|
||||
qCWarning(KWIN_BUTTONREBINDS) << "Could not convert" << keys << "to keysym";
|
||||
return false;
|
||||
}
|
||||
// KKeyServer returns upper case syms, lower it to not confuse modifiers handling
|
||||
auto keyCode = KWin::input()->keyboard()->xkb()->keycodeFromKeysym(sym);
|
||||
std::optional<int> keyCode;
|
||||
for (int sym : syms) {
|
||||
auto code = KWin::input()->keyboard()->xkb()->keycodeFromKeysym(sym);
|
||||
if (code) {
|
||||
keyCode = code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!keyCode) {
|
||||
qCWarning(KWIN_BUTTONREBINDS) << "Could not convert" << keys << "sym: " << sym << "to keycode";
|
||||
qCWarning(KWIN_BUTTONREBINDS) << "Could not convert" << keys << "syms: " << syms << "to keycode";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue