tenseleyflow/hyprkvm / a657504

Browse files

Revert "fix: prevent deviceless machines from initiating transfers"

This reverts commit ca44876ddfd05184dff035359d920e0ca88ee10d.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
a65750432432bbdc3f24231a89570dc3adb38118
Parents
ca44876
Tree
b2b2ba6

2 changed files

StatusFile+-
M hyprkvm-daemon/src/input/evdev_grab.rs 2 20
M hyprkvm-daemon/src/main.rs 18 47
hyprkvm-daemon/src/input/evdev_grab.rsmodified
@@ -30,9 +30,6 @@ pub struct EvdevGrabber {
3030
     recovery_active: Arc<AtomicU64>,
3131
     /// The direction to watch for in recovery mode (encoded as u8: 1=Up, 2=Down, 3=Left, 4=Right, 0=none)
3232
     recovery_direction: Arc<AtomicU64>,
33
-    /// Flag indicating whether this grabber has input devices to grab
34
-    /// If false, this machine cannot initiate transfers (but can still receive them)
35
-    has_devices: Arc<AtomicBool>,
3633
     event_rx: mpsc::Receiver<GrabEvent>,
3734
     _thread: thread::JoinHandle<()>,
3835
 }
@@ -46,15 +43,13 @@ impl EvdevGrabber {
4643
         let recovery_clone = recovery_active.clone();
4744
         let recovery_direction = Arc::new(AtomicU64::new(0));
4845
         let recovery_dir_clone = recovery_direction.clone();
49
-        let has_devices = Arc::new(AtomicBool::new(false));
50
-        let has_devices_clone = has_devices.clone();
5146
 
5247
         let (event_tx, event_rx) = mpsc::channel();
5348
 
5449
         let thread = thread::Builder::new()
5550
             .name("evdev-grabber".to_string())
5651
             .spawn(move || {
57
-                if let Err(e) = run_evdev_grabber(active_clone, recovery_clone, recovery_dir_clone, has_devices_clone, event_tx) {
52
+                if let Err(e) = run_evdev_grabber(active_clone, recovery_clone, recovery_dir_clone, event_tx) {
5853
                     tracing::error!("Evdev grabber error: {}", e);
5954
                 }
6055
             })
@@ -64,7 +59,6 @@ impl EvdevGrabber {
6459
             active,
6560
             recovery_active,
6661
             recovery_direction,
67
-            has_devices,
6862
             event_rx,
6963
             _thread: thread,
7064
         })
@@ -107,13 +101,6 @@ impl EvdevGrabber {
107101
         self.active.load(Ordering::SeqCst)
108102
     }
109103
 
110
-    /// Check if this grabber has input devices available
111
-    /// If false, this machine cannot initiate transfers (no devices to grab)
112
-    /// but can still receive control from other machines
113
-    pub fn has_devices(&self) -> bool {
114
-        self.has_devices.load(Ordering::SeqCst)
115
-    }
116
-
117104
     /// Try to receive a grab event (non-blocking)
118105
     pub fn try_recv(&self) -> Option<GrabEvent> {
119106
         self.event_rx.try_recv().ok()
@@ -197,20 +184,15 @@ fn run_evdev_grabber(
197184
     active: Arc<AtomicBool>,
198185
     recovery_active: Arc<AtomicU64>,
199186
     recovery_direction: Arc<AtomicU64>,
200
-    has_devices: Arc<AtomicBool>,
201187
     event_tx: mpsc::Sender<GrabEvent>,
202188
 ) -> Result<(), EvdevGrabError> {
203189
     let device_paths = find_input_devices();
204190
 
205191
     if device_paths.is_empty() {
206
-        tracing::warn!("No input devices found - this machine cannot initiate transfers");
207
-        // Leave has_devices as false (default)
208192
         return Err(EvdevGrabError::NoDevices);
209193
     }
210194
 
211
-    // Mark that we have devices - transfers can be initiated from this machine
212
-    has_devices.store(true, Ordering::SeqCst);
213
-    tracing::info!("Found {} input device paths (can initiate transfers)", device_paths.len());
195
+    tracing::info!("Found {} input device paths", device_paths.len());
214196
     for path in &device_paths {
215197
         tracing::debug!("  {}", path.display());
216198
     }
hyprkvm-daemon/src/main.rsmodified
@@ -967,10 +967,6 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
967967
 
968968
                                 if barrier_enabled.load(std::sync::atomic::Ordering::SeqCst) {
969969
                                     info!("RECOVERY HOTKEY: Barrier enabled, blocking transfer");
970
-                                } else if !input_grabber.has_devices() {
971
-                                    // Should never happen (no devices = no recovery hotkey events)
972
-                                    // but guard against it anyway
973
-                                    tracing::debug!("RECOVERY HOTKEY: No input devices, cannot initiate");
974970
                                 } else {
975971
                                     info!("RECOVERY HOTKEY: At edge with peer, initiating transfer to {:?}", direction);
976972
                                     if let Err(e) = transfer_manager.initiate_transfer(
@@ -1080,14 +1076,6 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
10801076
                                 cursor_pos.0,
10811077
                                 cursor_pos.1
10821078
                             );
1083
-                        } else if !input_grabber.has_devices() {
1084
-                            // No input devices = cannot initiate transfers (deviceless machine)
1085
-                            tracing::debug!(
1086
-                                "EDGE: {:?} at ({}, {}) - no input devices, cannot initiate",
1087
-                                direction,
1088
-                                cursor_pos.0,
1089
-                                cursor_pos.1
1090
-                            );
10911079
                         } else {
10921080
                             info!(
10931081
                                 "EDGE: {:?} at ({}, {}) - initiating transfer",
@@ -1232,12 +1220,6 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
12321220
                                                             "CURSOR EDGE: {:?} at ({}, {}) - barrier enabled, blocking",
12331221
                                                             edge_dir, cx, cy
12341222
                                                         );
1235
-                                                    } else if !input_grabber.has_devices() {
1236
-                                                        // No input devices = cannot initiate transfers
1237
-                                                        tracing::debug!(
1238
-                                                            "CURSOR EDGE: {:?} at ({}, {}) - no input devices, cannot initiate",
1239
-                                                            edge_dir, cx, cy
1240
-                                                        );
12411223
                                                     } else {
12421224
                                                         info!(
12431225
                                                             "CURSOR EDGE: {:?} at ({}, {}) - initiating transfer",
@@ -1854,8 +1836,6 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
18541836
                                     // At edge with peer but received control from different direction
18551837
                                     if barrier_enabled.load(std::sync::atomic::Ordering::SeqCst) {
18561838
                                         IpcResponse::Error { message: "Barrier enabled".to_string() }
1857
-                                    } else if !input_grabber.has_devices() {
1858
-                                        IpcResponse::Error { message: "No input devices - cannot initiate transfer".to_string() }
18591839
                                     } else {
18601840
                                         // Initiate new transfer
18611841
                                         let cursor_pos = hypr_client.cursor_pos().await
@@ -1899,8 +1879,6 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
18991879
                                     }
19001880
                                 } else if barrier_enabled.load(std::sync::atomic::Ordering::SeqCst) {
19011881
                                     IpcResponse::Error { message: "Barrier enabled".to_string() }
1902
-                                } else if !input_grabber.has_devices() {
1903
-                                    IpcResponse::Error { message: "No input devices - cannot initiate transfer".to_string() }
19041882
                                 } else {
19051883
                                     // Initiate new transfer
19061884
                                     let cursor_pos = hypr_client.cursor_pos().await
@@ -2092,32 +2070,25 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
20922070
                                 if peers_guard.get(&dir).is_some() {
20932071
                                     drop(peers_guard);
20942072
 
2095
-                                    // Check if we have input devices before initiating
2096
-                                    if !input_grabber.has_devices() {
2097
-                                        IpcResponse::Error {
2098
-                                            message: "No input devices - cannot initiate transfer".to_string(),
2073
+                                    // Get cursor position (use center of total screen)
2074
+                                    let cursor_pos = hypr_client.cursor_pos().await
2075
+                                        .map(|c| (c.x, c.y))
2076
+                                        .unwrap_or(((screen_min_x + screen_max_x) / 2, (screen_min_y + screen_max_y) / 2));
2077
+
2078
+                                    // Initiate transfer (CLI-initiated, not keyboard)
2079
+                                    info!("IPC Switch: calling initiate_transfer");
2080
+                                    match transfer_manager.initiate_transfer(dir, cursor_pos, screen_min_x, screen_min_y, screen_max_x, screen_max_y, false).await {
2081
+                                        Ok(()) => {
2082
+                                            let machine_name = config.machines.neighbors
2083
+                                                .iter()
2084
+                                                .find(|n| n.direction == dir)
2085
+                                                .map(|n| n.name.clone())
2086
+                                                .unwrap_or_else(|| format!("{:?}", dir));
2087
+                                            info!("IPC Switch: initiate_transfer succeeded, returning response to CLI");
2088
+                                            IpcResponse::Transferred { to_machine: machine_name }
20992089
                                         }
2100
-                                    } else {
2101
-                                        // Get cursor position (use center of total screen)
2102
-                                        let cursor_pos = hypr_client.cursor_pos().await
2103
-                                            .map(|c| (c.x, c.y))
2104
-                                            .unwrap_or(((screen_min_x + screen_max_x) / 2, (screen_min_y + screen_max_y) / 2));
2105
-
2106
-                                        // Initiate transfer (CLI-initiated, not keyboard)
2107
-                                        info!("IPC Switch: calling initiate_transfer");
2108
-                                        match transfer_manager.initiate_transfer(dir, cursor_pos, screen_min_x, screen_min_y, screen_max_x, screen_max_y, false).await {
2109
-                                            Ok(()) => {
2110
-                                                let machine_name = config.machines.neighbors
2111
-                                                    .iter()
2112
-                                                    .find(|n| n.direction == dir)
2113
-                                                    .map(|n| n.name.clone())
2114
-                                                    .unwrap_or_else(|| format!("{:?}", dir));
2115
-                                                info!("IPC Switch: initiate_transfer succeeded, returning response to CLI");
2116
-                                                IpcResponse::Transferred { to_machine: machine_name }
2117
-                                            }
2118
-                                            Err(e) => IpcResponse::Error {
2119
-                                                message: format!("Transfer failed: {}", e),
2120
-                                            }
2090
+                                        Err(e) => IpcResponse::Error {
2091
+                                            message: format!("Transfer failed: {}", e),
21212092
                                         }
21222093
                                     }
21232094
                                 } else {