Skip to main content

lefthk_core/worker/context/
chord.rs

1use crate::{config::Keybind, worker::Worker};
2
3#[derive(Debug, Clone, PartialEq, Eq, Default)]
4pub struct Chord {
5    pub keybinds: Option<Vec<Keybind>>,
6    pub elapsed: bool,
7}
8
9impl Chord {
10    #[must_use]
11    pub fn new() -> Self {
12        Self {
13            keybinds: None,
14            elapsed: false,
15        }
16    }
17}
18
19impl Worker {
20    pub fn evaluate_chord(&mut self) {
21        if self.chord_ctx.elapsed {
22            self.xwrap.grab_keys(&self.keybinds);
23            self.chord_ctx.keybinds = None;
24            self.chord_ctx.elapsed = false;
25        }
26    }
27}