summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandkeyboard.h
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-03-27 15:30:26 +0200
committerJohan Helsing <johan.helsing@qt.io>2018-04-27 10:17:10 +0000
commitbd5917025fe7491c9f24e99c20484c7ffce9f172 (patch)
tree006435d90eb25738b04a2c86aa45c0b3e8babdf1 /src/compositor/compositor_api/qwaylandkeyboard.h
parent531a767040782007181bb13583fe69b4ba4b1ba3 (diff)
Add QWaylandSeat::sendKeyEvent(int qtKey, bool pressed)
Makes it possible to send keyboard events using the QML API: Button { onPressedChanged: seat.sendKeyEvent(Qt.Key_Left, pressed) } The wl_keyboard.key event requires a keyboard scan code, so in order to get this we iterate over all the keys in the current keymap checking which QtKey they map to, storing the results in a QMap which is reused by later calls to QWaylandKeymap::toScanCode. This also fixes a bug when sending QKeyEvents without a native scan code using QWaylandSeat::sendFullKeyEvent. (generated key events have no nativeScanCode). Now we try QWaylandKeyboard::toScanCode, and if unsuccessful we return with a warning instead of letting the assertion in QWaylandKeyboard fail. This also adds more thorough testing for the keyboard, including keymaps and checking that the events, including enter and leave, are actually received on the client side. Change-Id: I601b0c7d909071863abb146bd65a990215dcaff7 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/compositor/compositor_api/qwaylandkeyboard.h')
-rw-r--r--src/compositor/compositor_api/qwaylandkeyboard.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/compositor/compositor_api/qwaylandkeyboard.h b/src/compositor/compositor_api/qwaylandkeyboard.h
index 580f0c4ed..e5d5e086e 100644
--- a/src/compositor/compositor_api/qwaylandkeyboard.h
+++ b/src/compositor/compositor_api/qwaylandkeyboard.h
@@ -82,6 +82,8 @@ public:
virtual void addClient(QWaylandClient *client, uint32_t id, uint32_t version);
+ uint toScanCode(int qtKey) const;
+
Q_SIGNALS:
void focusChanged(QWaylandSurface *surface);
void repeatRateChanged(quint32 repeatRate);