Using global keyboard listener subscription with rdev::grab, I noticed that if I launch another instance of the application, the first application will intercept two event, instead of one. Instead if only one instance is running everything goes fine, just one event is intercepted. why?
let (sender, mut receiver) = tokio::sync::mpsc::channel(20);
std::thread::spawn(move || {
rdev::grab(move |event| {
sender.blocking_send(event.clone()).unwrap_or_default();
Some(event)
}).unwrap_or_default();
});
tokio::spawn(async move {
loop {
if let Some(event) = receiver.recv().await {
println!("{:?}", event);
}
}
});