Skip to content

Commit

Permalink
x11: send end of previous active window
Browse files Browse the repository at this point in the history
  • Loading branch information
powellnorma committed Oct 6, 2024
1 parent bd780e1 commit a20f09e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 10 additions & 10 deletions watchers/src/report_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ impl ReportClient {
Fut: Future<Output = Result<T, E>>,
E: std::error::Error + Send + Sync + 'static,
{
for (attempt, &secs) in [1, 2].iter().enumerate() {
for (attempt, secs) in [0.01, 0.1, 1., 2.].iter().enumerate() {
match f().await {
Ok(val) => return Ok(val),
Err(e)
if e.to_string()
.contains("tcp connect error: Connection refused") =>
{
warn!("Failed to connect on attempt #{attempt}, retrying: {}", e);

tokio::time::sleep(tokio::time::Duration::from_secs(secs)).await;
Ok(val) => {
if attempt > 0 {
debug!("OK at attempt #{}", attempt + 1);
}
return Ok(val);
}
Err(e) => {
warn!("Failed on attempt #{}, retrying in {:.1}s: {}", attempt + 1, secs, e);
tokio::time::sleep(tokio::time::Duration::from_secs_f64(*secs)).await;
}
Err(e) => return Err(e),
}
}

Expand Down
4 changes: 4 additions & 0 deletions watchers/src/watchers/x11_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ impl WindowWatcher {
r#"Changed window app_id="{}", title="{}", wm_instance="{}""#,
app_id, title, wm_instance
);
client
.send_active_window_with_instance(&self.last_app_id, &self.last_title, Some(&self.last_wm_instance))
.await
.with_context(|| "Failed to send heartbeat for previous window")?;
self.last_app_id = app_id.clone();
self.last_title = title.clone();
self.last_wm_instance = wm_instance.clone();
Expand Down

0 comments on commit a20f09e

Please sign in to comment.