Skip to main content

CuBackend

Trait CuBackend 

Source
pub trait CuBackend {
    // Required methods
    fn name(&self) -> &'static str;
    fn fb_size(&self) -> Result<(i32, i32), String>;
    fn key(&self, scancode: u32, pressed: bool);
    fn mouse_move(&self, x: f64, y: f64);
    fn button(&self, btn: CuButton, pressed: bool);
    fn scroll(&self, dx: f64, dy: f64);
    fn screenshot_png(&self, display: u32) -> Result<Vec<u8>, String>;
    fn cursor_pos(&self) -> Result<(f64, f64), String>;
    fn resolve_keysyms(&self, keysyms: &[u32]) -> Vec<(u32, u32)>;

    // Provided methods
    fn display_fb_size(&self, display: u32) -> Result<(i32, i32), String> { ... }
    fn with_transient_keysyms(
        &self,
        keysyms: &[u32],
        seq: &mut dyn FnMut(&HashMap<u32, u32>),
    ) { ... }
    fn altgr_keycode(&self) -> u32 { ... }
}
Expand description

The desktop-side primitives one Computer Use action decomposes into. Keycodes are X/xkb keycodes (evdev + 8) — the numbering both the smithay seat and XTEST consume — and coordinates are framebuffer/root pixels, already clamped by the action layer.

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn fb_size(&self) -> Result<(i32, i32), String>

Source

fn key(&self, scancode: u32, pressed: bool)

Source

fn mouse_move(&self, x: f64, y: f64)

Source

fn button(&self, btn: CuButton, pressed: bool)

Source

fn scroll(&self, dx: f64, dy: f64)

Source

fn screenshot_png(&self, display: u32) -> Result<Vec<u8>, String>

PNG of one display’s framebuffer; 0 = the primary. Unknown ids are an error.

Source

fn cursor_pos(&self) -> Result<(f64, f64), String>

Source

fn resolve_keysyms(&self, keysyms: &[u32]) -> Vec<(u32, u32)>

Resolve keysyms against the backend’s ACTIVE keymap: one (keycode, shift level) per input keysym, (0, 0) where the keymap cannot produce it. Level bit 0 = Shift, bit 1 = AltGr — the order xkb two/four-level key types use. Wayland resolves through the compositor’s keymap policy (overlay-binding what the base lacks); X11 through the server’s own GetKeyboardMapping.

Provided Methods§

Source

fn display_fb_size(&self, display: u32) -> Result<(i32, i32), String>

One display’s framebuffer size; 0 = the primary. Unknown ids are an error. The X11 backend serves only the root (display 0); Wayland resolves any live output id.

Source

fn with_transient_keysyms( &self, keysyms: &[u32], seq: &mut dyn FnMut(&HashMap<u32, u32>), )

Run seq with every keysym in keysyms (which resolve_keysyms could not place) made temporarily typeable, when the backend can arrange that; seq receives keysym -> keycode for the transient bindings (empty when none could be arranged, in which case those keysyms simply stay untypeable). Wayland’s resolve_keysyms already overlay-binds anything the base keymap lacks, so the default runs seq with no bindings; the X11 backend overrides this with a grab-atomic spare-keycode remap.

Source

fn altgr_keycode(&self) -> u32

Keycode synthesized around AltGr-level hits (level bit 1). The default is the pc105 right-Alt position the compositor’s seat keymap binds to ISO_Level3_Shift; the X11 backend overrides it with the level-3 modifier key found in the server’s keymap (0 = none, in which case resolve_keysyms reports no AltGr levels).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§