Skip to content

Commit

Permalink
fix: move repeat rate to after the grab
Browse files Browse the repository at this point in the history
  • Loading branch information
jtroo committed Jul 2, 2023
1 parent bf24e14 commit f71d4e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ build_release_windows output_dir:
sha256sums output_dir:
rm -f {{output_dir}}/sha256sums
cd {{output_dir}}; sha256sum * > sha256sums

test:
cargo test --verbose -p kanata -p kanata-parser -p kanata-keyberon -- --nocapture
cargo clippy --all

fmt:
cargo fmt --all
4 changes: 4 additions & 0 deletions src/kanata/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ impl Kanata {
bail!("failed to open keyboard device(s): {}", e)
}
};

// In some environments, this needs to be done after the input device grab otherwise it
// does not work on kanata startup.
Kanata::set_repeat_rate(&k.defcfg_items)?;
drop(k);

loop {
Expand Down
6 changes: 5 additions & 1 deletion src/kanata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ pub struct Kanata {
log_layer_changes: bool,
/// Tracks the caps-word state. Is Some(...) if caps-word is active and None otherwise.
pub caps_word: Option<CapsWordState>,
/// Config items from `defcfg`.
#[cfg(target_os = "linux")]
pub defcfg_items: HashMap<String, String>,
}

pub struct ScrollState {
Expand Down Expand Up @@ -298,7 +301,6 @@ impl Kanata {
.get("linux-dev-names-exclude")
.cloned()
.map(|paths| parse_colon_separated_text(&paths));
Kanata::set_repeat_rate(&cfg.items)?;

#[cfg(target_os = "windows")]
unsafe {
Expand Down Expand Up @@ -389,6 +391,8 @@ impl Kanata {
dynamic_macros: Default::default(),
log_layer_changes,
caps_word: None,
#[cfg(target_os = "linux")]
defcfg_items: cfg.items,
})
}

Expand Down

0 comments on commit f71d4e1

Please sign in to comment.