tenseleyflow/hyprkvm / 35e3714

Browse files

fix: add cooldown after entering ReceivedControl to prevent immediate return

The edge detection was triggering immediately after entering ReceivedControl
because Hyprland's cursor position query returned stale data before the warp
took effect. Add 500ms cooldown after entering the state.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
35e3714959d5e1bc4e6a3d6f8c0caff5a8e7bfd3
Parents
3ca05aa
Tree
51b1a97

1 changed file

StatusFile+-
M hyprkvm-daemon/src/main.rs 15 1
hyprkvm-daemon/src/main.rsmodified
@@ -1192,7 +1192,21 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
1192
                                                 if has_peer {
1192
                                                 if has_peer {
1193
                                                     // Check if we're in ReceivedControl state from this direction
1193
                                                     // Check if we're in ReceivedControl state from this direction
1194
                                                     let current_state = transfer_manager.state().await;
1194
                                                     let current_state = transfer_manager.state().await;
1195
-                                                    if let transfer::TransferState::ReceivedControl { from, .. } = &current_state {
1195
+                                                    if let transfer::TransferState::ReceivedControl { from, entered_at, .. } = &current_state {
1196
+                                                        // Add cooldown after entering ReceivedControl to prevent immediate return
1197
+                                                        // (cursor warp may not have taken effect yet, or stale position from polling)
1198
+                                                        const RECEIVED_CONTROL_COOLDOWN_MS: u128 = 500;
1199
+                                                        let time_in_state = entered_at.elapsed().as_millis();
1200
+
1201
+                                                        if time_in_state < RECEIVED_CONTROL_COOLDOWN_MS {
1202
+                                                            tracing::debug!(
1203
+                                                                "CURSOR EDGE: {:?} - just entered ReceivedControl {}ms ago, waiting",
1204
+                                                                edge_dir, time_in_state
1205
+                                                            );
1206
+                                                            edge_dwell_start = None;
1207
+                                                            continue;
1208
+                                                        }
1209
+
1196
                                                         if *from == edge_dir {
1210
                                                         if *from == edge_dir {
1197
                                                             info!(
1211
                                                             info!(
1198
                                                                 "CURSOR EDGE: {:?} at ({}, {}) - returning control",
1212
                                                                 "CURSOR EDGE: {:?} at ({}, {}) - returning control",