Skip to content

Commit bb78a4e

Browse files
committed
Fix Keysym names for named Keysyms and test them agains xkbcommon
1 parent b705222 commit bb78a4e

File tree

5 files changed

+2652
-2554
lines changed

5 files changed

+2652
-2554
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ jobs:
4747
- uses: actions/checkout@v4
4848
with:
4949
submodules: true
50+
- name: Install dependencies
51+
run: |
52+
sudo apt-get update -q -y && sudo apt-get upgrade -y
53+
sudo apt-get install -y libxkbcommon-dev
5054
- name: Install Rust
5155
uses: dtolnay/rust-toolchain@master
5256
with:

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ rust-version = "1.58.1"
1212
[dev-dependencies]
1313
bytemuck = "1.12.3"
1414
x11rb = "0.12.0"
15+
xkbcommon = "0.7.0" # Used for testing
1516

1617
[workspace]
1718
members = [

keysym-generator/src/main.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub mod key {{
103103
#[allow(unreachable_patterns)]
104104
pub(crate) const fn name(keysym: Keysym) -> Option<&'static str> {
105105
match keysym {
106-
Keysym::NoSymbol => Some(\"XK_NoSymbol\"),\n"
106+
Keysym::NoSymbol => Some(\"NoSymbol\"),\n"
107107
.to_string();
108108

109109
// we're looking for lines of the following form:
@@ -210,7 +210,8 @@ pub(crate) const fn name(keysym: Keysym) -> Option<&'static str> {
210210
writeln!(
211211
keysym_dump,
212212
" Keysym::{} => Some(\"{}\"),",
213-
&keysym_name, &name
213+
&keysym_name,
214+
&name.replace("XK_", "")
214215
)
215216
.unwrap();
216217
}
@@ -226,6 +227,15 @@ pub(crate) const fn name(keysym: Keysym) -> Option<&'static str> {
226227
// Write out the keysym dump.
227228
keysym_dump.push_str(
228229
"
230+
unicode_sym if unicode_sym.is_unnamed_unicode_key() => {
231+
/*
232+
TODO: Fix the names of keysyms representing unnamed unicodes. This is the equivalent code from xkbcommon
233+
Taken from https://github.com/xkbcommon/libxkbcommon/blob/6073565903488cb5b9a8d37fdc4a7c2f9d7ad04d/src/keysym.c#L84:
234+
const int width = (ks & 0xff0000UL) ? 8 : 4;
235+
return snprintf(buffer, size, \"U%0*lX\", width, ks & 0xffffffUL);
236+
*/
237+
None
238+
}
229239
_ => None,
230240
}
231241
}",

0 commit comments

Comments
 (0)