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
impl XxInputMethodV1
pub fn perform_action(&self, action: Action)
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)
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,
)
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)
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)
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)
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:
- Replace existing preedit string with the cursor.
- Delete requested surrounding text.
- Insert commit string with the cursor at its end.
- Move the cursor and selection.
- Calculate surrounding text to send.
- Insert new preedit text in cursor position.
- Place cursor inside preedit text.
- 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
pub fn get_input_popup_surface<U, D>( &self, surface: &WlSurface, positioner: &XxInputPopupPositionerV1, qh: &QueueHandle<D>, udata: U, ) -> XxInputPopupSurfaceV2
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)
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
impl Borrow<ObjectId> for XxInputMethodV1
§impl Clone for XxInputMethodV1
impl Clone for XxInputMethodV1
§fn clone(&self) -> XxInputMethodV1
fn clone(&self) -> XxInputMethodV1
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for XxInputMethodV1
impl Debug for XxInputMethodV1
Source§impl<D, U> Dispatch2<XxInputMethodV1, D> for InputMethodData<U>where
D: InputMethodHandler,
impl<D, U> Dispatch2<XxInputMethodV1, D> for InputMethodData<U>where
D: InputMethodHandler,
fn event( &self, data: &mut D, input_method: &XxInputMethodV1, event: Event, _conn: &Connection, qh: &QueueHandle<D>, )
fn event_created_child( opcode: u16, _qh: &QueueHandle<State>, ) -> Arc<dyn ObjectData>
§impl Hash for XxInputMethodV1
impl Hash for XxInputMethodV1
§impl PartialEq<Weak<XxInputMethodV1>> for XxInputMethodV1
impl PartialEq<Weak<XxInputMethodV1>> for XxInputMethodV1
§impl PartialEq for XxInputMethodV1
impl PartialEq for XxInputMethodV1
§impl Proxy for XxInputMethodV1
impl Proxy for XxInputMethodV1
§fn object_data(&self) -> Option<&Arc<dyn ObjectData>>
fn object_data(&self) -> Option<&Arc<dyn ObjectData>>
§fn send_request(
&self,
req: <XxInputMethodV1 as Proxy>::Request<'_>,
) -> Result<(), InvalidId>
fn send_request( &self, req: <XxInputMethodV1 as Proxy>::Request<'_>, ) -> Result<(), InvalidId>
§fn send_constructor<I>(
&self,
req: <XxInputMethodV1 as Proxy>::Request<'_>,
data: Arc<dyn ObjectData>,
) -> Result<I, InvalidId>where
I: Proxy,
fn send_constructor<I>(
&self,
req: <XxInputMethodV1 as Proxy>::Request<'_>,
data: Arc<dyn ObjectData>,
) -> Result<I, InvalidId>where
I: Proxy,
§fn from_id(
conn: &Connection,
id: ObjectId,
) -> Result<XxInputMethodV1, InvalidId>
fn from_id( conn: &Connection, id: ObjectId, ) -> Result<XxInputMethodV1, InvalidId>
§fn inert(backend: WeakBackend) -> XxInputMethodV1
fn inert(backend: WeakBackend) -> XxInputMethodV1
§fn parse_event(
conn: &Connection,
msg: Message<ObjectId, OwnedFd>,
) -> Result<(XxInputMethodV1, <XxInputMethodV1 as Proxy>::Event), DispatchError>
fn parse_event( conn: &Connection, msg: Message<ObjectId, OwnedFd>, ) -> Result<(XxInputMethodV1, <XxInputMethodV1 as Proxy>::Event), DispatchError>
§fn write_request<'a>(
&self,
conn: &Connection,
msg: <XxInputMethodV1 as Proxy>::Request<'a>,
) -> Result<(Message<ObjectId, BorrowedFd<'a>>, Option<(&'static Interface, u32)>), InvalidId>
fn write_request<'a>( &self, conn: &Connection, msg: <XxInputMethodV1 as Proxy>::Request<'a>, ) -> Result<(Message<ObjectId, BorrowedFd<'a>>, Option<(&'static Interface, u32)>), InvalidId>
impl Eq for XxInputMethodV1
Auto Trait Implementations§
impl Freeze for XxInputMethodV1
impl !RefUnwindSafe for XxInputMethodV1
impl Send for XxInputMethodV1
impl Sync for XxInputMethodV1
impl Unpin for XxInputMethodV1
impl UnsafeUnpin for XxInputMethodV1
impl !UnwindSafe for XxInputMethodV1
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.