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
impl KeymapPolicy
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Placeholder policy before the seat keymap is known; rebuild_base fills it in.
Sourcepub fn with_overlay_range(first: u32, last: u32) -> Self
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.
Sourcepub fn rebuild_base(&mut self, base_text: String) -> bool
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.
Sourcepub fn resolve(&self, keysym: u32) -> Option<(u32, u32)>
pub fn resolve(&self, keysym: u32) -> Option<(u32, u32)>
Resolve keysym without binding: base first, then an existing overlay slot.
Sourcepub fn resolves_plain(&self, keysym: u32) -> bool
pub fn resolves_plain(&self, keysym: u32) -> bool
True when keysym resolves at level 0 (base or overlay) — i.e. typable without
synthetic modifiers.
Sourcepub fn bind_many(
&mut self,
keysyms: &[u32],
pressed: &HashSet<u32>,
) -> (Vec<(u32, u32)>, bool)
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.
Sourcepub fn bind_many_plain(
&mut self,
keysyms: &[u32],
pressed: &HashSet<u32>,
) -> (Vec<u32>, bool)
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).
Sourcepub fn set_manual_overlay(&mut self, binds: &[(u32, u32)])
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.
Sourcepub fn keymap_text(&self) -> String
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§
impl Freeze for KeymapPolicy
impl RefUnwindSafe for KeymapPolicy
impl Send for KeymapPolicy
impl Sync for KeymapPolicy
impl Unpin for KeymapPolicy
impl UnsafeUnpin for KeymapPolicy
impl UnwindSafe for KeymapPolicy
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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