Module input_method

Source
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§

InputMethodHandle
Handle to an input method instance
InputMethodKeyboardGrab
Handle to an input method instance
InputMethodKeyboardUserData
User data of ZwpInputKeyboardGrabV2 object
InputMethodManagerGlobalData
Data associated with a InputMethodManager global.
InputMethodManagerState
State of wp misc input method protocol
InputMethodPopupSurfaceUserData
User data of ZwpInputPopupSurfaceV2 object
InputMethodUserData
User data of ZwpInputMethodV2 object
PopupParent
Parent surface and location for the IME popup.
PopupSurface
A handle to an input method popup surface

Constants§

INPUT_POPUP_SURFACE_ROLE
The role of the input method popup.

Traits§

InputMethodHandler
Adds input method popup to compositor state
InputMethodSeat
Extends Seat with input method functionality