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<()> {
11921192
                                                 if has_peer {
11931193
                                                     // Check if we're in ReceivedControl state from this direction
11941194
                                                     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
+
11961210
                                                         if *from == edge_dir {
11971211
                                                             info!(
11981212
                                                                 "CURSOR EDGE: {:?} at ({}, {}) - returning control",