Skip to main content

XxInputMethodV1

Struct XxInputMethodV1 

pub struct XxInputMethodV1 { /* private fields */ }
Expand description

input method

An input method object allows for clients to compose text.

The objects connects the client to a text input in an application, and lets the client to serve as an input method for a seat.

The xx_input_method_v1 object can occupy two distinct states: active and inactive. In the active state, the object is associated to and communicates with a text input. In the inactive state, there is no associated text input, and the only communication is with the compositor. Initially, the input method is in the inactive state.

Requests issued in the inactive state must be accepted by the compositor. Because of the serial mechanism, and the state reset on activate event, they will not have any effect on the state of the next text input.

There must be no more than one input method object per seat.

See also the [Event] enum for this interface.

Implementations§

§

impl XxInputMethodV1

pub fn perform_action(&self, action: Action)

perform action

Perform an action on this text input.

Values set with this event are double-buffered. They must be applied and reset to initial on the next commit request.

The initial value of action is none.

pub fn commit_string(&self, text: String)

commit string

Send the commit string text for insertion to the application.

Inserts a string at current cursor position (see commit event sequence). The string to commit could be either just a single character after a key press or the result of some composing.

The argument text is a buffer containing the string to insert. There is a maximum length of wayland messages, so text can not be longer than 4000 bytes.

Values set with this request are double-buffered. They must be applied and reset to initial on the next .commit request.

The initial value of text is an empty string.

pub fn set_preedit_string( &self, text: String, cursor_begin: i32, cursor_end: i32, )

pre-edit string

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

Place a new composing text (pre-edit) at the current cursor position. Any previously set composing text must be removed. Any previously existing selected text must be removed. The cursor is moved to a new position within the preedit string.

The argument text is a buffer containing the preedit string. There is a maximum length of wayland messages, so text can not be longer than 4000 bytes.

The arguments cursor_begin and cursor_end are counted in bytes relative to the beginning of the submitted string buffer. Cursor should be hidden by the text input when both are equal to -1.

cursor_begin indicates the beginning of the cursor. cursor_end indicates the end of the cursor. It may be equal or different than cursor_begin.

Values set with this request are double-buffered. They must be applied on the next xx_input_method_v1.commit request. They must be reset to initial on the next committed disable event.

The initial value of text is an empty string. The initial value of cursor_begin, and cursor_end are both 0.

pub fn delete_surrounding_text(&self, before_length: u32, after_length: u32)

delete text

Remove the surrounding text.

before_length and after_length are the number of bytes before and after the current cursor index (excluding the preedit text) to delete.

If any preedit text is present, it is replaced with the cursor for the purpose of this event. In effect before_length is counted from the beginning of preedit text, and after_length from its end (see commit event sequence).

Values set with this request are double-buffered. They must be applied and reset to initial on the next xx_input_method_v1.commit request.

The initial values of both before_length and after_length are 0.

pub fn move_cursor(&self, cursor: i32, anchor: i32)

move cursor and change selection

Unselects text, moves the cursor and selects text.

This is equivalent to dragging the mouse over some text: it deselects whatever might be currently selected and selects a new range of text.

The offsets used in arguments are in bytes relative to the current cursor position. Cursor is the new position of the cursor, and anchor is the opposite end of selection. If there’s no selection, anchor should be equal to cursor.

The offsets do not take preedit contents into account, nor is preedit changed in any way with this request.

Both cursor and anchor must fall on code point boundaries, otherwise text input client may ignore the request. It is therefore not recommended for an input method to move any of them beyond the text received in surrounding_text.

When surrounding_text is not supported, the offsets must not be interpreted as bytes, but as some human-readable unit at least as big as a code point, for example a grapheme.

The cursor and anchor arguments can also take the following special values: BEGINNING := 0x8000_0000 = i32::MIN END := 0x7fff_ffff = i32::MAX meaning, respectively, the beginning and the end of of all text in the input field.

Values set with this event are double-buffered. They must be applied and reset to initial on the next commit request.

The initial values of both cursor and anchor are 0.

pub fn commit(&self, serial: u32)

apply state

Apply state changes from commit_string, set_preedit_string and delete_surrounding_text requests.

The state relating to these events is double-buffered, and each one modifies the pending state. This request replaces the current state with the pending state.

The connected text input is expected to proceed by evaluating the changes in the following order:

  1. Replace existing preedit string with the cursor.
  2. Delete requested surrounding text.
  3. Insert commit string with the cursor at its end.
  4. Move the cursor and selection.
  5. Calculate surrounding text to send.
  6. Insert new preedit text in cursor position.
  7. Place cursor inside preedit text.
  8. Perform the requested action.

Note that the input method can not receive more than 4000 bytes of selection text, which might be the case for example when the entire document is selected. Nevertheless, the text input must delete the entire selected range before inserting the commit string.

The serial number reflects the last state of the xx_input_method_v1 object known to the client. The value of the serial argument must be equal to the number of done events already issued by that object. When the compositor receives a commit request with a serial different than the number of past done events, it must proceed as normal, except it should not change the current state of the xx_input_method_v1 object.

pub fn get_input_popup_surface<U, D>( &self, surface: &WlSurface, positioner: &XxInputPopupPositionerV1, qh: &QueueHandle<D>, udata: U, ) -> XxInputPopupSurfaceV2
where U: Send + Sync + 'static, D: Dispatch<XxInputPopupSurfaceV2, U> + 'static,

create popup surface

Creates a new xx_input_popup_surface_v2 object wrapping a given surface.

The surface gets assigned the “input_popup” role. If the surface already has an assigned role, the compositor must issue a protocol error.

Issuing this request before receiving a committed .activate causes the “inactive” error.

pub fn destroy(&self)

destroy the input method

Destroys the xx_input_method_v1 object and any associated child objects.

Trait Implementations§

§

impl Borrow<ObjectId> for XxInputMethodV1

§

fn borrow(&self) -> &ObjectId

Immutably borrows from an owned value. Read more
§

impl Clone for XxInputMethodV1

§

fn clone(&self) -> XxInputMethodV1

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for XxInputMethodV1

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<D, U> Dispatch2<XxInputMethodV1, D> for InputMethodData<U>

Source§

fn event( &self, data: &mut D, input_method: &XxInputMethodV1, event: Event, _conn: &Connection, qh: &QueueHandle<D>, )

Source§

fn event_created_child( opcode: u16, _qh: &QueueHandle<State>, ) -> Arc<dyn ObjectData>

§

impl Hash for XxInputMethodV1

§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq<Weak<XxInputMethodV1>> for XxInputMethodV1

§

fn eq(&self, other: &Weak<XxInputMethodV1>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq for XxInputMethodV1

§

fn eq(&self, other: &XxInputMethodV1) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Proxy for XxInputMethodV1

§

type Request<'request> = Request<'request>

The request enum for this interface
§

type Event = Event

The event enum for this interface
§

fn interface() -> &'static Interface

The interface description
§

fn id(&self) -> ObjectId

The ID of this object
§

fn version(&self) -> u32

The version of this object
§

fn data<U>(&self) -> Option<&U>
where U: Send + Sync + 'static,

Access the user-data associated with this object
§

fn object_data(&self) -> Option<&Arc<dyn ObjectData>>

Access the raw data associated with this object. Read more
§

fn backend(&self) -> &WeakBackend

Access the backend associated with this object
§

fn send_request( &self, req: <XxInputMethodV1 as Proxy>::Request<'_>, ) -> Result<(), InvalidId>

Send a request for this object. Read more
§

fn send_constructor<I>( &self, req: <XxInputMethodV1 as Proxy>::Request<'_>, data: Arc<dyn ObjectData>, ) -> Result<I, InvalidId>
where I: Proxy,

Send a request for this object that creates another object. Read more
§

fn from_id( conn: &Connection, id: ObjectId, ) -> Result<XxInputMethodV1, InvalidId>

Create an object proxy from its ID Read more
§

fn inert(backend: WeakBackend) -> XxInputMethodV1

Create an inert object proxy Read more
§

fn parse_event( conn: &Connection, msg: Message<ObjectId, OwnedFd>, ) -> Result<(XxInputMethodV1, <XxInputMethodV1 as Proxy>::Event), DispatchError>

Parse a event for this object Read more
§

fn write_request<'a>( &self, conn: &Connection, msg: <XxInputMethodV1 as Proxy>::Request<'a>, ) -> Result<(Message<ObjectId, BorrowedFd<'a>>, Option<(&'static Interface, u32)>), InvalidId>

Serialize a request for this object Read more
§

fn is_alive(&self) -> bool

Checks if the Wayland object associated with this proxy is still alive
§

fn downgrade(&self) -> Weak<Self>

Creates a weak handle to this object Read more
§

impl Eq for XxInputMethodV1

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more