---
name: "wayland_zwp_text_input_v1_t"
section: "3"
platform: "linux"
package: "waylandpp-dev"
version: "1.0.0-6+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/wayland_zwp_text_input_v1_t"
---

# wayland\_zwp\_text\_input\_v1\_t(3)

text input

## NAME

wayland::zwp\_text\_input\_v1\_t - text input

## SYNOPSIS

`#include <wayland-client-protocol-unstable.hpp>`

Inherits **wayland::proxy\_t**.

### Public Types

enum class **wrapper\_type** { **standard**, **display**, **foreign**, **proxy\_wrapper** }\

### Public Member Functions

void **activate** (**seat\_t** const &seat, **surface\_t** const &surface)\
 request activation  void **deactivate** (**seat\_t** const &seat)\
 request deactivation  void **show\_input\_panel** ()\
 show input panels  void **hide\_input\_panel** ()\
 hide input panels  void **reset** ()\
 reset  void **set\_surrounding\_text** (std::string const &text, uint32\_t cursor, uint32\_t anchor)\
 sets the surrounding text  void **set\_content\_type** (**zwp\_text\_input\_v1\_content\_hint** const &hint, zwp\_text\_input\_v1\_content\_purpose const &purpose)\
 set content purpose and hint  void **set\_cursor\_rectangle** (int32\_t x, int32\_t y, int32\_t width, int32\_t height)\
 void **set\_preferred\_language** (std::string const &language)\
 sets preferred language  void **commit\_state** (uint32\_t serial)\
 void **invoke\_action** (uint32\_t button, uint32\_t index)\
 std::function\< void(**surface\_t**)\> & **on\_enter** ()\
 enter event  std::function\< void()\> & **on\_leave** ()\
 leave event  std::function\< void(array\_t)\> & **on\_modifiers\_map** ()\
 modifiers map  std::function\< void(uint32\_t)\> & **on\_input\_panel\_state** ()\
 state of the input panel  std::function\< void(uint32\_t, std::string, std::string)\> & **on\_preedit\_string** ()\
 pre-edit  std::function\< void(uint32\_t, uint32\_t, zwp\_text\_input\_v1\_preedit\_style)\> & **on\_preedit\_styling** ()\
 pre-edit styling  std::function\< void(int32\_t)\> & **on\_preedit\_cursor** ()\
 pre-edit cursor  std::function\< void(uint32\_t, std::string)\> & **on\_commit\_string** ()\
 commit  std::function\< void(int32\_t, int32\_t)\> & **on\_cursor\_position** ()\
 set cursor to new position  std::function\< void(int32\_t, uint32\_t)\> & **on\_delete\_surrounding\_text** ()\
 delete surrounding text  std::function\< void(uint32\_t, uint32\_t, uint32\_t, keyboard\_key\_state, uint32\_t)\> & **on\_keysym** ()\
 keysym  std::function\< void(uint32\_t, std::string)\> & **on\_language** ()\
 language  std::function\< void(uint32\_t, zwp\_text\_input\_v1\_text\_direction)\> & **on\_text\_direction** ()\
 text direction  uint32\_t **get\_id** () const\
 Get the id of a proxy object.  std::string **get\_class** () const\
 Get the interface name (class) of a proxy object.  uint32\_t **get\_version** () const\
 Get the protocol object version of a proxy object.  **wrapper\_type** **get\_wrapper\_type** () const\
 Get the type of a proxy object.  void **set\_queue** (**event\_queue\_t** queue)\
 Assign a proxy to an event queue.  wl\_proxy \* **c\_ptr** () const\
 Get a pointer to the underlying C struct.  bool **proxy\_has\_object** () const\
 Check whether this wrapper actually wraps an object.  **operator bool** () const\
 Check whether this wrapper actually wraps an object.  bool **operator==** (const **proxy\_t** &right) const\
 Check whether two wrappers refer to the same object.  bool **operator!=** (const **proxy\_t** &right) const\
 Check whether two wrappers refer to different objects.  void **proxy\_release** ()\
 Release the wrapped object (if any), making this an empty wrapper.

### Static Public Attributes

static constexpr std::uint32\_t **activate\_since\_version** = 1\
 Minimum protocol version required for the **activate** function.  static constexpr std::uint32\_t **deactivate\_since\_version** = 1\
 Minimum protocol version required for the **deactivate** function.  static constexpr std::uint32\_t **show\_input\_panel\_since\_version** = 1\
 Minimum protocol version required for the **show\_input\_panel** function.  static constexpr std::uint32\_t **hide\_input\_panel\_since\_version** = 1\
 Minimum protocol version required for the **hide\_input\_panel** function.  static constexpr std::uint32\_t **reset\_since\_version** = 1\
 Minimum protocol version required for the **reset** function.  static constexpr std::uint32\_t **set\_surrounding\_text\_since\_version** = 1\
 Minimum protocol version required for the **set\_surrounding\_text** function.  static constexpr std::uint32\_t **set\_content\_type\_since\_version** = 1\
 Minimum protocol version required for the **set\_content\_type** function.  static constexpr std::uint32\_t **set\_cursor\_rectangle\_since\_version** = 1\
 Minimum protocol version required for the **set\_cursor\_rectangle** function.  static constexpr std::uint32\_t **set\_preferred\_language\_since\_version** = 1\
 Minimum protocol version required for the **set\_preferred\_language** function.  static constexpr std::uint32\_t **commit\_state\_since\_version** = 1\
 Minimum protocol version required for the **commit\_state** function.  static constexpr std::uint32\_t **invoke\_action\_since\_version** = 1\
 Minimum protocol version required for the **invoke\_action** function.

## Detailed Description

text input

An object used for text input. Adds support for text input and input methods to applications. A text\_input object is created from a wl\_text\_input\_manager and corresponds typically to a text entry in an application.

Requests are used to activate/deactivate the text\_input object and set state information like surrounding and selected text or the content type. The information about entered text is sent to the text\_input object via the pre-edit and commit events. Using this interface removes the need for applications to directly process hardware key events and compose text out of them.

Text is generally UTF-8 encoded, indices and lengths are in bytes.

Serials are used to synchronize the state between the text input and an input method. New serials are sent by the text input in the commit\_state request and are used by the input method to indicate the known text input state in events like preedit\_string, commit\_string, and keysym. The text input can then ignore events from the input method which are based on an outdated state (for example after a reset).

Warning! The protocol described in this file is experimental and backward incompatible changes may be made. Backward compatible changes may be added together with the corresponding interface version bump. Backward incompatible changes are done by bumping the version number in the protocol and interface names and resetting the interface version. Once the protocol is to be declared stable, the 'z' prefix and the version number in the protocol and interface names are removed and the interface version number is reset.

Definition at line **5624** of file **wayland-client-protocol-unstable.hpp**.

## Member Enumeration Documentation

### enum class wayland::proxy\_t::wrapper\_type` [strong]`, ` [inherited]`

Underlying wl\_proxy type and properties of a **proxy\_t** that affect construction, destruction, and event handling

**Enumerator**

- *standard*

  *C pointer is a standard type compatible with wl\_proxy\*. Events are dispatched and it is destructed when the* **proxy\_t** *is destructed. User data is set.*

- *display*

  *C pointer is a wl\_display\*. No events are dispatched, wl\_display\_disconnect is called when the* **proxy\_t** *is destructed. User data is set.*

- *foreign*

  *C pointer is a standard type compatible with wl\_proxy\*, but another library owns it and it should not be touched in a way that could affect the operation of the other library. No events are dispatched, wl\_proxy\_destroy is not called when the* **proxy\_t** *is destructed, user data is not touched. Consequently, there is no reference counting for the* **proxy\_t***. Lifetime of such wrappers should preferably be short to minimize the chance that the owning library decides to destroy the wl\_proxy.*

- *proxy\_wrapper*

  *C pointer is a wl\_proxy\* that was constructed with wl\_proxy\_create\_wrapper. No events are dispatched, wl\_proxy\_wrapper\_destroy is called when the* **proxy\_t** *is destroyed. Reference counting is active. A reference to the* **proxy\_t** *creating this proxy wrapper is held to extend its lifetime until after the proxy wrapper is destroyed.*

*Definition at line* **116** *of file* **wayland-client.hpp***.*

## Member Function Documentation

### void zwp\_text\_input\_v1\_t::activate (seat\_t const & seat, surface\_t const & surface)

*request activation*

**Parameters**

*seat* \
 *surface*

*Requests the text\_input object to be activated (typically when the text entry gets focus).*

*The seat argument is a wl\_seat which maintains the focus for this activation. The surface argument is a wl\_surface assigned to the text\_input object and tracked for focus lost. The enter event is emitted on successful activation.*

*Definition at line* **8136** *of file* **wayland-client-protocol-unstable.cpp***.*

### wl\_proxy \* wayland::proxy\_t::c\_ptr () const` [inherited]`

*Get a pointer to the underlying C struct.*

**Returns**

*The underlying wl\_proxy wrapped by this* **proxy\_t** *if it exists, otherwise an exception is thrown*

### void zwp\_text\_input\_v1\_t::commit\_state (uint32\_t serial)

**Parameters**

*serial used to identify the known state*

*Definition at line* **8190** *of file* **wayland-client-protocol-unstable.cpp***.*

### void zwp\_text\_input\_v1\_t::deactivate (seat\_t const & seat)

*request deactivation*

**Parameters**

*seat*

*Requests the text\_input object to be deactivated (typically when the text entry lost focus). The seat argument is a wl\_seat which was used for activation.*

*Definition at line* **8142** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::string wayland::proxy\_t::get\_class () const` [inherited]`

*Get the interface name (class) of a proxy object.*

**Returns**

*The interface name of the object associated with the proxy*

### uint32\_t wayland::proxy\_t::get\_id () const` [inherited]`

*Get the id of a proxy object.*

**Returns**

*The id the object associated with the proxy*

### uint32\_t wayland::proxy\_t::get\_version () const` [inherited]`

*Get the protocol object version of a proxy object. Gets the protocol object version of a proxy object, or 0 if the proxy was created with unversioned API.*

*A returned value of 0 means that no version information is available, so the caller must make safe assumptions about the object's real version.*

**display\_t** *will always return version 0.*

**Returns**

*The protocol object version of the proxy or 0*

### wrapper\_type wayland::proxy\_t::get\_wrapper\_type () const` [inline]`, ` [inherited]`

*Get the type of a proxy object.*

*Definition at line* **302** *of file* **wayland-client.hpp***.*

### void zwp\_text\_input\_v1\_t::hide\_input\_panel ()

*hide input panels Requests input panels (virtual keyboard) to hide.*

*Definition at line* **8154** *of file* **wayland-client-protocol-unstable.cpp***.*

### void zwp\_text\_input\_v1\_t::invoke\_action (uint32\_t button, uint32\_t index)

**Parameters**

*button* \
 *index*

*Definition at line* **8196** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(uint32\_t, std::string)\> & zwp\_text\_input\_v1\_t::on\_commit\_string ()

*commit*

**Parameters**

*serial serial of the latest known text input state* \
 *text*

*Notify when text should be inserted into the editor widget. The text to commit could be either just a single character after a key press or the result of some composing (pre-edit). It could also be an empty text when some text should be removed (see delete\_surrounding\_text) or when the input cursor should be moved (see cursor\_position).*

*Any previously set composing text should be removed.*

*Definition at line* **8237** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(int32\_t, int32\_t)\> & zwp\_text\_input\_v1\_t::on\_cursor\_position ()

*set cursor to new position*

**Parameters**

*index* \
 *anchor*

*Notify when the cursor or anchor position should be modified.*

*This event should be handled as part of a following commit\_string event.*

*Definition at line* **8242** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(int32\_t, uint32\_t)\> & zwp\_text\_input\_v1\_t::on\_delete\_surrounding\_text ()

*delete surrounding text*

**Parameters**

*index* \
 *length*

*Notify when the text around the current cursor position should be deleted.*

*Index is relative to the current cursor (in bytes). Length is the length of deleted text (in bytes).*

*This event should be handled as part of a following commit\_string event.*

*Definition at line* **8247** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(surface\_t)\> & zwp\_text\_input\_v1\_t::on\_enter ()

*enter event*

**Parameters**

*surface*

*Notify the text\_input object when it received focus. Typically in response to an activate request.*

*Definition at line* **8202** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(uint32\_t)\> & zwp\_text\_input\_v1\_t::on\_input\_panel\_state ()

*state of the input panel*

**Parameters**

*state*

*Notify when the visibility state of the input panel changed.*

*Definition at line* **8217** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(uint32\_t, uint32\_t, uint32\_t, keyboard\_key\_state, uint32\_t)\> & zwp\_text\_input\_v1\_t::on\_keysym ()

*keysym*

**Parameters**

*serial serial of the latest known text input state* \
 *time* \
 *sym* \
 *state* \
 *modifiers*

*Notify when a key event was sent. Key events should not be used for normal text input operations, which should be done with commit\_string, delete\_surrounding\_text, etc. The key event follows the wl\_keyboard key event convention. Sym is an XKB keysym, state a wl\_keyboard key\_state. Modifiers are a mask for effective modifiers (where the modifier indices are set by the modifiers\_map event)*

*Definition at line* **8252** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(uint32\_t, std::string)\> & zwp\_text\_input\_v1\_t::on\_language ()

*language*

**Parameters**

*serial serial of the latest known text input state* \
 *language*

*Sets the language of the input text. The 'language' argument is an RFC-3066 format language tag.*

*Definition at line* **8257** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void()\> & zwp\_text\_input\_v1\_t::on\_leave ()

*leave event Notify the text\_input object when it lost focus. Either in response to a deactivate request or when the assigned surface lost focus or was destroyed.*

*Definition at line* **8207** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(array\_t)\> & zwp\_text\_input\_v1\_t::on\_modifiers\_map ()

*modifiers map*

**Parameters**

*map*

*Transfer an array of 0-terminated modifier names. The position in the array is the index of the modifier as used in the modifiers bitmask in the keysym event.*

*Definition at line* **8212** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(int32\_t)\> & zwp\_text\_input\_v1\_t::on\_preedit\_cursor ()

*pre-edit cursor*

**Parameters**

*index*

*Sets the cursor position inside the composing text (as byte offset) relative to the start of the composing text. When index is a negative number no cursor is shown.*

*This event is handled as part of a following preedit\_string event.*

*Definition at line* **8232** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(uint32\_t, std::string, std::string)\> & zwp\_text\_input\_v1\_t::on\_preedit\_string ()

*pre-edit*

**Parameters**

*serial serial of the latest known text input state* \
 *text* \
 *commit*

*Notify when a new composing text (pre-edit) should be set around the current cursor position. Any previously set composing text should be removed.*

*The commit text can be used to replace the preedit text on reset (for example on unfocus).*

*The text input should also handle all preedit\_style and preedit\_cursor events occurring directly before preedit\_string.*

*Definition at line* **8222** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(uint32\_t, uint32\_t, zwp\_text\_input\_v1\_preedit\_style)\> & zwp\_text\_input\_v1\_t::on\_preedit\_styling ()

*pre-edit styling*

**Parameters**

*index* \
 *length* \
 *style*

*Sets styling information on composing text. The style is applied for length bytes from index relative to the beginning of the composing text (as byte offset). Multiple styles can be applied to a composing text by sending multiple preedit\_styling events.*

*This event is handled as part of a following preedit\_string event.*

*Definition at line* **8227** *of file* **wayland-client-protocol-unstable.cpp***.*

### std::function\< void(uint32\_t, zwp\_text\_input\_v1\_text\_direction)\> & zwp\_text\_input\_v1\_t::on\_text\_direction ()

*text direction*

**Parameters**

*serial serial of the latest known text input state* \
 *direction*

*Sets the text direction of input text.*

*It is mainly needed for showing an input cursor on the correct side of the editor when there is no input done yet and making sure neutral direction text is laid out properly.*

*Definition at line* **8262** *of file* **wayland-client-protocol-unstable.cpp***.*

### wayland::proxy\_t::operator bool () const` [inherited]`

*Check whether this wrapper actually wraps an object.*

**Returns**

*true if there is an underlying object, false if this wrapper is empty*

### bool wayland::proxy\_t::operator!= (const proxy\_t & right) const` [inherited]`

*Check whether two wrappers refer to different objects.*

### bool wayland::proxy\_t::operator== (const proxy\_t & right) const` [inherited]`

*Check whether two wrappers refer to the same object.*

### bool wayland::proxy\_t::proxy\_has\_object () const` [inherited]`

*Check whether this wrapper actually wraps an object.*

**Returns**

*true if there is an underlying object, false if this wrapper is empty*

### void wayland::proxy\_t::proxy\_release ()` [inherited]`

*Release the wrapped object (if any), making this an empty wrapper. Note that* **display\_t** *instances cannot be released this way. Attempts to do so are ignored.*

**Examples** **foreign\_display.cpp***.*

### void zwp\_text\_input\_v1\_t::reset ()

*reset Should be called by an editor widget when the input state should be reset, for example after the text was changed outside of the normal input method flow.*

*Definition at line* **8160** *of file* **wayland-client-protocol-unstable.cpp***.*

### void zwp\_text\_input\_v1\_t::set\_content\_type (zwp\_text\_input\_v1\_content\_hint const & hint, zwp\_text\_input\_v1\_content\_purpose const & purpose)

*set content purpose and hint*

**Parameters**

*hint* \
 *purpose*

*Sets the content purpose and content hint. While the purpose is the basic purpose of an input field, the hint flags allow to modify some of the behavior.*

*When no content type is explicitly set, a normal content purpose with default hints (auto completion, auto correction, auto capitalization) should be assumed.*

*Definition at line* **8172** *of file* **wayland-client-protocol-unstable.cpp***.*

### void zwp\_text\_input\_v1\_t::set\_cursor\_rectangle (int32\_t x, int32\_t y, int32\_t width, int32\_t height)

**Parameters**

*x* \
 *y* \
 *width* \
 *height*

*Definition at line* **8178** *of file* **wayland-client-protocol-unstable.cpp***.*

### void zwp\_text\_input\_v1\_t::set\_preferred\_language (std::string const & language)

*sets preferred language*

**Parameters**

*language*

*Sets a specific language. This allows for example a virtual keyboard to show a language specific layout. The 'language' argument is an RFC-3066 format language tag.*

*It could be used for example in a word processor to indicate the language of the currently edited document or in an instant message application which tracks languages of contacts.*

*Definition at line* **8184** *of file* **wayland-client-protocol-unstable.cpp***.*

### void wayland::proxy\_t::set\_queue (event\_queue\_t queue)` [inherited]`

*Assign a proxy to an event queue.*

**Parameters**

*queue The event queue that will handle this proxy*

*Assign proxy to event queue. Events coming from proxy will be queued in queue instead of the display's main queue.*

*See also:* **display\_t::dispatch\_queue()***.*

**Examples** **proxy\_wrapper.cpp***.*

### void zwp\_text\_input\_v1\_t::set\_surrounding\_text (std::string const & text, uint32\_t cursor, uint32\_t anchor)

*sets the surrounding text*

**Parameters**

*text* \
 *cursor* \
 *anchor*

*Sets the plain surrounding text around the input position. Text is UTF-8 encoded. Cursor is the byte offset within the surrounding text. Anchor is the byte offset of the selection anchor within the surrounding text. If there is no selected text anchor, then it is the same as cursor.*

*Definition at line* **8166** *of file* **wayland-client-protocol-unstable.cpp***.*

### void zwp\_text\_input\_v1\_t::show\_input\_panel ()

*show input panels Requests input panels (virtual keyboard) to show.*

*Definition at line* **8148** *of file* **wayland-client-protocol-unstable.cpp***.*

## Member Data Documentation

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::activate\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **activate** *function.*

*Definition at line* **5676** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::commit\_state\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **commit\_state** *function.*

*Definition at line* **5803** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::deactivate\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **deactivate** *function.*

*Definition at line* **5690** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::hide\_input\_panel\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **hide\_input\_panel** *function.*

*Definition at line* **5712** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::invoke\_action\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **invoke\_action** *function.*

*Definition at line* **5814** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::reset\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **reset** *function.*

*Definition at line* **5725** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::set\_content\_type\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **set\_content\_type** *function.*

*Definition at line* **5762** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::set\_cursor\_rectangle\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **set\_cursor\_rectangle** *function.*

*Definition at line* **5775** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::set\_preferred\_language\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **set\_preferred\_language** *function.*

*Definition at line* **5793** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::set\_surrounding\_text\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **set\_surrounding\_text** *function.*

*Definition at line* **5743** *of file* **wayland-client-protocol-unstable.hpp***.*

### constexpr std::uint32\_t wayland::zwp\_text\_input\_v1\_t::show\_input\_panel\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **show\_input\_panel** *function.*

*Definition at line* **5701** *of file* **wayland-client-protocol-unstable.hpp***.*

## Author

*Generated automatically by Doxygen for Wayland++ from the source code.*
