mirror of
https://github.com/2e3s/awatcher.git
synced 2025-06-06 19:45:30 +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>>,
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user