kbvm: identify keymaps by their hash
This commit is contained in:
parent
11c10fde70
commit
6bea5a072c
3 changed files with 25 additions and 7 deletions
20
Cargo.lock
generated
20
Cargo.lock
generated
|
|
@ -173,6 +173,19 @@ version = "2.8.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
|
||||
[[package]]
|
||||
name = "blake3"
|
||||
version = "1.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"arrayvec",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"constant_time_eq",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "1.11.3"
|
||||
|
|
@ -295,6 +308,12 @@ version = "1.0.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
|
|
@ -587,6 +606,7 @@ dependencies = [
|
|||
"ash",
|
||||
"backtrace",
|
||||
"bincode",
|
||||
"blake3",
|
||||
"bstr",
|
||||
"byteorder",
|
||||
"cc",
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ regex = "1.11.1"
|
|||
cfg-if = "1.0.0"
|
||||
opera = "1.0.1"
|
||||
with_builtin_macros = "0.1.0"
|
||||
blake3 = "1.8.2"
|
||||
|
||||
[build-dependencies]
|
||||
repc = "0.1.1"
|
||||
|
|
|
|||
11
src/kbvm.rs
11
src/kbvm.rs
|
|
@ -33,21 +33,18 @@ pub enum KbvmError {
|
|||
|
||||
pub struct KbvmContext {
|
||||
pub ctx: xkb::Context,
|
||||
pub ids: KbvmMapIds,
|
||||
}
|
||||
|
||||
impl Default for KbvmContext {
|
||||
fn default() -> Self {
|
||||
let mut ctx = xkb::Context::builder();
|
||||
ctx.enable_environment(true);
|
||||
Self {
|
||||
ctx: ctx.build(),
|
||||
ids: Default::default(),
|
||||
}
|
||||
Self { ctx: ctx.build() }
|
||||
}
|
||||
}
|
||||
|
||||
linear_ids!(KbvmMapIds, KbvmMapId, u64);
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct KbvmMapId([u8; 32]);
|
||||
|
||||
pub struct KbvmMap {
|
||||
pub id: KbvmMapId,
|
||||
|
|
@ -90,7 +87,7 @@ impl KbvmContext {
|
|||
.map_err(KbvmError::CouldNotParseKeymap)?;
|
||||
let builder = map.to_builder();
|
||||
Ok(Rc::new(KbvmMap {
|
||||
id: self.ids.next(),
|
||||
id: KbvmMapId(*blake3::hash(keymap).as_bytes()),
|
||||
state_machine: builder.build_state_machine(),
|
||||
map: create_keymap_memfd(&map, false).map_err(KbvmError::KeymapMemfd)?,
|
||||
xwayland_map: create_keymap_memfd(&map, true).map_err(KbvmError::KeymapMemfd)?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue