pub struct Repeat { /* private fields */ }Expand description
Which key is repeating, and what each event does to that.
Split out from the timer so it can be reasoned about, and tested, without one. libinput deliberately does not auto-repeat – it reports what the hardware did, and the repeat rate is a user preference the compositor owns – so this is the piece that has to exist somewhere.
Implementations§
Source§impl Repeat
impl Repeat
Sourcepub const fn new(config: RepeatConfig) -> Self
pub const fn new(config: RepeatConfig) -> Self
Start with nothing held.
Sourcepub const fn config(&self) -> RepeatConfig
pub const fn config(&self) -> RepeatConfig
The delay and interval this was built with.
Sourcepub fn on_key(&mut self, event: &KeyEvent, repeats: bool) -> Timer
pub fn on_key(&mut self, event: &KeyEvent, repeats: bool) -> Timer
Feed a real key event.
repeats is the keymap’s answer for this key –
Keyboard::should_repeat. It is
passed in rather than looked up so this stays usable without a keymap,
and so a caller with its own policy can impose it.
Synthesized events are ignored: feeding this its own output back would re-arm the delay on every tick and the key would never repeat.
Sourcepub fn cancel(&mut self) -> Timer
pub fn cancel(&mut self) -> Timer
Stop repeating.
For a session pause, or any point where the held-key state has stopped being trustworthy.
Sourcepub fn synthesize(
&self,
expirations: u64,
time_ms: u32,
out: &mut Vec<KeyEvent>,
) -> u64
pub fn synthesize( &self, expirations: u64, time_ms: u32, out: &mut Vec<KeyEvent>, ) -> u64
Turn a batch of timer expirations into events to deliver.
Returns how many were dropped to the burst cap, which is worth saying out loud rather than swallowing: a nonzero answer means the loop is not keeping up.
The events carry only the key. A caller that wants sym and utf8
runs them through Keyboard::resolve,
which reads against the modifiers held now – so pressing Shift
partway through a held key changes what the next repeat types.