7#include <QtWaylandCompositor/QWaylandCompositor>
8#include <QtWaylandCompositor/private/qwaylandseat_p.h>
14#include <QGuiApplication>
15#include <QInputMethodEvent>
16#include <qpa/qwindowsysteminterface.h>
18#if QT_CONFIG(xkbcommon)
19#include <QtGui/private/qxkbcommon_p.h>
34 Qt::InputMethodQueries queries;
52 Qt::InputMethodQueries queries;
97 bool needsDone =
false;
99 const QString &newPreeditString =
event->preeditString();
103 int32_t preeditCursorPos = newPreeditString.
length();
105 if (
event->replacementLength() > 0 ||
event->replacementStart() < 0) {
106 if (
event->replacementStart() <= 0 && (
event->replacementLength() >= -
event->replacementStart())) {
111 send_delete_surrounding_text(
focusResource->handle, before, after);
114 qCWarning(qLcWaylandCompositorTextInput) <<
"Not yet supported case of replacement. Start:" <<
event->replacementStart() <<
"length:" <<
event->replacementLength();
116 preeditCursorPos =
event->replacementStart() +
event->replacementLength();
124 if (!
event->commitString().isEmpty()) {
204 qApp->inputMethod()->commit();
207 qApp->inputMethod()->hide();
213 if (
focus != surface)
216 Resource *resource = surface ? resourceMap().value(surface->
waylandClient()) : 0;
217 if (resource && surface) {
218 send_enter(resource->handle, surface->
resource());
220 if (
focus != surface)
247 wl_resource_destroy(resource->handle);
263 qApp->inputMethod()->show();
273 emit q->surfaceDisabled(
s);
278 qApp->inputMethod()->commit();
280 qApp->inputMethod()->reset();
305 qCDebug(qLcWaylandCompositorTextInput) <<
"OBS: Disabled surface!!";
313 qCDebug(qLcWaylandCompositorTextInput) <<
Q_FUNC_INFO <<
"pendingState is not changed";
322 qApp->inputMethod()->reset();
333 qCDebug(qLcWaylandCompositorTextInput) <<
"QInputMethod::update() after commit with" << queries;
335 qApp->inputMethod()->update(queries);
348 if ((
hint & content_hint_completion) == 0)
350 if ((
hint & content_hint_auto_capitalization) == 0)
352 if ((
hint & content_hint_lowercase) != 0)
354 if ((
hint & content_hint_uppercase) != 0)
356 if ((
hint & content_hint_hidden_text) != 0)
358 if ((
hint & content_hint_sensitive_data) != 0)
360 if ((
hint & content_hint_latin) != 0)
362 if ((
hint & content_hint_multiline) != 0)
366 case content_purpose_normal:
368 case content_purpose_alpha:
371 case content_purpose_digits:
374 case content_purpose_number:
377 case content_purpose_phone:
380 case content_purpose_url:
383 case content_purpose_email:
386 case content_purpose_name:
387 case content_purpose_password:
389 case content_purpose_date:
392 case content_purpose_time:
395 case content_purpose_datetime:
398 case content_purpose_terminal:
434 this, &QWaylandTextInputV4::focusSurfaceDestroyed);
445 d->sendInputMethodEvent(
event);
473 d->setFocus(surface);
476void QWaylandTextInputV4::focusSurfaceDestroyed(
void *)
482 d->focusDestroyListener.reset();
485 d->focusResource =
nullptr;
494 return d->enabledSurfaces.values().contains(surface);
503 d->add(client,
id, version);
508 return QWaylandTextInputV4Private::interface();
513 return QWaylandTextInputV4Private::interfaceName();
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
The QKeyEvent class describes a key event.
\inmodule QtCore\reentrant
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString right(qsizetype n) const
Returns a substring that contains the n rightmost characters of the string.
void clear()
Clears the contents of the string and makes it null.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
qsizetype length() const
Returns the number of characters in this string.
\inmodule QtWaylandCompositor
\qmltype WaylandCompositor \instantiates QWaylandCompositor \inqmlmodule QtWayland....
void listenForDestruction(struct wl_resource *resource)
\inmodule QtWaylandCompositor
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
struct wl_resource * resource() const
Returns the Wayland resource corresponding to this QWaylandSurface.
::wl_client * waylandClient() const
Holds the wl_client using this QWaylandSurface.
Qt::InputMethodQueries mergeChanged(const QWaylandTextInputV4ClientState &other)
Qt::InputMethodQueries changedState
Qt::InputMethodHints hints
Qt::InputMethodQueries updatedQueries(const QWaylandTextInputV4ClientState &other) const
QScopedPointer< QWaylandTextInputV4ClientState > pendingState
void zwp_text_input_v4_disable(Resource *resource) override
void zwp_text_input_v4_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) override
void zwp_text_input_v4_set_text_change_cause(Resource *resource, uint32_t cause) override
QHash< Resource *, QWaylandSurface * > enabledSurfaces
void sendKeyEvent(QKeyEvent *event)
QScopedPointer< QWaylandTextInputV4ClientState > currentState
QString currentPreeditString
void zwp_text_input_v4_destroy(Resource *resource) override
void zwp_text_input_v4_destroy_resource(Resource *resource) override
void setFocus(QWaylandSurface *surface)
void zwp_text_input_v4_commit(Resource *resource) override
QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
void zwp_text_input_v4_enable(Resource *resource) override
void zwp_text_input_v4_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override
QWaylandDestroyListener focusDestroyListener
QWaylandTextInputV4Private(QWaylandCompositor *compositor)
void zwp_text_input_v4_set_surrounding_text(Resource *resource, const QString &text, int32_t cursor, int32_t anchor) override
void sendInputMethodEvent(QInputMethodEvent *event)
void zwp_text_input_v4_bind_resource(Resource *resource) override
void sendKeyEvent(QKeyEvent *event)
~QWaylandTextInputV4() override
void setFocus(QWaylandSurface *surface)
static QByteArray interfaceName()
QWaylandSurface * focus() const
void add(::wl_client *client, uint32_t id, int version)
void sendInputMethodEvent(QInputMethodEvent *event)
QWaylandTextInputV4(QWaylandObject *container, QWaylandCompositor *compositor)
bool isSurfaceEnabled(QWaylandSurface *surface) const
static const struct wl_interface * interface()
QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
Combined button and popup list for selecting options.
@ ImhFormattedNumbersOnly
@ ImhDialableCharactersOnly
#define QByteArrayLiteral(str)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
static QOpenGLCompositor * compositor
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble q
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)