summaryrefslogtreecommitdiff
path: root/src/shared/qwaylandxkb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/qwaylandxkb.cpp')
-rw-r--r--src/shared/qwaylandxkb.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/shared/qwaylandxkb.cpp b/src/shared/qwaylandxkb.cpp
index 49925700..2afdcce8 100644
--- a/src/shared/qwaylandxkb.cpp
+++ b/src/shared/qwaylandxkb.cpp
@@ -293,8 +293,13 @@ static xkb_keysym_t toKeysymFromTable(uint32_t key)
return 0;
}
-int QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, const QString &text)
+std::pair<int, QString> QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers &modifiers)
{
+ QString text;
+ uint utf32 = xkb_keysym_to_utf32(keysym);
+ if (utf32)
+ text = QString::fromUcs4(&utf32, 1);
+
int code = 0;
if (keysym >= XKB_KEY_F1 && keysym <= XKB_KEY_F35) {
@@ -316,7 +321,13 @@ int QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers &modif
code = lookupKeysym(keysym);
}
- return code;
+ // Map control + letter to proper text
+ if (utf32 >= 'A' && utf32 <= '~' && (modifiers & Qt::ControlModifier)) {
+ utf32 &= ~0x60;
+ text = QString::fromUcs4(&utf32, 1);
+ }
+
+ return { code, text };
}
Qt::KeyboardModifiers QWaylandXkb::modifiers(struct xkb_state *state)
@@ -342,22 +353,6 @@ QEvent::Type QWaylandXkb::toQtEventType(uint32_t state)
return state != 0 ? QEvent::KeyPress : QEvent::KeyRelease;
}
-QString QWaylandXkb::textFromKeysym(uint32_t keysym, Qt::KeyboardModifiers modifiers)
-{
- uint utf32 = xkb_keysym_to_utf32(keysym);
-
- // Map control + letter to proper text
- if (utf32 >= 'A' && utf32 <= '~' && (modifiers & Qt::ControlModifier)) {
- utf32 &= ~0x60;
- return QString::fromUcs4(&utf32, 1);
- }
-
- if (utf32)
- return QString::fromUcs4(&utf32, 1);
-
- return QString();
-}
-
QVector<xkb_keysym_t> QWaylandXkb::toKeysym(QKeyEvent *event)
{
QVector<xkb_keysym_t> keysyms;