Commit 76fe4192 authored by Eskil Abrahamsen-Blomfeldt's avatar Eskil Abrahamsen-Blomfeldt
Browse files

Fix key events on Qt 5.15

Do this also the lazy way, since it's a temporary backport.
parent e75bf160
......@@ -167,6 +167,20 @@ void QVncItem::createServer()
QMouseEvent me(eventType, pos, pos, mouseButton, mouseState, keyboardState);
handleMouse(&me);
});
connect(m_vncServer, &QVncServer::keyEventReceived, this, [this](
QEvent::Type eventType,
Qt::Key key,
Qt::KeyboardModifiers keyboardModifiers,
const QChar &text){
if (!text.isNull() && text.isLetter() && text.isUpper() != !!(keyboardModifiers & Qt::ShiftModifier)) {
// We probably have CapsLock: flip the shift state so that Wayland can handle it
keyboardModifiers ^= Qt::ShiftModifier;
}
QKeyEvent ke(eventType, key, keyboardModifiers, text.isNull() ? QString{} : QString{text} );
QVncItem::handleKey(&ke);
});
#else
connect(m_vncServer, &QVncServer::mouseEventReceived, this, [this](
int eventType,
......@@ -178,19 +192,20 @@ void QVncItem::createServer()
QMouseEvent me(QEvent::Type(eventType), pos, pos, Qt::MouseButton(mouseButton), Qt::MouseButtons(mouseState), Qt::KeyboardModifiers(keyboardState));
handleMouse(&me);
});
#endif
connect(m_vncServer, &QVncServer::keyEventReceived, this, [this](
QEvent::Type eventType,
Qt::Key key,
Qt::KeyboardModifiers keyboardModifiers,
int eventType,
int key,
int keyboardModifiers,
const QChar &text){
if (!text.isNull() && text.isLetter() && text.isUpper() != !!(keyboardModifiers & Qt::ShiftModifier)) {
// We probably have CapsLock: flip the shift state so that Wayland can handle it
keyboardModifiers ^= Qt::ShiftModifier;
}
QKeyEvent ke(eventType, key, keyboardModifiers, text.isNull() ? QString{} : QString{text} );
QKeyEvent ke(QEvent::Type(eventType), Qt::Key(key), Qt::KeyboardModifiers(keyboardModifiers), text.isNull() ? QString{} : QString{text} );
QVncItem::handleKey(&ke);
});
#endif
connect(m_vncServer, &QVncServer::requestImage, this, &QVncItem::handleImageRequest);
}
......
......@@ -165,17 +165,23 @@ signals:
Qt::MouseButton mouseButton,
Qt::MouseButtons mouseState,
Qt::KeyboardModifiers keyboardState);
void keyEventReceived(QEvent::Type eventType,
Qt::Key key,
Qt::KeyboardModifiers keyboardModifiers,
const QChar &text);
#else
void mouseEventReceived(int eventType,
const QPointF &mousePosition,
int mouseButton,
int mouseState,
int keyboardState);
#endif
void keyEventReceived(QEvent::Type eventType,
Qt::Key key,
Qt::KeyboardModifiers keyboardModifiers,
void keyEventReceived(int eventType,
int key,
int keyboardModifiers,
const QChar &text);
#endif
void updateRequested();
void socketCreated(QTcpSocket *socket);
......
......@@ -69,24 +69,30 @@ public:
void setPassword(const QByteArray &newPassword);
Q_SIGNALS:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void mouseEventReceived(int eventType,
const QPointF &mousePosition,
int mouseButton,
int mouseState,
int keyboardState);
#else
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void mouseEventReceived(QEvent::Type eventType,
const QPointF &mousePosition,
Qt::MouseButton mouseButton,
Qt::MouseButtons mouseState,
Qt::KeyboardModifiers keyboardState);
#endif
void keyEventReceived(QEvent::Type eventType,
Qt::Key key,
Qt::KeyboardModifiers keyboardModifiers,
const QChar &text);
#else
void mouseEventReceived(int eventType,
const QPointF &mousePosition,
int mouseButton,
int mouseState,
int keyboardState);
void keyEventReceived(int eventType,
int key,
int keyboardModifiers,
const QChar &text);
#endif
void isConnectedChanged(bool connected);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment