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<()> {
322
 
322
 
323
     // Cooldown after control returns to prevent immediate bounce-back
323
     // Cooldown after control returns to prevent immediate bounce-back
324
     let mut last_control_return: Option<std::time::Instant> = None;
324
     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)
326
 
326
 
327
     // Connection storage: direction -> peer connection
327
     // Connection storage: direction -> peer connection
328
     let peers: Arc<RwLock<HashMap<Direction, network::FramedConnection>>> =
328
     let peers: Arc<RwLock<HashMap<Direction, network::FramedConnection>>> =
@@ -1023,6 +1023,9 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
1023
                                 );
1023
                                 );
1024
                                 if let Err(e) = transfer_manager.return_control().await {
1024
                                 if let Err(e) = transfer_manager.return_control().await {
1025
                                     tracing::warn!("Failed to return control: {}", e);
1025
                                     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());
1026
                                 }
1029
                                 }
1027
                                 continue;
1030
                                 continue;
1028
                             }
1031
                             }
@@ -1139,6 +1142,9 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
1139
                                                             );
1142
                                                             );
1140
                                                             if let Err(e) = transfer_manager.return_control().await {
1143
                                                             if let Err(e) = transfer_manager.return_control().await {
1141
                                                                 tracing::warn!("Failed to return control: {}", e);
1144
                                                                 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());
1142
                                                             }
1148
                                                             }
1143
                                                             edge_dwell_start = None;
1149
                                                             edge_dwell_start = None;
1144
                                                             continue;
1150
                                                             continue;
@@ -1753,6 +1759,8 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
1753
                                         tracing::warn!("Failed to return control: {}", e);
1759
                                         tracing::warn!("Failed to return control: {}", e);
1754
                                         IpcResponse::Error { message: format!("Return failed: {}", e) }
1760
                                         IpcResponse::Error { message: format!("Return failed: {}", e) }
1755
                                     } else {
1761
                                     } else {
1762
+                                        // Set cooldown to prevent immediate re-transfer (bounce-back)
1763
+                                        last_control_return = Some(std::time::Instant::now());
1756
                                         IpcResponse::Transferred { to_machine: neighbor_name.unwrap() }
1764
                                         IpcResponse::Transferred { to_machine: neighbor_name.unwrap() }
1757
                                     }
1765
                                     }
1758
                                 } else {
1766
                                 } else {