Skip to content

Commit 94d6112

Browse files
committed
Fix Keysym names for named Keysyms and test them agains xkbcommon
1 parent e94ff66 commit 94d6112

File tree

6 files changed

+2667
-2556
lines changed

6 files changed

+2667
-2556
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ jobs:
6161

6262
steps:
6363
- uses: actions/checkout@v4
64-
with:
65-
submodules: true
64+
- name: Install dependencies
65+
run: sudo apt-get install -y libxkbcommon-dev
6666
- name: Install Rust
6767
uses: dtolnay/rust-toolchain@master
6868
with:

.github/workflows/test.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SPDX-License-Identifier: MIT OR Apache-2.0 OR Zlib
2+
# Copyright 2022-2023 John Nunley
3+
#
4+
# Licensed under the Apache License, Version 2.0, the MIT License, and
5+
# the Zlib license ("the Licenses"), you may not use this file except in
6+
# compliance with one of the the Licenses, at your option. You may obtain
7+
# a copy of the Licenses at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
# http://opensource.org/licenses/MIT
11+
# http://opensource.org/licenses/Zlib
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the Licenses is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the Licenses for the specific language governing permissions and
17+
# limitations under the Licenses.
18+
19+
name: Test
20+
21+
permissions:
22+
contents: read
23+
on:
24+
push:
25+
branches:
26+
- master
27+
pull_request:
28+
workflow_dispatch:
29+
30+
env:
31+
RUSTFLAGS: -Dwarnings
32+
CARGO_TERM_COLOR: always
33+
34+
jobs:
35+
test:
36+
runs-on: ubuntu-latest
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
rust:
41+
- stable
42+
- beta
43+
- nightly
44+
- 1.58.1
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Install dependencies
49+
run: |
50+
sudo apt-get update -q -y
51+
sudo apt-get upgrade -y
52+
sudo apt-get install -y libxkbcommon-dev
53+
- name: Install Rust
54+
uses: dtolnay/rust-toolchain@master
55+
with:
56+
toolchain: ${{ matrix.rust }}
57+
components: rustfmt, clippy
58+
- uses: Swatinem/rust-cache@v2
59+
- name: Run the tests
60+
run: cargo test -- --include-ignored
61+

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ 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
16+
rayon = "1.8.0" # Used for testing
1517

1618
[workspace]
1719
members = [

keysym-generator/src/main.rs

Lines changed: 3 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
}

0 commit comments

Comments
 (0)