21const quint32 s_version = 1;
24TextInputContentHints convertContentHint(uint32_t hint)
26 const auto hints = QtWaylandServer::zwp_text_input_v1::content_hint(hint);
29 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_auto_completion) {
32 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_auto_correction) {
35 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_auto_capitalization) {
38 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_lowercase) {
41 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_uppercase) {
44 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_titlecase) {
47 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_hidden_text) {
50 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_sensitive_data) {
53 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_latin) {
56 if (hints & QtWaylandServer::zwp_text_input_v1::content_hint_multiline) {
64 const auto wlPurpose = QtWaylandServer::zwp_text_input_v1::content_purpose(purpose);
67 case QtWaylandServer::zwp_text_input_v1::content_purpose_alpha:
69 case QtWaylandServer::zwp_text_input_v1::content_purpose_digits:
71 case QtWaylandServer::zwp_text_input_v1::content_purpose_number:
73 case QtWaylandServer::zwp_text_input_v1::content_purpose_phone:
75 case QtWaylandServer::zwp_text_input_v1::content_purpose_url:
77 case QtWaylandServer::zwp_text_input_v1::content_purpose_email:
79 case QtWaylandServer::zwp_text_input_v1::content_purpose_name:
81 case QtWaylandServer::zwp_text_input_v1::content_purpose_password:
83 case QtWaylandServer::zwp_text_input_v1::content_purpose_date:
85 case QtWaylandServer::zwp_text_input_v1::content_purpose_time:
87 case QtWaylandServer::zwp_text_input_v1::content_purpose_datetime:
89 case QtWaylandServer::zwp_text_input_v1::content_purpose_terminal:
91 case QtWaylandServer::zwp_text_input_v1::content_purpose_normal:
101 EnabledEmitter(TextInputV1Interface *q)
103 , m_wasEnabled(q->isEnabled())
108 if (m_wasEnabled != q->isEnabled()) {
109 Q_EMIT q->enabledChanged();
114 TextInputV1Interface *q;
115 const bool m_wasEnabled;
121 : QtWaylandServer::zwp_text_input_manager_v1(*_display, s_version)
130 if (seats.isEmpty()) {
131 wl_resource_post_error(resource->handle, 0,
"No seat on display.");
136 textInputPrivate->add(resource->client(),
id, resource->version());
149 EnabledEmitter emitter(
q);
151 Q_ASSERT(newSurface);
154 if (
auto resource =
activated.value(newSurface)) {
155 send_enter(resource->handle, newSurface->
resource());
162 Q_ASSERT(leavingSurface &&
surface == leavingSurface);
163 EnabledEmitter emitter(
q);
166 if (
auto resource =
activated.value(leavingSurface)) {
167 send_leave(resource->handle);
174 send_preedit_string(resource->handle,
serialHash.value(resource), text, commit);
181 send_preedit_styling(resource->handle, index, length, style);
188 send_commit_string(resource->handle,
serialHash.value(resource), text);
195 send_keysym(resource->handle,
serialHash.value(resource), time, keysym, WL_KEYBOARD_KEY_STATE_PRESSED, modifiers);
202 send_keysym(resource->handle,
serialHash.value(resource), time, keysym, WL_KEYBOARD_KEY_STATE_RELEASED, modifiers);
209 send_delete_surrounding_text(resource->handle, index, length);
216 send_cursor_position(resource->handle, index, anchor);
222 text_direction wlDirection;
224 case Qt::LeftToRight:
225 wlDirection = text_direction::text_direction_ltr;
227 case Qt::RightToLeft:
228 wlDirection = text_direction::text_direction_rtl;
230 case Qt::LayoutDirectionAuto:
231 wlDirection = text_direction::text_direction_auto;
238 send_text_direction(resource->handle,
serialHash.value(resource), wlDirection);
245 send_preedit_cursor(resource->handle, index);
252 send_input_panel_state(resource->handle,
286 if (iter.value() == resource) {
297 if (!s || this->seat != s) {
298 wl_resource_post_error(resource->handle, 0,
"Invalid seat");
301 EnabledEmitter emitter(
q);
303 auto *oldResource =
activated.value(enabledSurface);
304 if (oldResource == resource) {
308 if (this->surface == enabledSurface) {
310 send_leave(oldResource->handle);
312 send_enter(resource->handle,
surface);
315 EnabledEmitter emitter(
q);
323 if (!s || this->seat != s) {
324 wl_resource_post_error(resource->handle, 0,
"Invalid seat");
327 EnabledEmitter emitter(
q);
330 if (iter.value() == resource) {
332 send_leave(resource->handle);
383 const QRect rect = QRect(x, y, width, height);
405 return resourceMap().values(client->
client());
420 return d->preferredLanguage;
425 return d->contentHints;
430 return d->contentPurpose;
435 return d->surroundingText;
440 return d->surroundingTextCursorPosition;
445 return d->surroundingTextSelectionAnchor;
450 d->preEdit(text, commit);
455 d->preEditStyling(index, length, style);
460 d->commitString(text);
465 d->keysymPressed(time, keysym, modifiers);
470 d->keysymReleased(time, keysym, modifiers);
475 d->deleteSurroundingText(beforeLength, afterLength);
480 d->setCursorPosition(index, anchor);
485 d->setTextDirection(direction);
490 d->setPreEditCursor(index);
495 if (d->inputPanelVisible == visible) {
499 d->inputPanelVisible = visible;
500 d->sendInputPanelState();
505 if (d->language == languageTag) {
509 d->language = languageTag;
515 if (d->modifiersMap == modifiersMap) {
519 d->modifiersMap = modifiersMap;
520 d->sendModifiersMap();
525 if (!d->resourceMap().contains(d->surface->client()->client())) {
534 return d->cursorRectangle;
542 return d->activated.contains(d->surface);
547 return client && d->resourceMap().contains(*client);
551#include "moc_textinput_v1.cpp"
Convenient Class which represents a wl_client.
wl_client * client() const
Class holding the Wayland server display loop.
QList< SeatInterface * > seats() const
Represents a Seat on the Wayland Display.
static SeatInterface * get(wl_resource *native)
Resource representing a wl_surface.
static SurfaceInterface * get(wl_resource *native)
void aboutToBeDestroyed()
wl_resource * resource() const
Represent the Global for the interface.
~TextInputManagerV1Interface() override
TextInputManagerV1Interface(Display *display, QObject *parent=nullptr)
std::unique_ptr< TextInputV1Interface > textInputV1
void zwp_text_input_manager_v1_create_text_input(Resource *resource, uint32_t id) override
TextInputManagerV1InterfacePrivate(TextInputManagerV1Interface *_q, Display *display)
Represents a generic Resource for a text input object.
qint32 surroundingTextSelectionAnchor() const
void requestShowInputPanel()
TextInputContentPurpose contentPurpose() const
void keysymReleased(quint32 time, quint32 keysym, quint32 modifiers=0)
QString preferredLanguage() const
bool clientSupportsTextInput(ClientConnection *client) const
void stateUpdated(quint32 serial)
QPointer< SurfaceInterface > surface() const
void keysymPressed(quint32 time, quint32 keysym, quint32 modifiers=0)
void surroundingTextChanged()
void cursorRectangleChanged(const QRect &rect)
void preEditStyling(uint32_t index, uint32_t length, uint32_t style)
void setInputPanelState(bool visible)
void setLanguage(const QString &languageTag)
qint32 surroundingTextCursorPosition() const
void setPreEditCursor(qint32 index)
void preEdit(const QString &text, const QString &commitText)
void preferredLanguageChanged(const QString &language)
void contentTypeChanged()
void commitString(const QString &text)
void setTextDirection(Qt::LayoutDirection direction)
~TextInputV1Interface() override
void setModifiersMap(const QByteArray &modifiersMap)
void setCursorPosition(qint32 index, qint32 anchor)
void invokeAction(quint32 button, quint32 index)
void deleteSurroundingText(quint32 beforeLength, quint32 afterLength)
void requestHideInputPanel()
TextInputContentHints contentHints() const
QString surroundingText() const
TextInputV1Interface(SeatInterface *seat)
QRect cursorRectangle() const
void keysymReleased(quint32 time, quint32 keysym, quint32 modifiers)
QHash< Resource *, quint32 > serialHash
void sendEnter(SurfaceInterface *surface)
TextInputContentPurpose contentPurpose
void zwp_text_input_v1_show_input_panel(Resource *resource) override
qint32 surroundingTextSelectionAnchor
void setCursorPosition(qint32 index, qint32 anchor)
void keysymPressed(quint32 time, quint32 keysym, quint32 modifiers)
void setPreEditCursor(qint32 index)
void commitString(const QString &text)
QPointer< SurfaceInterface > surface
void deleteSurroundingText(qint32 index, quint32 length)
void sendLeave(SurfaceInterface *surface)
void forActivatedResource(const T &callback)
void setTextDirection(Qt::LayoutDirection direction)
void preEditStyling(quint32 index, uint32_t length, uint32_t style)
void zwp_text_input_v1_reset(Resource *resource) override
qint32 surroundingTextCursorPosition
void zwp_text_input_v1_set_preferred_language(Resource *resource, const QString &language) override
void preEdit(const QString &text, const QString &commit)
TextInputContentHints contentHints
QString preferredLanguage
void zwp_text_input_v1_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override
void sendInputPanelState()
void zwp_text_input_v1_destroy_resource(Resource *resource) override
void zwp_text_input_v1_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) override
void zwp_text_input_v1_deactivate(Resource *resource, wl_resource *seat) override
QList< Resource * > textInputsForClient(ClientConnection *client) const
QHash< SurfaceInterface *, Resource * > activated
void zwp_text_input_v1_hide_input_panel(Resource *resource) override
void zwp_text_input_v1_invoke_action(Resource *resource, uint32_t button, uint32_t index) override
void zwp_text_input_v1_bind_resource(Resource *resource) override
void zwp_text_input_v1_activate(Resource *resource, struct wl_resource *seat, struct wl_resource *surface) override
void zwp_text_input_v1_set_surrounding_text(Resource *resource, const QString &text, uint32_t cursor, uint32_t anchor) override
QPointer< SeatInterface > seat
void zwp_text_input_v1_commit_state(Resource *resource, uint32_t serial) override
TextInputV1InterfacePrivate(SeatInterface *seat, TextInputV1Interface *_q)
static TextInputV1InterfacePrivate * get(TextInputV1Interface *inputInterface)