From 98b21a81fe77bdbb4f6ce984ab50b9a7dcf86530 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 19 Jan 2024 10:52:37 +0100 Subject: Fix bool parameter trap in sendUnicodeKeyEvent() Match this to the other events in the class instead of sendKeyEvent(), which stands out as being a bit awkward. Change-Id: I07d5a57717bc5f7400f577246652eac6a86fe469 Reviewed-by: Volker Hilsheimer Reviewed-by: Inho Lee (cherry picked from commit 7b06ee44eab57000c597f9154c802ad06078c281) Reviewed-by: Qt Cherry-pick Bot --- src/compositor/compositor_api/qwaylandseat.cpp | 48 +++++++++++++++++++++----- src/compositor/compositor_api/qwaylandseat.h | 6 +++- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp index 6468a2b1f..1ea2e7bcf 100644 --- a/src/compositor/compositor_api/qwaylandseat.cpp +++ b/src/compositor/compositor_api/qwaylandseat.cpp @@ -538,19 +538,17 @@ void QWaylandSeat::sendKeyEvent(int qtKey, bool pressed) } /*! - * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendUnicodeKeyEvent(uint unicode, bool pressed) + * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendUnicodeKeyPressEvent(uint unicode) * \since 6.7 * - * Sends a key press (if \a pressed is \c true) or release (if \a pressed is \c false) - * event of a UCS4 \a unicode through a text-input protocol. + * Sends a key press event of a UCS4 \a unicode through a text-input protocol. * * \note This function will not work properly if the client does not support the * text-input protocol that the compositor supports. */ /*! - * Sends a key press (if \a pressed is \c true) or release (if \a pressed is \c false) - * event of a UCS4 \a unicode through a text-input protocol. + * Sends a key press event of a UCS4 \a unicode through a text-input protocol. * * \note This function will not work properly if the client does not support the * text-input protocol that the compositor supports. @@ -559,7 +557,42 @@ void QWaylandSeat::sendKeyEvent(int qtKey, bool pressed) * * \since 6.7 */ -void QWaylandSeat::sendUnicodeKeyEvent(uint unicode, bool pressed) +void QWaylandSeat::sendUnicodeKeyPressEvent(uint unicode) +{ + sendUnicodeKeyEvent(unicode, QEvent::KeyPress); +} + +/*! + * \qmlmethod void QtWayland.Compositor::WaylandSeat::sendUnicodeKeyReleaseEvent(uint unicode) + * \since 6.7 + * + * Sends a key release event of a UCS4 \a unicode through a text-input protocol. + * + * \note This function will not work properly if the client does not support the + * text-input protocol that the compositor supports. + */ + +/*! + * Sends a key release event of a UCS4 \a unicode through a text-input protocol. + * + * \note This function will not work properly if the client does not support the + * text-input protocol that the compositor supports. + * + * \sa {sendFullKeyEvent} {sendKeyEvent} + * + * \since 6.7 + */ +void QWaylandSeat::sendUnicodeKeyReleaseEvent(uint unicode) +{ + sendUnicodeKeyEvent(unicode, QEvent::KeyRelease); +} + +/*! + * \internal + * + * Sends an \a eventType for the UCS4 \a unicode through a text-input protocol. + */ +void QWaylandSeat::sendUnicodeKeyEvent(uint unicode, QEvent::Type eventType) { if (!keyboardFocus()) { qWarning("Can't send a unicode key event, no keyboard focus, fix the compositor"); @@ -567,7 +600,6 @@ void QWaylandSeat::sendUnicodeKeyEvent(uint unicode, bool pressed) } #if QT_CONFIG(im) - auto eventType = pressed ? QEvent::KeyPress : QEvent::KeyRelease; // make a keysym value for the UCS4 const uint keysym = 0x01000000 | unicode; auto text = QXkbCommon::lookupStringNoKeysymTransformations(keysym); @@ -599,7 +631,7 @@ void QWaylandSeat::sendUnicodeKeyEvent(uint unicode, bool pressed) } #else Q_UNUSED(keysym); - Q_UNUSED(pressed); + Q_UNUSED(eventType); qWarning() << "Can't send a unicode key event: Unable to find a text-input protocol."; #endif } diff --git a/src/compositor/compositor_api/qwaylandseat.h b/src/compositor/compositor_api/qwaylandseat.h index 6522a8d5b..dd67e83ae 100644 --- a/src/compositor/compositor_api/qwaylandseat.h +++ b/src/compositor/compositor_api/qwaylandseat.h @@ -70,7 +70,9 @@ public: void sendFullKeyEvent(QKeyEvent *event); Q_INVOKABLE void sendKeyEvent(int qtKey, bool pressed); - Q_REVISION(6, 7) Q_INVOKABLE void sendUnicodeKeyEvent(uint unicode, bool pressed); + + Q_REVISION(6, 7) Q_INVOKABLE void sendUnicodeKeyPressEvent(uint unicode); + Q_REVISION(6, 7) Q_INVOKABLE void sendUnicodeKeyReleaseEvent(uint unicode); uint sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state); Q_INVOKABLE uint sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position); @@ -115,6 +117,8 @@ Q_SIGNALS: void cursorSurfaceRequested(QWaylandSurface *surface, int hotspotX, int hotspotY, QWaylandClient *client); private: + void sendUnicodeKeyEvent(uint unicode, QEvent::Type type); + void handleMouseFocusDestroyed(); }; -- cgit v1.2.3