Skip to content

Commit ca7d348

Browse files
committed
x11: send end of previous active window
1 parent bd780e1 commit ca7d348

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

watchers/src/report_client.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,16 @@ impl ReportClient {
4141
Fut: Future<Output = Result<T, E>>,
4242
E: std::error::Error + Send + Sync + 'static,
4343
{
44-
for (attempt, &secs) in [1, 2].iter().enumerate() {
44+
for (attempt, secs) in [0.01, 0.1, 1., 2.].iter().enumerate() {
4545
match f().await {
46-
Ok(val) => return Ok(val),
47-
Err(e)
48-
if e.to_string()
49-
.contains("tcp connect error: Connection refused") =>
50-
{
51-
warn!("Failed to connect on attempt #{attempt}, retrying: {}", e);
52-
53-
tokio::time::sleep(tokio::time::Duration::from_secs(secs)).await;
46+
Ok(val) => {
47+
info!("OK at attempt #{}", attempt + 1);
48+
return Ok(val);
49+
}
50+
Err(e) => {
51+
warn!("Failed on attempt #{}, retrying in {:.1}s: {}", attempt + 1, secs, e);
52+
tokio::time::sleep(tokio::time::Duration::from_secs_f64(*secs)).await;
5453
}
55-
Err(e) => return Err(e),
5654
}
5755
}
5856

watchers/src/watchers/x11_window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ impl WindowWatcher {
3232
r#"Changed window app_id="{}", title="{}", wm_instance="{}""#,
3333
app_id, title, wm_instance
3434
);
35+
client
36+
.send_active_window_with_instance(&self.last_app_id, &self.last_title, Some(&self.last_wm_instance))
37+
.await
38+
.with_context(|| "Failed to send heartbeat for previous window")?;
3539
self.last_app_id = app_id.clone();
3640
self.last_title = title.clone();
3741
self.last_wm_instance = wm_instance.clone();

0 commit comments

Comments
 (0)