Skip to content

Commit

Permalink
fix: retry after a delay
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzhiyong committed Oct 7, 2024
1 parent 450337f commit 9c1a647
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll": "explicit"
},
"eslint.options": {
// "overrideConfigFile": "eslint.config.js"
Expand Down
14 changes: 13 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::error::Error;
use std::{error::Error, thread, time};
use x11rb::{
connection::Connection,
protocol::{
Expand Down Expand Up @@ -53,6 +53,18 @@ fn main() -> Result<(), Box<dyn Error>> {
} else {
connection.flush()?;
}
} else {
thread::sleep(time::Duration::from_millis(50));

let active_window = get_active_window(&connection, root, net_active_window)?;

if active_window != window_id {
if let Err(err) = connection.unmap_window(window_id) {
eprintln!("Error unmapping window: {:?}", err);
} else {
connection.flush()?;
}
}
}
}
Ok(_) => (),
Expand Down

0 comments on commit 9c1a647

Please sign in to comment.