tenseleyflow/hyprkvm / 60df824

Browse files

fix: increase cooldown and set on all return paths to prevent bounce-back

- Increase cooldown from 500ms to 1000ms
- Set cooldown after barrier-triggered returns
- Set cooldown after cursor-edge returns
- Set cooldown after keyboard-initiated returns
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
60df824e3d22674e4b4654e023ddd1b09a2ca2c0
Parents
ca11bc3
Tree
7b1d24d

1 changed file

StatusFile+-
M hyprkvm-daemon/src/main.rs 9 1
hyprkvm-daemon/src/main.rsmodified
@@ -322,7 +322,7 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
322322
 
323323
     // Cooldown after control returns to prevent immediate bounce-back
324324
     let mut last_control_return: Option<std::time::Instant> = None;
325
-    const CONTROL_RETURN_COOLDOWN_MS: u64 = 500; // 500ms cooldown after control returns
325
+    const CONTROL_RETURN_COOLDOWN_MS: u64 = 1000; // 1000ms cooldown after control returns (prevents bounce-back)
326326
 
327327
     // Connection storage: direction -> peer connection
328328
     let peers: Arc<RwLock<HashMap<Direction, network::FramedConnection>>> =
@@ -1023,6 +1023,9 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
10231023
                                 );
10241024
                                 if let Err(e) = transfer_manager.return_control().await {
10251025
                                     tracing::warn!("Failed to return control: {}", e);
1026
+                                } else {
1027
+                                    // Set cooldown to prevent immediate re-transfer
1028
+                                    last_control_return = Some(std::time::Instant::now());
10261029
                                 }
10271030
                                 continue;
10281031
                             }
@@ -1139,6 +1142,9 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
11391142
                                                             );
11401143
                                                             if let Err(e) = transfer_manager.return_control().await {
11411144
                                                                 tracing::warn!("Failed to return control: {}", e);
1145
+                                                            } else {
1146
+                                                                // Set cooldown to prevent immediate re-transfer
1147
+                                                                last_control_return = Some(std::time::Instant::now());
11421148
                                                             }
11431149
                                                             edge_dwell_start = None;
11441150
                                                             continue;
@@ -1753,6 +1759,8 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
17531759
                                         tracing::warn!("Failed to return control: {}", e);
17541760
                                         IpcResponse::Error { message: format!("Return failed: {}", e) }
17551761
                                     } else {
1762
+                                        // Set cooldown to prevent immediate re-transfer (bounce-back)
1763
+                                        last_control_return = Some(std::time::Instant::now());
17561764
                                         IpcResponse::Transferred { to_machine: neighbor_name.unwrap() }
17571765
                                     }
17581766
                                 } else {