summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2024-01-19 10:52:37 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-01-19 14:02:20 +0000
commit98b21a81fe77bdbb4f6ce984ab50b9a7dcf86530 (patch)
tree4dd06c2b266aa919d25463e279f9eb85b02c4fc2
parent1867ef129a0076a771a7fbab49398901574fd3ad (diff)
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 <volker.hilsheimer@qt.io> Reviewed-by: Inho Lee <inho.lee@qt.io> (cherry picked from commit 7b06ee44eab57000c597f9154c802ad06078c281) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/compositor/compositor_api/qwaylandseat.cpp48
-rw-r--r--src/compositor/compositor_api/qwaylandseat.h6
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();
};