---
name: "wayland_server_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_server_zwp_input_method_context_v1_t"
---

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

input method context

## NAME

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

## SYNOPSIS

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

Inherits wayland::server::resource\_t.

### Public Member Functions

std::function\< void(uint32\_t, std::string)\> & **on\_commit\_string** ()\
 commit string  std::function\< void(uint32\_t, std::string, std::string)\> & **on\_preedit\_string** ()\
 pre-edit string  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(int32\_t, uint32\_t)\> & **on\_delete\_surrounding\_text** ()\
 delete text  std::function\< void(int32\_t, int32\_t)\> & **on\_cursor\_position** ()\
 set cursor to a new position  std::function\< void(array\_t)\> & **on\_modifiers\_map** ()\
 std::function\< void(uint32\_t, uint32\_t, uint32\_t, keyboard\_key\_state, uint32\_t)\> & **on\_keysym** ()\
 keysym  std::function\< void(**keyboard\_t**)\> & **on\_grab\_keyboard** ()\
 grab hardware keyboard  std::function\< void(uint32\_t, uint32\_t, uint32\_t, keyboard\_key\_state)\> & **on\_key** ()\
 forward key event  std::function\< void(uint32\_t, uint32\_t, uint32\_t, uint32\_t, uint32\_t)\> & **on\_modifiers** ()\
 forward modifiers event  std::function\< void(uint32\_t, std::string)\> & **on\_language** ()\
 std::function\< void(uint32\_t, uint32\_t)\> & **on\_text\_direction** ()\
 void **surrounding\_text** (std::string const &text, uint32\_t cursor, uint32\_t anchor, bool post=true)\
 surrounding text event  void **content\_type** (**zwp\_text\_input\_v1\_content\_hint** const &hint, zwp\_text\_input\_v1\_content\_purpose const &purpose, bool post=true)\
 void **invoke\_action** (uint32\_t button, uint32\_t index, bool post=true)\
 void **commit\_state** (uint32\_t serial, bool post=true)\
 void **preferred\_language** (std::string const &language, bool post=true)\
 bool **proxy\_has\_object** () const\
 Check whether this wrapper actually wraps an object.  void **post\_no\_memory** () const\
 uint32\_t **get\_id** () const\
 client\_t **get\_client** () const\
 unsigned int **get\_version** () const\
 std::string **get\_class** ()\

### Static Public Attributes

static constexpr std::uint32\_t **surrounding\_text\_since\_version** = 1\
 Minimum protocol version required for the **surrounding\_text** function.  static constexpr std::uint32\_t **reset\_since\_version** = 1\
 Minimum protocol version required for the **reset** function.  static constexpr std::uint32\_t **content\_type\_since\_version** = 1\
 Minimum protocol version required for the **content\_type** function.  static constexpr std::uint32\_t **invoke\_action\_since\_version** = 1\
 Minimum protocol version required for the **invoke\_action** 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 **preferred\_language\_since\_version** = 1\
 Minimum protocol version required for the **preferred\_language** 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 **752** of file **wayland-server-protocol-unstable.hpp**.

## Member Function Documentation

### void zwp\_input\_method\_context\_v1\_t::commit\_state (uint32\_t serial, bool post = `true`)

**Parameters**

*serial* serial of text input state

Definition at line **4523** of file **wayland-server-protocol-unstable.cpp**.

### void zwp\_input\_method\_context\_v1\_t::content\_type (zwp\_text\_input\_v1\_content\_hint const & hint, zwp\_text\_input\_v1\_content\_purpose const & purpose, bool post = `true`)

**Parameters**

*hint* \
 *purpose*

Definition at line **4513** of file **wayland-server-protocol-unstable.cpp**.

### std::string wayland::server::resource\_t::get\_class ()` [inherited]`

Retrieve the interface name (class) of a resource object.

**Returns**

Interface name of the resource object.

### client\_t wayland::server::resource\_t::get\_client () const` [inherited]`

Get the associated client

**Returns**

the client that owns the resource.

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

Get the internal ID of the resource

**Returns**

the internal ID of the resource

### unsigned int wayland::server::resource\_t::get\_version () const` [inherited]`

Get interface version

**Returns**

Interface version this resource has been constructed with.

### void zwp\_input\_method\_context\_v1\_t::invoke\_action (uint32\_t button, uint32\_t index, bool post = `true`)

**Parameters**

*button* \
 *index*

Definition at line **4518** of file **wayland-server-protocol-unstable.cpp**.

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

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 **4425** of file **wayland-server-protocol-unstable.cpp**.

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

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 **4455** of file **wayland-server-protocol-unstable.cpp**.

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

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 **4449** of file **wayland-server-protocol-unstable.cpp**.

### std::function\< void(keyboard\_t)\> & zwp\_input\_method\_context\_v1\_t::on\_grab\_keyboard ()

grab hardware keyboard

**Parameters**

*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 **4473** of file **wayland-server-protocol-unstable.cpp**.

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

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 **4479** of file **wayland-server-protocol-unstable.cpp**.

### std::function\< void(uint32\_t, uint32\_t, uint32\_t, keyboard\_key\_state, uint32\_t)\> & zwp\_input\_method\_context\_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 is a wl\_keyboard key\_state.

Definition at line **4467** of file **wayland-server-protocol-unstable.cpp**.

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

**Parameters**

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

Definition at line **4491** of file **wayland-server-protocol-unstable.cpp**.

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

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 **4485** of file **wayland-server-protocol-unstable.cpp**.

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

**Parameters**

*map*

Definition at line **4461** of file **wayland-server-protocol-unstable.cpp**.

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

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 **4443** of file **wayland-server-protocol-unstable.cpp**.

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

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 **4431** of file **wayland-server-protocol-unstable.cpp**.

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

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 **4437** of file **wayland-server-protocol-unstable.cpp**.

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

**Parameters**

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

Definition at line **4497** of file **wayland-server-protocol-unstable.cpp**.

### void wayland::server::resource\_t::post\_no\_memory () const` [inherited]`

Post 'not enough memory' error to the client

If the compositor has not enough memory to fulfill a certail request of the client, this function can be called to notify the client of this circumstance.

### void zwp\_input\_method\_context\_v1\_t::preferred\_language (std::string const & language, bool post = `true`)

**Parameters**

*language*

Definition at line **4528** of file **wayland-server-protocol-unstable.cpp**.

### bool wayland::server::resource\_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 zwp\_input\_method\_context\_v1\_t::surrounding\_text (std::string const & text, uint32\_t cursor, uint32\_t anchor, bool post = `true`)

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 **4503** of file **wayland-server-protocol-unstable.cpp**.

## Member Data Documentation

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

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

Definition at line **1021** of file **wayland-server-protocol-unstable.hpp**.

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

Minimum protocol version required for the **content\_type** function.

Definition at line **1000** of file **wayland-server-protocol-unstable.hpp**.

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

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

Definition at line **1011** of file **wayland-server-protocol-unstable.hpp**.

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

Minimum protocol version required for the **preferred\_language** function.

Definition at line **1031** of file **wayland-server-protocol-unstable.hpp**.

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

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

Definition at line **989** of file **wayland-server-protocol-unstable.hpp**.

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

Minimum protocol version required for the **surrounding\_text** function.

Definition at line **980** of file **wayland-server-protocol-unstable.hpp**.

## Author

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