Skip to main content

KeymapPolicy

Struct KeymapPolicy 

Source
pub struct KeymapPolicy { /* private fields */ }
Expand description

Seat keymap state: the base text, its reverse keysym map, and the overlay slots.

Implementations§

Source§

impl KeymapPolicy

Source

pub fn empty() -> Self

Placeholder policy before the seat keymap is known; rebuild_base fills it in.

Source

pub fn with_overlay_range(first: u32, last: u32) -> Self

Policy with a custom overlay keycode range (inclusive, xkb numbering). The seat uses empty()’s above-255 range (pure-Wayland clients resolve it fine); the virtual-keyboard client typing into a nested compositor uses a sub-256 range so XWayland apps under that compositor stay reachable.

Source

pub fn rebuild_base(&mut self, base_text: String) -> bool

Replace the base keymap text and rebuild the reverse map. Overlay assignments are retained (same keycodes), so keycodes already handed out stay valid across the swap. Returns whether base_text compiled. A string that does not is rejected without touching any state, so the caller needs no separate validation pass — compiling a keymap is the expensive part of installing one and doing it twice is pure cost.

Source

pub fn has_base(&self) -> bool

True once a base keymap has been installed.

Source

pub fn resolve(&self, keysym: u32) -> Option<(u32, u32)>

Resolve keysym without binding: base first, then an existing overlay slot.

Source

pub fn resolves_plain(&self, keysym: u32) -> bool

True when keysym resolves at level 0 (base or overlay) — i.e. typable without synthetic modifiers.

Source

pub fn bind_many( &mut self, keysyms: &[u32], pressed: &HashSet<u32>, ) -> (Vec<(u32, u32)>, bool)

Resolve every keysym, overlay-binding the unresolvable ones. Returns one (keycode, level) per input keysym ((0, 0) when it cannot be bound) plus whether the keymap changed and must be re-applied — at most ONE swap per call, however many new keysyms were bound. Slots whose keycode is in pressed are never recycled.

Source

pub fn bind_many_plain( &mut self, keysyms: &[u32], pressed: &HashSet<u32>, ) -> (Vec<u32>, bool)

Like bind_many but only accepts level-0 resolutions: a keysym reachable in the base solely behind a modifier (e.g. A behind Shift) is overlay-bound instead, so the caller can inject it without synthesizing modifiers. Returns keycodes (0 = unbindable).

Source

pub fn set_manual_overlay(&mut self, binds: &[(u32, u32)])

Replace the externally-owned overlay binds (keycode -> keysym). selkies resolves its own keysyms and re-sends the whole set on every change, so a full replace is the contract. They then ride along in every keymap_text, so a base-layout swap or a computer-use policy bind re-applies them instead of dropping them.

Source

pub fn keymap_text(&self) -> String

The full seat keymap: the base text with every occupied policy overlay slot and every externally-owned bind spliced into the xkb_keycodes and xkb_symbols sections (and maximum raised to cover them). With neither, the base text verbatim. A manual bind sharing a keycode with a policy slot is emitted last, so its symbol wins.

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> Ungil for T
where T: Send,

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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