tenseleyflow/hyprkvm / c9a8dd6

Browse files

fix: add cooldown after entering ReceivedControl to prevent double navigation

When Super+Arrow triggers a transfer, the keypress gets forwarded to the
receiving machine and causes Hyprland to fire IPC Move. This resulted in
focus moving an extra window after the transfer.

Add a 1-second cooldown after entering ReceivedControl during which all
IPC Move events are ignored.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
c9a8dd6ad5e20da128595c2f198fd6effae877d8
Parents
6d08dd0
Tree
d8f072b

1 changed file

StatusFile+-
M hyprkvm-daemon/src/main.rs 13 0
hyprkvm-daemon/src/main.rsmodified
@@ -1741,6 +1741,19 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
17411741
                         let current_state = transfer_manager.state().await;
17421742
                         info!("IPC Move {:?}: state={:?}", direction, current_state);
17431743
 
1744
+                        // Early exit: if in ReceivedControl and within cooldown, ignore
1745
+                        // (prevents the Super+Arrow keypress that triggered the transfer from
1746
+                        // causing a double navigation on the receiving machine)
1747
+                        if let transfer::TransferState::ReceivedControl { entered_at, .. } = &current_state {
1748
+                            const RECEIVED_CONTROL_IPC_COOLDOWN_MS: u128 = 1000;
1749
+                            let time_in_state = entered_at.elapsed().as_millis();
1750
+                            if time_in_state < RECEIVED_CONTROL_IPC_COOLDOWN_MS {
1751
+                                tracing::info!("IPC Move {:?}: in ReceivedControl cooldown ({}ms), ignoring", direction, time_in_state);
1752
+                                response_tx.send(IpcResponse::Ok { message: "in cooldown".to_string() }).ok();
1753
+                                continue;
1754
+                            }
1755
+                        }
1756
+
17441757
                         // If we're already initiating a transfer in this direction, skip entirely
17451758
                         // (prevents double-action when both RECOVERY hotkey and IPC Move fire)
17461759
                         if let transfer::TransferState::Initiating { target, .. } = &current_state {