X11 key release order problems
Closed this issue · 1 comments
RastislavKish commented
I'm not sure if this is problem of this crate or X11, but it seems the order in which keys of a shortcut are released does matter right now. Here is a simple snippet detecting Alt+C hotkey and printing when it's pressed and released.
Reproduction steps
- Run the code snippet below
- Press the following key sequences:
- Alt down, C down, C up, Alt up
- Alt down, C down, Alt up, C up
- Alt down, C down, Alt up, C up
- Alt down, C down, C up, Alt up
Expected output
Pressed
Released
Pressed
Released
Pressed
Released
Pressed
Released
Actual output
Pressed
Released
Pressed
Released
There are basically two problems here, pressing sequence 2 prints "Pressed" but not "Released", repeating the same sequence (sequence 3) won't do anything (because the internal hotkey state is likely stuck), and sequence 4 won't produce the pressed event but only the released event.
Code snippet
use global_hotkey::{
GlobalHotKeyManager, GlobalHotKeyEvent,
hotkey::{HotKey, Modifiers, Code}
};
fn main() {
let manager=GlobalHotKeyManager::new().unwrap();
let hotkey=HotKey::new(Some(Modifiers::ALT), Code::KeyC, );
manager.register(hotkey).unwrap();
for event in GlobalHotKeyEvent::receiver() {
println!("{:?}", event.state());
}
}
Environment
global-hotkey 0.4.0, Ubuntu Mate 22.04 64-bit
amrbashir commented
This is now fixed and released in 4.1
, if you find any other quirks, please let me know and thanks for your feedback