Skip to content

Commit

Permalink
[x11][xkbcommon] Fix keysym translation using official libxkbcommon i…
Browse files Browse the repository at this point in the history
…nstead of bespoke implementation. This should fix the enter to carriage return conversion among other things
  • Loading branch information
eloraiby authored and not-fl3 committed Jun 21, 2024
1 parent c9adf59 commit da6bc06
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 929 deletions.
5 changes: 4 additions & 1 deletion src/native/linux_x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::collections::HashMap;

pub struct X11Display {
libx11: LibX11,
libxkbcommon: LibXkbCommon,
libxi: xi_input::LibXi,
display: *mut Display,
root: Window,
Expand Down Expand Up @@ -47,7 +48,7 @@ impl X11Display {
&mut keysym,
std::ptr::null_mut(),
);
let chr = keycodes::keysym_to_unicode(keysym);
let chr = keycodes::keysym_to_unicode(&mut self.libxkbcommon, keysym);
if chr > 0 {
if let Some(chr) = std::char::from_u32(chr as u32) {
event_handler.char_event(chr, mods, repeat);
Expand Down Expand Up @@ -547,6 +548,7 @@ where
{
unsafe {
let mut libx11 = LibX11::try_load()?;
let libxkbcommon = LibXkbCommon::try_load()?;
let libxi = xi_input::LibXi::try_load()?;

(libx11.XInitThreads)();
Expand Down Expand Up @@ -581,6 +583,7 @@ where
root: x11_root,
window: 0,
libx11,
libxkbcommon,
libxi,
repeated_keycodes: [false; 256],
cursor_cache: HashMap::new(),
Expand Down
Loading

0 comments on commit da6bc06

Please sign in to comment.