---
name: "wayland_zwp_input_method_context_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_input_method_context_v1_t"
---

# wayland\_zwp\_input\_method\_context\_v1\_t(3)

input method context

## NAME

wayland::zwp\_input\_method\_context\_v1\_t - input method context

## 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 **commit\_string** (uint32\_t serial, std::string const &text)\
 commit string  void **preedit\_string** (uint32\_t serial, std::string const &text, std::string const &commit)\
 pre-edit string  void **preedit\_styling** (uint32\_t index, uint32\_t length, zwp\_text\_input\_v1\_preedit\_style const &style)\
 pre-edit styling  void **preedit\_cursor** (int32\_t index)\
 pre-edit cursor  void **delete\_surrounding\_text** (int32\_t index, uint32\_t length)\
 delete text  void **cursor\_position** (int32\_t index, int32\_t anchor)\
 set cursor to a new position  void **modifiers\_map** (array\_t const &map)\
 void **keysym** (uint32\_t serial, uint32\_t time, uint32\_t sym, keyboard\_key\_state const &state, uint32\_t **modifiers**)\
 keysym  **keyboard\_t** **grab\_keyboard** ()\
 grab hardware keyboard  void **key** (uint32\_t serial, uint32\_t time, uint32\_t key, keyboard\_key\_state const &state)\
 forward key event  void **modifiers** (uint32\_t serial, uint32\_t mods\_depressed, uint32\_t mods\_latched, uint32\_t mods\_locked, uint32\_t group)\
 forward modifiers event  void **language** (uint32\_t serial, std::string const &language)\
 void **text\_direction** (uint32\_t serial, uint32\_t direction)\
 std::function\< void(std::string, uint32\_t, uint32\_t)\> & **on\_surrounding\_text** ()\
 surrounding text event  std::function\< void(**zwp\_text\_input\_v1\_content\_hint**, zwp\_text\_input\_v1\_content\_purpose)\> & **on\_content\_type** ()\
 std::function\< void(uint32\_t, uint32\_t)\> & **on\_invoke\_action** ()\
 std::function\< void(uint32\_t)\> & **on\_commit\_state** ()\
 std::function\< void(std::string)\> & **on\_preferred\_language** ()\
 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 **commit\_string\_since\_version** = 1\
 Minimum protocol version required for the **commit\_string** function.  static constexpr std::uint32\_t **preedit\_string\_since\_version** = 1\
 Minimum protocol version required for the **preedit\_string** function.  static constexpr std::uint32\_t **preedit\_styling\_since\_version** = 1\
 Minimum protocol version required for the **preedit\_styling** function.  static constexpr std::uint32\_t **preedit\_cursor\_since\_version** = 1\
 Minimum protocol version required for the **preedit\_cursor** function.  static constexpr std::uint32\_t **delete\_surrounding\_text\_since\_version** = 1\
 Minimum protocol version required for the **delete\_surrounding\_text** function.  static constexpr std::uint32\_t **cursor\_position\_since\_version** = 1\
 Minimum protocol version required for the **cursor\_position** function.  static constexpr std::uint32\_t **modifiers\_map\_since\_version** = 1\
 Minimum protocol version required for the **modifiers\_map** function.  static constexpr std::uint32\_t **keysym\_since\_version** = 1\
 Minimum protocol version required for the **keysym** function.  static constexpr std::uint32\_t **grab\_keyboard\_since\_version** = 1\
 Minimum protocol version required for the **grab\_keyboard** function.  static constexpr std::uint32\_t **key\_since\_version** = 1\
 Minimum protocol version required for the **key** function.  static constexpr std::uint32\_t **modifiers\_since\_version** = 1\
 Minimum protocol version required for the **modifiers** function.  static constexpr std::uint32\_t **language\_since\_version** = 1\
 Minimum protocol version required for the **language** function.  static constexpr std::uint32\_t **text\_direction\_since\_version** = 1\
 Minimum protocol version required for the **text\_direction** function.

## Detailed Description

input method context

Corresponds to a text input on the input method side. An input method context is created on text input activation on the input method side. It allows receiving information about the text input from the application via events. Input method contexts do not keep state after deactivation and should be destroyed after deactivation is handled.

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 **704** 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

### 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\_input\_method\_context\_v1\_t::commit\_string (uint32\_t serial, std::string const & text)

*commit string*

**Parameters**

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

*Send the commit string text for insertion to the application.*

*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 be also 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 will be removed.*

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

### void zwp\_input\_method\_context\_v1\_t::cursor\_position (int32\_t index, int32\_t anchor)

*set cursor to a new position*

**Parameters**

*index* \
 *anchor*

*Set the cursor and anchor to a new position. Index is the new cursor position in bytes (when \>= 0 this is relative to the end of the inserted text, otherwise it is relative to the beginning of the inserted text). Anchor is the new anchor position in bytes (when \>= 0 this is relative to the end of the inserted text, otherwise it is relative to the beginning of the inserted text). When there should be no selected text, anchor should be the same as index.*

*This request will be handled on the text\_input side directly following a commit\_string request.*

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

### void zwp\_input\_method\_context\_v1\_t::delete\_surrounding\_text (int32\_t index, uint32\_t length)

*delete text*

**Parameters**

*index* \
 *length*

*Remove the surrounding text.*

*This request will be handled on the text\_input side directly following a commit\_string request.*

*Definition at line* **4567** *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***.*

### keyboard\_t zwp\_input\_method\_context\_v1\_t::grab\_keyboard ()

*grab hardware keyboard Allow an input method to receive hardware keyboard input and process key events to generate text events (with pre-edit) over the wire. This allows input methods which compose multiple key events for inputting text like it is done for CJK languages.*

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

### void zwp\_input\_method\_context\_v1\_t::key (uint32\_t serial, uint32\_t time, uint32\_t key, keyboard\_key\_state const & state)

*forward key event*

**Parameters**

*serial serial from wl\_keyboard::key* \
 *time time from wl\_keyboard::key* \
 *key key from wl\_keyboard::key* \
 *state state from wl\_keyboard::key*

*Forward a wl\_keyboard::key event to the client that was not processed by the input method itself. Should be used when filtering key events with grab\_keyboard. The arguments should be the ones from the wl\_keyboard::key event.*

*For generating custom key events use the keysym request instead.*

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

### void zwp\_input\_method\_context\_v1\_t::keysym (uint32\_t serial, uint32\_t time, uint32\_t sym, keyboard\_key\_state const & state, uint32\_t modifiers)

*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 is a wl\_keyboard key\_state.*

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

### void zwp\_input\_method\_context\_v1\_t::language (uint32\_t serial, std::string const & language)

**Parameters**

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

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

### void zwp\_input\_method\_context\_v1\_t::modifiers (uint32\_t serial, uint32\_t mods\_depressed, uint32\_t mods\_latched, uint32\_t mods\_locked, uint32\_t group)

*forward modifiers event*

**Parameters**

*serial serial from wl\_keyboard::modifiers* \
 *mods\_depressed mods\_depressed from wl\_keyboard::modifiers* \
 *mods\_latched mods\_latched from wl\_keyboard::modifiers* \
 *mods\_locked mods\_locked from wl\_keyboard::modifiers* \
 *group group from wl\_keyboard::modifiers*

*Forward a wl\_keyboard::modifiers event to the client that was not processed by the input method itself. Should be used when filtering key events with grab\_keyboard. The arguments should be the ones from the wl\_keyboard::modifiers event.*

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

### void zwp\_input\_method\_context\_v1\_t::modifiers\_map (array\_t const & map)

**Parameters**

*map*

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

### std::function\< void(uint32\_t)\> & zwp\_input\_method\_context\_v1\_t::on\_commit\_state ()

**Parameters**

*serial serial of text input state*

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

### std::function\< void(zwp\_text\_input\_v1\_content\_hint, zwp\_text\_input\_v1\_content\_purpose)\> & zwp\_input\_method\_context\_v1\_t::on\_content\_type ()

**Parameters**

*hint* \
 *purpose*

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

### std::function\< void(uint32\_t, uint32\_t)\> & zwp\_input\_method\_context\_v1\_t::on\_invoke\_action ()

**Parameters**

*button* \
 *index*

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

### std::function\< void(std::string)\> & zwp\_input\_method\_context\_v1\_t::on\_preferred\_language ()

**Parameters**

*language*

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

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

*surrounding text event*

**Parameters**

*text* \
 *cursor* \
 *anchor*

*The plain surrounding text around the input position. Cursor is the position in bytes within the surrounding text relative to the beginning of the text. Anchor is the position in bytes of the selection anchor within the surrounding text relative to the beginning of the text. If there is no selected text then anchor is the same as cursor.*

*Definition at line* **4622** *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.*

### void zwp\_input\_method\_context\_v1\_t::preedit\_cursor (int32\_t index)

*pre-edit cursor*

**Parameters**

*index*

*Set the cursor position inside the composing text (as byte offset) relative to the start of the composing text.*

*When index is negative no cursor should be displayed.*

*This request should be sent before sending a preedit\_string request.*

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

### void zwp\_input\_method\_context\_v1\_t::preedit\_string (uint32\_t serial, std::string const & text, std::string const & commit)

*pre-edit string*

**Parameters**

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

*Send the pre-edit string text to the application text input.*

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

*Previously sent preedit\_style and preedit\_cursor requests are also processed by the text\_input.*

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

### void zwp\_input\_method\_context\_v1\_t::preedit\_styling (uint32\_t index, uint32\_t length, zwp\_text\_input\_v1\_preedit\_style const & style)

*pre-edit styling*

**Parameters**

*index* \
 *length* \
 *style*

*Set the styling information on composing text. The style is applied for length in bytes from index relative to the beginning of the composing text (as byte offset). Multiple styles can be applied to a composing text.*

*This request should be sent before sending a preedit\_string request.*

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

### 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 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\_input\_method\_context\_v1\_t::text\_direction (uint32\_t serial, uint32\_t direction)

**Parameters**

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

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

## Member Data Documentation

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

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

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

### constexpr std::uint32\_t wayland::zwp\_input\_method\_context\_v1\_t::cursor\_position\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **cursor\_position** *function.*

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

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

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

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

### constexpr std::uint32\_t wayland::zwp\_input\_method\_context\_v1\_t::grab\_keyboard\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **grab\_keyboard** *function.*

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

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

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

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

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

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

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

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

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

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

### constexpr std::uint32\_t wayland::zwp\_input\_method\_context\_v1\_t::modifiers\_map\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **modifiers\_map** *function.*

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

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

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

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

### constexpr std::uint32\_t wayland::zwp\_input\_method\_context\_v1\_t::preedit\_cursor\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **preedit\_cursor** *function.*

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

### constexpr std::uint32\_t wayland::zwp\_input\_method\_context\_v1\_t::preedit\_string\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **preedit\_string** *function.*

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

### constexpr std::uint32\_t wayland::zwp\_input\_method\_context\_v1\_t::preedit\_styling\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **preedit\_styling** *function.*

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

### constexpr std::uint32\_t wayland::zwp\_input\_method\_context\_v1\_t::text\_direction\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **text\_direction** *function.*

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

## Author

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