diff --git a/src/hotkey.rs b/src/hotkey.rs index 57d665e..7e92cff 100644 --- a/src/hotkey.rs +++ b/src/hotkey.rs @@ -55,7 +55,7 @@ pub struct HotKey { /// The hotkey key. pub key: Code, /// The hotkey id. - pub id: u32, + pub id: u64, } #[cfg(feature = "serde")] @@ -92,20 +92,13 @@ impl HotKey { } let mut hotkey = Self { mods, key, id: 0 }; - hotkey.id = hotkey.generate_hash(); + hotkey.id = (mods.bits() as u64) << 32 | key as u64; hotkey } - fn generate_hash(&self) -> u32 { - let hotkey_str = self.into_string(); - let mut hasher = std::collections::hash_map::DefaultHasher::new(); - hotkey_str.hash(&mut hasher); - std::hash::Hasher::finish(&hasher) as u32 - } - /// Returns the id associated with this hotKey /// which is a hash of the string represention of modifiers and key within this hotKey. - pub fn id(&self) -> u32 { + pub fn id(&self) -> u64 { self.id } @@ -476,4 +469,4 @@ fn test_equality() { && h4.id() == h5.id() && h5.id() != h6.id() ); -} +} \ No newline at end of file