I’m creating a simple tauri app where i want to capture user input globally, and show it in the application, something like a keystrokes visualizer.
I’m using rdev
crate for this.
the app sometimes runs fine, but after a while, when i press the ctrl
key, or alt
or just any special keys combination, my main monitor (laptop) goes totally black. and the second monitor stays working.
if i unplug the HDMI cable the main screen comes back to life.
then i can plug it back and continue working.
I’m on Ubutun 24.04.1 LTS
i checked /var/log/syslog
and here is the last couple of lines after the problem happend
Present-flip: queue flip during flip on CRTC 0 failed: Device or resource busy]
2024-09-25T07:24:18.284701+03:00 urboifox gnome-software[50089]: Failed to reload changed app filter: App filtering is globally disabled
2024-09-25T07:24:18.294084+03:00 urboifox /usr/libexec/gdm-x-session[49447]: (WW) modeset(0): Present-flip: queue flip during flip on CRTC 0 failed: Device or resource busy
the rest are literally the same couple of lines but repeated.
and here’s my main.rs
code
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use rdev::{listen, EventType};
use tauri::{self, Manager};
#[derive(Clone, serde::Serialize)]
struct Payload {
key: String,
}
fn main() {
tauri::Builder::default()
.setup(|app| {
let handle = app.handle();
std::thread::spawn(move || {
listen(move |event| match event.event_type {
EventType::KeyPress(key) => {
let key_name = format!("{:?}", key);
handle
.emit_all("key-down", Payload { key: key_name })
.unwrap()
}
EventType::KeyRelease(key) => {
let key_name = format!("{:?}", key);
handle
.emit_all("key-up", Payload { key: key_name })
.unwrap()
}
_ => {}
})
.unwrap();
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
I don’t know if it’s the rdev
crate, or making the app always top top..
It’s blurry and I don’t think i have the experience to figure this out myself.
thanks for help in advance.