mirror of
https://github.com/2e3s/awatcher.git
synced 2025-06-07 12:05:49 +00:00
x11: send end of previous active window
This commit is contained in:
parent
bd780e1cbb
commit
a20f09ef58
@ -41,18 +41,18 @@ impl ReportClient {
|
|||||||
Fut: Future<Output = Result<T, E>>,
|
Fut: Future<Output = Result<T, E>>,
|
||||||
E: std::error::Error + Send + Sync + 'static,
|
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 {
|
match f().await {
|
||||||
Ok(val) => return Ok(val),
|
Ok(val) => {
|
||||||
Err(e)
|
if attempt > 0 {
|
||||||
if e.to_string()
|
debug!("OK at attempt #{}", attempt + 1);
|
||||||
.contains("tcp connect error: Connection refused") =>
|
}
|
||||||
{
|
return Ok(val);
|
||||||
warn!("Failed to connect on attempt #{attempt}, retrying: {}", e);
|
}
|
||||||
|
Err(e) => {
|
||||||
tokio::time::sleep(tokio::time::Duration::from_secs(secs)).await;
|
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),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,10 @@ impl WindowWatcher {
|
|||||||
r#"Changed window app_id="{}", title="{}", wm_instance="{}""#,
|
r#"Changed window app_id="{}", title="{}", wm_instance="{}""#,
|
||||||
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_app_id = app_id.clone();
|
||||||
self.last_title = title.clone();
|
self.last_title = title.clone();
|
||||||
self.last_wm_instance = wm_instance.clone();
|
self.last_wm_instance = wm_instance.clone();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user