From 3998df839238b141056d5233fcccf15be933b15d Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Thu, 16 Jun 2022 19:46:59 -0700 Subject: Also use text-input if QT_IM_MODULE is empty or "wayland" Previously, text input can only be used when only when QT_IM_MODULE is unset, it is counter-intuitive when empty and null has different meaning. Additionally making "wayland" to use text input to make it easier to enforce wayland context. Gtk's relevant value is also "wayland" so it will be more consistent. Change-Id: I39b8c899b0ab7965d4b17ca29ed9eadc14f17e88 Reviewed-by: Qt CI Bot Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Aleix Pol Gonzalez (cherry picked from commit 07dd6afa70cab374958468a45098a9b3ee57819f) Reviewed-by: Qt Cherry-pick Bot --- src/client/qwaylanddisplay.cpp | 4 ++++ src/client/qwaylanddisplay_p.h | 6 +++++- src/client/qwaylandintegration.cpp | 2 +- tests/auto/client/inputcontext/tst_inputcontext.cpp | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index c75ede73..55043311 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -833,6 +833,10 @@ bool QWaylandDisplay::isKeyboardAvailable() const [](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; }); } +bool QWaylandDisplay::isClientSideInputContextRequested() const { + return mClientSideInputContextRequested; +} + #if QT_CONFIG(cursor) QWaylandCursor *QWaylandDisplay::waylandCursor() diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h index 3809de1e..473016f1 100644 --- a/src/client/qwaylanddisplay_p.h +++ b/src/client/qwaylanddisplay_p.h @@ -185,6 +185,7 @@ public: wl_event_queue *frameEventQueue() { return m_frameEventQueue; }; bool isKeyboardAvailable() const; + bool isClientSideInputContextRequested() const; void initEventThread(); @@ -275,7 +276,10 @@ private: struct wl_callback *mSyncCallback = nullptr; static const wl_callback_listener syncCallbackListener; - bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull(); + bool mClientSideInputContextRequested = [] () { + const QString& requested = QPlatformInputContextFactory::requested(); + return !requested.isEmpty() && requested != QLatin1String("wayland"); + }(); QStringList mTextInputManagerList; int mTextInputManagerIndex = INT_MAX; diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp index 33d47e4c..ed04e403 100644 --- a/src/client/qwaylandintegration.cpp +++ b/src/client/qwaylandintegration.cpp @@ -476,7 +476,7 @@ void QWaylandIntegration::reconfigureInputContext() qCWarning(lcQpaWayland) << "qtvirtualkeyboard currently is not supported at client-side," " use QT_IM_MODULE=qtvirtualkeyboard at compositor-side."; - if (requested.isNull()) { + if (!mDisplay->isClientSideInputContextRequested()) { if (mDisplay->textInputMethodManager() != nullptr) mInputContext.reset(new QWaylandInputMethodContext(mDisplay.data())); #if QT_WAYLAND_TEXT_INPUT_V4_WIP diff --git a/tests/auto/client/inputcontext/tst_inputcontext.cpp b/tests/auto/client/inputcontext/tst_inputcontext.cpp index 9e3d75e0..9bcfa9e7 100644 --- a/tests/auto/client/inputcontext/tst_inputcontext.cpp +++ b/tests/auto/client/inputcontext/tst_inputcontext.cpp @@ -98,8 +98,9 @@ void tst_inputcontext::selectingInputContext_data() // Test compositor with Text Input extension QTest::newRow("ibus:text-input") << QByteArray("ibus") << mIbusModule; QTest::newRow("compose:text-input") << QByteArray("compose") << mComposeModule; - QTest::newRow("empty:text-input") << QByteArray("") << mComposeModule; + QTest::newRow("empty:text-input") << QByteArray("") << mTextInputModule; QTest::newRow("null:text-input") << QByteArray() << mTextInputModule; + QTest::newRow("wayland:text-input") << QByteArray("wayland") << mTextInputModule; QTest::newRow("fake:text-input") << QByteArray("fake") << mComposeModule; } -- cgit v1.2.1