tenseleyflow/hyprkvm / a754f1a

Browse files

fix: add cooldown check to keyboard navigation

Keyboard-initiated transfers (IPC Move) now check the control return
cooldown, preventing bounce-back loops when navigating via keybinds.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
a754f1aa73e0544d3febdc1016d19f8563c63c01
Parents
60df824
Tree
0570056

1 changed file

StatusFile+-
M hyprkvm-daemon/src/main.rs 20 2
hyprkvm-daemon/src/main.rsmodified
@@ -1789,8 +1789,26 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
17891789
                                     }
17901790
                                 }
17911791
                             } else {
1792
-                                // Not in ReceivedControl - check barrier
1793
-                                if barrier_enabled.load(std::sync::atomic::Ordering::SeqCst) {
1792
+                                // Not in ReceivedControl - check cooldown first
1793
+                                let in_cooldown = if let Some(last_return) = last_control_return {
1794
+                                    last_return.elapsed().as_millis() < CONTROL_RETURN_COOLDOWN_MS as u128
1795
+                                } else {
1796
+                                    false
1797
+                                };
1798
+
1799
+                                if in_cooldown {
1800
+                                    tracing::info!("IPC Move {:?}: in cooldown, doing local movefocus", direction);
1801
+                                    let hypr_dir = match direction {
1802
+                                        Direction::Left => "l",
1803
+                                        Direction::Right => "r",
1804
+                                        Direction::Up => "u",
1805
+                                        Direction::Down => "d",
1806
+                                    };
1807
+                                    match hypr_client.dispatch("movefocus", hypr_dir).await {
1808
+                                        Ok(_) => IpcResponse::Ok { message: "movefocus (cooldown)".to_string() },
1809
+                                        Err(e) => IpcResponse::Error { message: format!("movefocus failed: {}", e) },
1810
+                                    }
1811
+                                } else if barrier_enabled.load(std::sync::atomic::Ordering::SeqCst) {
17941812
                                     IpcResponse::Error { message: "Barrier enabled".to_string() }
17951813
                                 } else {
17961814
                                     // Initiate new transfer