Client: Allow inheritance of key translation

Use a virtual method keysymToQtKey for Qt key code translation, so that
it can be customized by a descendant class if needed.

Change-Id: I3b48346a63e2c6f134230fe15279faa95abe11a0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Jaeyoon Jung 2021-03-25 07:50:25 +09:00
parent 98c921c0e2
commit bffa397f68
2 changed files with 7 additions and 1 deletions

View File

@ -1268,7 +1268,7 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time,
Qt::KeyboardModifiers modifiers = mParent->modifiers();
int qtkey = QXkbCommon::keysymToQtKey(sym, modifiers, mXkbState.get(), code);
int qtkey = keysymToQtKey(sym, modifiers, mXkbState.get(), code);
QString text = QXkbCommon::lookupString(mXkbState.get(), code);
QEvent::Type type = isDown ? QEvent::KeyPress : QEvent::KeyRelease;

View File

@ -263,6 +263,12 @@ public:
struct ::wl_keyboard *wl_keyboard() { return QtWayland::wl_keyboard::object(); }
#if QT_CONFIG(xkbcommon)
virtual int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers, xkb_state *state, xkb_keycode_t code) {
return QXkbCommon::keysymToQtKey(keysym, modifiers, state, code);
}
#endif
private slots:
void handleFocusDestroyed();
void handleFocusLost();