Available on crate feature
wayland_frontend
only.Expand description
Utilities for input method support
This module provides you with utilities to handle input methods, it must be used in conjunction with the text input module to work.
use smithay::{
delegate_seat, delegate_input_method_manager, delegate_text_input_manager,
};
use smithay::input::{Seat, SeatState, SeatHandler, pointer::CursorImageStatus};
use smithay::wayland::input_method::{InputMethodManagerState, InputMethodHandler, PopupSurface};
use smithay::wayland::text_input::TextInputManagerState;
use smithay::reexports::wayland_server::{Display, protocol::wl_surface::WlSurface};
use smithay::utils::{Rectangle, Logical};
delegate_seat!(State);
impl InputMethodHandler for State {
fn new_popup(&mut self, surface: PopupSurface) {}
fn dismiss_popup(&mut self, surface: PopupSurface) {}
fn popup_repositioned(&mut self, surface: PopupSurface) {}
fn parent_geometry(&self, parent: &WlSurface) -> Rectangle<i32, Logical> {
Rectangle::default()
}
}
// Delegate input method handling for State to InputMethodManagerState.
delegate_input_method_manager!(State);
delegate_text_input_manager!(State);
let mut seat_state = SeatState::<State>::new();
// implement the required traits
impl SeatHandler for State {
type KeyboardFocus = WlSurface;
type PointerFocus = WlSurface;
type TouchFocus = WlSurface;
fn seat_state(&mut self) -> &mut SeatState<Self> {
&mut self.seat_state
}
fn focus_changed(&mut self, seat: &Seat<Self>, focused: Option<&WlSurface>) { unimplemented!() }
fn cursor_image(&mut self, seat: &Seat<Self>, image: CursorImageStatus) { unimplemented!() }
}
// Add the seat state to your state and create manager globals
InputMethodManagerState::new::<State, _>(&display_handle, |_client| true);
// Add text input capabilities, needed for the input method to work
TextInputManagerState::new::<State>(&display_handle);
Structs§
- Input
Method Handle - Handle to an input method instance
- Input
Method Keyboard Grab - Handle to an input method instance
- Input
Method Keyboard User Data - User data of ZwpInputKeyboardGrabV2 object
- Input
Method Manager Global Data - Data associated with a InputMethodManager global.
- Input
Method Manager State - State of wp misc input method protocol
- Input
Method Popup Surface User Data - User data of ZwpInputPopupSurfaceV2 object
- Input
Method User Data - User data of ZwpInputMethodV2 object
- Popup
Parent - Parent surface and location for the IME popup.
- Popup
Surface - A handle to an input method popup surface
Constants§
- INPUT_
POPUP_ SURFACE_ ROLE - The role of the input method popup.
Traits§
- Input
Method Handler - Adds input method popup to compositor state
- Input
Method Seat - Extends Seat with input method functionality