Skip to content

Commit

Permalink
Fix Keysym names for named Keysyms and test them agains xkbcommon
Browse files Browse the repository at this point in the history
  • Loading branch information
pentamassiv committed Oct 23, 2023
1 parent b705222 commit 1684b95
Show file tree
Hide file tree
Showing 5 changed files with 2,652 additions and 2,554 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: |
sudo apt-get update -q -y && sudo apt-get upgrade -y
sudo apt-get install -y libxkbcommon-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rust-version = "1.58.1"
[dev-dependencies]
bytemuck = "1.12.3"
x11rb = "0.12.0"
xkbcommon = "0.7.0" # Used for testing

[workspace]
members = [
Expand Down
14 changes: 12 additions & 2 deletions keysym-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub mod key {{
#[allow(unreachable_patterns)]
pub(crate) const fn name(keysym: Keysym) -> Option<&'static str> {
match keysym {
Keysym::NoSymbol => Some(\"XK_NoSymbol\"),\n"
Keysym::NoSymbol => Some(\"NoSymbol\"),\n"
.to_string();

// we're looking for lines of the following form:
Expand Down Expand Up @@ -210,7 +210,8 @@ pub(crate) const fn name(keysym: Keysym) -> Option<&'static str> {
writeln!(
keysym_dump,
" Keysym::{} => Some(\"{}\"),",
&keysym_name, &name
&keysym_name,
&name.replace("XK_", "")
)
.unwrap();
}
Expand All @@ -226,6 +227,15 @@ pub(crate) const fn name(keysym: Keysym) -> Option<&'static str> {
// Write out the keysym dump.
keysym_dump.push_str(
"
unicode_sym if unicode_sym.is_unnamed_unicode_key() => {
/*
TODO: Fix the names of keysyms representing unnamed unicodes. This is the equivalent code from xkbcommon
Taken from https://github.com/xkbcommon/libxkbcommon/blob/6073565903488cb5b9a8d37fdc4a7c2f9d7ad04d/src/keysym.c#L84:
const int width = (ks & 0xff0000UL) ? 8 : 4;
return snprintf(buffer, size, \"U%0*lX\", width, ks & 0xffffffUL);
*/
None
}
_ => None,
}
}",
Expand Down
Loading

0 comments on commit 1684b95

Please sign in to comment.