Skip to content

Commit

Permalink
stop deadlocking in raw_latin_sym_or_raw_current_sym
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rch3n1ng committed Sep 20, 2024
1 parent 2c0076e commit 1d50fd8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/input/keyboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,14 @@ impl<'a> KeysymHandle<'a> {
pub fn raw_latin_sym_or_raw_current_sym(&self) -> Option<Keysym> {
let xkb = self.xkb.lock().unwrap();
let effective_layout = Layout(xkb.state.key_get_layout(self.keycode));

// don't call `self.raw_syms()` to avoid a deadlock
// and an unnecessary allocation into a Vec
let raw_syms =
xkb.keymap
.key_get_syms_by_level(self.keycode, xkb.state.key_get_layout(self.keycode), 0);
// NOTE: There's always a keysym in the current layout given that we have modified_sym.
let base_sym = *self.raw_syms().first()?;
let base_sym = *raw_syms.first()?;

// If the character is ascii or non-printable, return it.
if base_sym.key_char().map(|ch| ch.is_ascii()).unwrap_or(true) {
Expand Down

0 comments on commit 1d50fd8

Please sign in to comment.