7#include <QtWaylandCompositor/QWaylandCompositor>
8#include <QtWaylandCompositor/private/qwaylandseat_p.h>
15#include <QGuiApplication>
16#include <QInputMethodEvent>
18#if QT_CONFIG(xkbcommon)
19#include <QtGui/private/qxkbcommon_p.h>
30 Qt::InputMethodQueries queries;
49 Qt::InputMethodQueries queries;
106 if (
event->replacementLength() > 0 ||
event->replacementStart() != 0) {
113 if (
event->replacementStart() <= 0 && (
event->replacementLength() >= -
event->replacementStart())) {
118 send_delete_surrounding_text(
focusResource->handle, before, after);
121 qWarning() <<
"Not yet supported case of replacement. Start:" <<
event->replacementStart() <<
"length:" <<
event->replacementLength();
155 Qt::InputMethodQueries queries =
currentState->updatedQueries(afterCommit);
161 qCDebug(qLcWaylandCompositorInputMethods) <<
"QInputMethod::update() after QInputMethodEvent" << queries;
163 emit q->updateInputMethod(queries);
173 const auto &qtMods =
event->modifiers();
175 mods |= shiftModifierMask;
177 mods |= controlModifierMask;
179 mods |= altModifierMask;
181 mods |= metaModifierMask;
183#if QT_CONFIG(xkbcommon)
205 inputMethod->
isVisible() ? input_panel_visibility_visible : input_panel_visibility_hidden,
206 localRect.
x(), localRect.
y(), localRect.
width(), localRect.
height());
225 const QLocale locale =
qApp->inputMethod()->locale();
280 Resource *resource = surface ? resourceMap().value(surface->
waylandClient()) : 0;
293 qApp->inputMethod()->show();
305#if !QT_CONFIG(xkbcommon)
306#define XKB_MOD_NAME_SHIFT "Shift"
307#define XKB_MOD_NAME_CTRL "Control"
308#define XKB_MOD_NAME_ALT "Mod1"
309#define XKB_MOD_NAME_LOGO "Mod4"
317 send_modifiers_map(resource->handle,
modifiers);
328 wl_resource_destroy(resource->handle);
342 emit q->surfaceEnabled(
s);
350 emit q->surfaceDisabled(
s);
357 qApp->inputMethod()->show();
364 qApp->inputMethod()->hide();
386 if (
flags == update_state_reset ||
flags == update_state_enter) {
387 qCDebug(qLcWaylandCompositorInputMethods) <<
"QInputMethod::reset()";
388 qApp->inputMethod()->reset();
393 Qt::InputMethodQueries queries;
394 if (
flags == update_state_change) {
404 qCDebug(qLcWaylandCompositorInputMethods) <<
"QInputMethod::update()" << queries;
406 emit q->updateInputMethod(queries);
417 if ((
hint & content_hint_auto_completion) == 0
418 && (
hint & content_hint_auto_correction) == 0)
420 if ((
hint & content_hint_auto_capitalization) == 0)
422 if ((
hint & content_hint_lowercase) != 0)
424 if ((
hint & content_hint_uppercase) != 0)
426 if ((
hint & content_hint_hidden_text) != 0)
428 if ((
hint & content_hint_sensitive_data) != 0)
430 if ((
hint & content_hint_latin) != 0)
432 if ((
hint & content_hint_multiline) != 0)
436 case content_purpose_normal:
438 case content_purpose_alpha:
441 case content_purpose_digits:
444 case content_purpose_number:
447 case content_purpose_phone:
450 case content_purpose_url:
453 case content_purpose_email:
456 case content_purpose_name:
457 case content_purpose_password:
459 case content_purpose_date:
462 case content_purpose_time:
465 case content_purpose_datetime:
468 case content_purpose_terminal:
502 this, &QWaylandTextInput::focusSurfaceDestroyed);
505 this, &QWaylandTextInput::sendInputPanelState);
507 this, &QWaylandTextInput::sendInputPanelState);
509 this, &QWaylandTextInput::sendTextDirection);
511 this, &QWaylandTextInput::sendLocale);
522 d->sendInputMethodEvent(
event);
532void QWaylandTextInput::sendInputPanelState()
536 d->sendInputPanelState();
539void QWaylandTextInput::sendTextDirection()
543 d->sendTextDirection();
546void QWaylandTextInput::sendLocale()
571 d->setFocus(surface);
574void QWaylandTextInput::focusSurfaceDestroyed(
void *)
578 d->focusDestroyListener.reset();
581 d->focusResource =
nullptr;
588 return d->enabledSurfaces.values().contains(surface);
595 d->add(client,
id, version);
600 return QWaylandTextInputPrivate::interface();
605 return QWaylandTextInputPrivate::interfaceName();
619 for (
int i = 0;
i < numModifiers; ++
i) {
622 d->shiftModifierMask = 1 <<
i;
624 d->controlModifierMask = 1 <<
i;
626 d->altModifierMask = 1 <<
i;
628 d->metaModifierMask = 1 <<
i;
630 qCDebug(qLcWaylandCompositorInputMethods) <<
"unsupported modifier name " << modString;
632 d->sendModifiersMap(modifiersMap);
637#include "moc_qwaylandtextinput.cpp"
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays.
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.
qsizetype size() const noexcept
\inmodule QtCore\reentrant
constexpr qreal y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
constexpr qreal x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
QRectF intersected(const QRectF &other) const noexcept
\inmodule QtCore\reentrant
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype size() const
Returns the number of characters in this string.
QString & insert(qsizetype i, QChar c)
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
\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.
static QWaylandSurface * fromResource(::wl_resource *resource)
Returns the QWaylandSurface corresponding to the Wayland resource resource.
Qt::InputMethodHints hints
Qt::InputMethodQueries updatedQueries(const QWaylandTextInputClientState &other) const
QWaylandTextInputClientState()
Qt::InputMethodQueries mergeChanged(const QWaylandTextInputClientState &other)
QString preferredLanguage
void zwp_text_input_v2_set_preferred_language(Resource *resource, const QString &language) override
QHash< Resource *, QWaylandSurface * > enabledSurfaces
void zwp_text_input_v2_enable(Resource *resource, wl_resource *surface) override
void zwp_text_input_v2_update_state(Resource *resource, uint32_t serial, uint32_t flags) override
void setFocus(QWaylandSurface *surface)
QWaylandTextInputPrivate(QWaylandCompositor *compositor)
void zwp_text_input_v2_bind_resource(Resource *resource) override
void zwp_text_input_v2_set_surrounding_text(Resource *resource, const QString &text, int32_t cursor, int32_t anchor) override
QWaylandCompositor * compositor
void zwp_text_input_v2_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override
QWaylandDestroyListener focusDestroyListener
void sendKeyEvent(QKeyEvent *event)
std::unique_ptr< QWaylandTextInputClientState > pendingState
void zwp_text_input_v2_hide_input_panel(Resource *resource) override
void sendInputPanelState()
void zwp_text_input_v2_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) override
void zwp_text_input_v2_disable(Resource *resource, wl_resource *surface) override
void zwp_text_input_v2_show_input_panel(Resource *resource) override
std::unique_ptr< QWaylandTextInputClientState > currentState
void zwp_text_input_v2_destroy_resource(Resource *resource) override
void sendModifiersMap(const QByteArray &modifiersMap)
QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
void zwp_text_input_v2_destroy(Resource *resource) override
void sendInputMethodEvent(QInputMethodEvent *event)
void sendInputMethodEvent(QInputMethodEvent *event)
void sendModifiersMap(const QByteArray &modifiersMap)
static QByteArray interfaceName()
QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const
~QWaylandTextInput() override
QWaylandTextInput(QWaylandObject *container, QWaylandCompositor *compositor)
void setFocus(QWaylandSurface *surface)
bool isSurfaceEnabled(QWaylandSurface *surface) const
void add(::wl_client *client, uint32_t id, int version)
QWaylandSurface * focus() const
static const struct wl_interface * interface()
void sendKeyEvent(QKeyEvent *event)
static QList< xkb_keysym_t > toKeysym(QKeyEvent *event)
EGLImageKHR int int EGLuint64KHR * modifiers
Combined button and popup list for selecting options.
@ ImhFormattedNumbersOnly
@ ImhDialableCharactersOnly
EGLOutputLayerEXT EGLint attribute
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
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
GLenum GLuint GLenum GLsizei length
GLdouble GLdouble GLdouble GLdouble q
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define XKB_MOD_NAME_SHIFT
#define XKB_MOD_NAME_LOGO
#define XKB_MOD_NAME_CTRL
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)