Skip to content
Permalink
Browse files
Add client support for the text-input-unstable-v1 protocol
This is used by weston for forwarding virtualkeyboard related
event from keyboard applications to a Qt client.

Right now Qt only supports text-input-unstable-v2, v4 and the
special qt-input-method protocol, while weston only supports
text-input-unstable-v1.

Without this, a virtual-keyboard application can't be used
with a Qt client within weston.

Change-Id: I9a34a87100854bb0b0f76762ced56419e70c297e
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
  • Loading branch information
Gagi2k committed Feb 2, 2022
1 parent 1eded03 commit e68f0f0
Show file tree
Hide file tree
Showing 10 changed files with 983 additions and 6 deletions.

Large diffs are not rendered by default.

@@ -29,6 +29,7 @@ qt_internal_add_module(WaylandClient
qwaylanddisplay.cpp qwaylanddisplay_p.h
qwaylandextendedsurface.cpp qwaylandextendedsurface_p.h
qwaylandinputcontext.cpp qwaylandinputcontext_p.h
qwaylandtextinputv1.cpp qwaylandtextinputv1_p.h
qwaylandtextinputv2.cpp qwaylandtextinputv2_p.h
qwaylandtextinputinterface.cpp qwaylandtextinputinterface_p.h
qwaylandinputdevice.cpp qwaylandinputdevice_p.h
@@ -75,6 +76,7 @@ qt6_generate_wayland_protocol_client_sources(WaylandClient
FILES
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/pointer-gestures-unstable-v1.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/tablet-unstable-v2.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/text-input-unstable-v1.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/text-input-unstable-v2.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/text-input-unstable-v4-wip.xml
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/protocol/wayland.xml
@@ -60,6 +60,7 @@
#include <wayland-cursor.h>
#endif
#include "qwaylandhardwareintegration_p.h"
#include "qwaylandtextinputv1_p.h"
#include "qwaylandtextinputv2_p.h"
#if QT_WAYLAND_TEXT_INPUT_V4_WIP
#include "qwaylandtextinputv4_p.h"
@@ -80,6 +81,7 @@
#endif
#include "qwaylandqtkey_p.h"

#include <QtWaylandClient/private/qwayland-text-input-unstable-v1.h>
#include <QtWaylandClient/private/qwayland-text-input-unstable-v2.h>
#include <QtWaylandClient/private/qwayland-text-input-unstable-v4-wip.h>
#include <QtWaylandClient/private/qwayland-wp-primary-selection-unstable-v1.h>
@@ -453,9 +455,11 @@ void QWaylandDisplay::checkTextInputProtocol()
{
QStringList tips, timps; // for text input protocols and text input manager protocols
tips << QLatin1String(QtWayland::qt_text_input_method_v1::interface()->name)
<< QLatin1String(QtWayland::zwp_text_input_v2::interface()->name);
<< QLatin1String(QtWayland::zwp_text_input_v2::interface()->name)
<< QLatin1String(QtWayland::zwp_text_input_v1::interface()->name);
timps << QLatin1String(QtWayland::qt_text_input_method_manager_v1::interface()->name)
<< QLatin1String(QtWayland::zwp_text_input_manager_v2::interface()->name);
<< QLatin1String(QtWayland::zwp_text_input_manager_v2::interface()->name)
<< QLatin1String(QtWayland::zwp_text_input_manager_v1::interface()->name);
#if QT_WAYLAND_TEXT_INPUT_V4_WIP
tips << QLatin1String(QtWayland::zwp_text_input_v4::interface()->name);
timps << QLatin1String(QtWayland::zwp_text_input_manager_v4::interface()->name);
@@ -540,6 +544,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
&& (mTextInputManagerList.contains(interface) && mTextInputManagerList.indexOf(interface) < mTextInputManagerIndex)) {
qCDebug(lcQpaWayland) << "text input: register qt_text_input_method_manager_v1";
if (mTextInputManagerIndex < INT_MAX) {
mTextInputManagerv1.reset();
mTextInputManagerv2.reset();
#if QT_WAYLAND_TEXT_INPUT_V4_WIP
mTextInputManagerv4.reset();
@@ -553,11 +558,34 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
inputDevice->setTextInputMethod(new QWaylandTextInputMethod(this, mTextInputMethodManager->get_text_input_method(inputDevice->wl_seat())));
mWaylandIntegration->reconfigureInputContext();
mTextInputManagerIndex = mTextInputManagerList.indexOf(interface);
} else if (interface == QLatin1String(QtWayland::zwp_text_input_manager_v1::interface()->name)
&& (mTextInputManagerList.contains(interface) && mTextInputManagerList.indexOf(interface) < mTextInputManagerIndex)) {
qCDebug(lcQpaWayland) << "text input: register zwp_text_input_v1";
if (mTextInputManagerIndex < INT_MAX) {
mTextInputMethodManager.reset();
mTextInputManagerv2.reset();
#if QT_WAYLAND_TEXT_INPUT_V4_WIP
mTextInputManagerv4.reset();
#endif // QT_WAYLAND_TEXT_INPUT_V4_WIP
for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
inputDevice->setTextInputMethod(nullptr);
}

mTextInputManagerv1.reset(new QtWayland::zwp_text_input_manager_v1(registry, id, 1));
for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices)) {
auto textInput = new QWaylandTextInputv1(this, mTextInputManagerv1->create_text_input());
textInput->setSeat(inputDevice->wl_seat());
inputDevice->setTextInput(textInput);
}

mWaylandIntegration->reconfigureInputContext();
mTextInputManagerIndex = mTextInputManagerList.indexOf(interface);
} else if (interface == QLatin1String(QtWayland::zwp_text_input_manager_v2::interface()->name)
&& (mTextInputManagerList.contains(interface) && mTextInputManagerList.indexOf(interface) < mTextInputManagerIndex)) {
qCDebug(lcQpaWayland) << "text input: register zwp_text_input_v2";
if (mTextInputManagerIndex < INT_MAX) {
mTextInputMethodManager.reset();
mTextInputManagerv1.reset();
#if QT_WAYLAND_TEXT_INPUT_V4_WIP
mTextInputManagerv4.reset();
#endif // QT_WAYLAND_TEXT_INPUT_V4_WIP
@@ -633,6 +661,12 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
}
}
}
if (global.interface == QLatin1String(QtWayland::zwp_text_input_manager_v1::interface()->name)) {
mTextInputManagerv1.reset();
for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
inputDevice->setTextInput(nullptr);
mWaylandIntegration->reconfigureInputContext();
}
if (global.interface == QLatin1String(QtWayland::zwp_text_input_manager_v2::interface()->name)) {
mTextInputManagerv2.reset();
for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
@@ -82,6 +82,7 @@ class QPlatformPlaceholderScreen;

namespace QtWayland {
class qt_surface_extension;
class zwp_text_input_manager_v1;
class zwp_text_input_manager_v2;
class zwp_text_input_manager_v4;
class qt_text_input_method_manager_v1;
@@ -176,6 +177,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
QWaylandPointerGestures *pointerGestures() const { return mPointerGestures.data(); }
QWaylandTouchExtension *touchExtension() const { return mTouchExtension.data(); }
QtWayland::qt_text_input_method_manager_v1 *textInputMethodManager() const { return mTextInputMethodManager.data(); }
QtWayland::zwp_text_input_manager_v1 *textInputManagerv1() const { return mTextInputManagerv1.data(); }
QtWayland::zwp_text_input_manager_v2 *textInputManagerv2() const { return mTextInputManagerv2.data(); }
QtWayland::zwp_text_input_manager_v4 *textInputManagerv4() const { return mTextInputManagerv4.data(); }
QWaylandHardwareIntegration *hardwareIntegration() const { return mHardwareIntegration.data(); }
@@ -289,6 +291,7 @@ public slots:
QScopedPointer<QWaylandPrimarySelectionDeviceManagerV1> mPrimarySelectionManager;
#endif
QScopedPointer<QtWayland::qt_text_input_method_manager_v1> mTextInputMethodManager;
QScopedPointer<QtWayland::zwp_text_input_manager_v1> mTextInputManagerv1;
QScopedPointer<QtWayland::zwp_text_input_manager_v2> mTextInputManagerv2;
QScopedPointer<QtWayland::zwp_text_input_manager_v4> mTextInputManagerv4;
QScopedPointer<QWaylandHardwareIntegration> mHardwareIntegration;
@@ -71,9 +71,9 @@ QWaylandInputContext::~QWaylandInputContext()
bool QWaylandInputContext::isValid() const
{
#if QT_WAYLAND_TEXT_INPUT_V4_WIP
return mDisplay->textInputManagerv2() != nullptr || mDisplay->textInputManagerv4() != nullptr;
return mDisplay->textInputManagerv2() != nullptr || mDisplay->textInputManagerv1() != nullptr || mDisplay->textInputManagerv4() != nullptr;
#else // QT_WAYLAND_TEXT_INPUT_V4_WIP
return mDisplay->textInputManagerv2() != nullptr;
return mDisplay->textInputManagerv2() != nullptr || mDisplay->textInputManagerv1() != nullptr;
#endif // QT_WAYLAND_TEXT_INPUT_V4_WIP
}

@@ -59,6 +59,7 @@
#include "qwaylandcursor_p.h"
#include "qwaylanddisplay_p.h"
#include "qwaylandshmbackingstore_p.h"
#include "qwaylandtextinputv1_p.h"
#include "qwaylandtextinputv2_p.h"
#if QT_WAYLAND_TEXT_INPUT_V4_WIP
#include "qwaylandtextinputv4_p.h"
@@ -426,6 +427,12 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version,
setPrimarySelectionDevice(psm->createDevice(this));
#endif

if (mQDisplay->textInputManagerv1()) {
auto textInput = new QWaylandTextInputv1(mQDisplay, mQDisplay->textInputManagerv1()->create_text_input());
textInput->setSeat(wl_seat());
mTextInput.reset(textInput);
}

if (mQDisplay->textInputManagerv2())
mTextInput.reset(new QWaylandTextInputv2(mQDisplay, mQDisplay->textInputManagerv2()->get_text_input(wl_seat())));

@@ -514,9 +514,9 @@ void QWaylandIntegration::reconfigureInputContext()
if (mDisplay->textInputMethodManager() != nullptr)
mInputContext.reset(new QWaylandInputMethodContext(mDisplay.data()));
#if QT_WAYLAND_TEXT_INPUT_V4_WIP
else if (mDisplay->textInputManagerv2() != nullptr || mDisplay->textInputManagerv4() != nullptr)
else if (mDisplay->textInputManagerv1() != nullptr || mDisplay->textInputManagerv2() != nullptr || mDisplay->textInputManagerv4() != nullptr)
#else // QT_WAYLAND_TEXT_INPUT_V4_WIP
else if (mDisplay->textInputManagerv2() != nullptr)
else if (mDisplay->textInputManagerv1() != nullptr || mDisplay->textInputManagerv2() != nullptr)
#endif // QT_WAYLAND_TEXT_INPUT_V4_WIP
mInputContext.reset(new QWaylandInputContext(mDisplay.data()));
} else {

0 comments on commit e68f0f0

Please sign in to comment.