tenseleyflow/hyprkvm / 3529085

Browse files

fix: use logical dimensions for monitor direction checks

Monitor positions are in logical coordinates but width/height from
Hyprland are physical. Fixed edge detection to convert physical
dimensions to logical (dividing by scale) for consistent comparisons.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
3529085313d88887d0a1f9d89de2f8a22b6dffbd
Parents
1ea754f
Tree
97a7dae

1 changed file

StatusFile+-
M hyprkvm-daemon/src/main.rs 18 8
hyprkvm-daemon/src/main.rsmodified
@@ -872,13 +872,18 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
872
                                 };
872
                                 };
873
 
873
 
874
                                 // Check if there's another monitor in the requested direction
874
                                 // Check if there's another monitor in the requested direction
875
+                                // Use logical dimensions (physical / scale) since positions are logical
875
                                 let has_monitor_in_direction = monitors.iter().any(|m| {
876
                                 let has_monitor_in_direction = monitors.iter().any(|m| {
876
                                     if m.id == focused_monitor.id { return false; }
877
                                     if m.id == focused_monitor.id { return false; }
878
+                                    let m_logical_w = (m.width as f32 / m.scale).round() as i32;
879
+                                    let m_logical_h = (m.height as f32 / m.scale).round() as i32;
880
+                                    let focused_logical_w = (focused_monitor.width as f32 / focused_monitor.scale).round() as i32;
881
+                                    let focused_logical_h = (focused_monitor.height as f32 / focused_monitor.scale).round() as i32;
877
                                     match direction {
882
                                     match direction {
878
-                                        Direction::Left => m.x + m.width as i32 <= focused_monitor.x,
883
+                                        Direction::Left => m.x + m_logical_w <= focused_monitor.x,
879
-                                        Direction::Right => m.x >= focused_monitor.x + focused_monitor.width as i32,
884
+                                        Direction::Right => m.x >= focused_monitor.x + focused_logical_w,
880
-                                        Direction::Up => m.y + m.height as i32 <= focused_monitor.y,
885
+                                        Direction::Up => m.y + m_logical_h <= focused_monitor.y,
881
-                                        Direction::Down => m.y >= focused_monitor.y + focused_monitor.height as i32,
886
+                                        Direction::Down => m.y >= focused_monitor.y + focused_logical_h,
882
                                     }
887
                                     }
883
                                 });
888
                                 });
884
 
889
 
@@ -1692,13 +1697,18 @@ async fn run_daemon(config_path: &std::path::Path) -> anyhow::Result<()> {
1692
                             };
1697
                             };
1693
 
1698
 
1694
                             // Check if there's another monitor in the requested direction
1699
                             // Check if there's another monitor in the requested direction
1700
+                            // Use logical dimensions (physical / scale) since positions are logical
1695
                             let has_monitor_in_direction = monitors.iter().any(|m| {
1701
                             let has_monitor_in_direction = monitors.iter().any(|m| {
1696
                                 if m.id == focused_monitor.id { return false; }
1702
                                 if m.id == focused_monitor.id { return false; }
1703
+                                let m_logical_w = (m.width as f32 / m.scale).round() as i32;
1704
+                                let m_logical_h = (m.height as f32 / m.scale).round() as i32;
1705
+                                let focused_logical_w = (focused_monitor.width as f32 / focused_monitor.scale).round() as i32;
1706
+                                let focused_logical_h = (focused_monitor.height as f32 / focused_monitor.scale).round() as i32;
1697
                                 match direction {
1707
                                 match direction {
1698
-                                    Direction::Left => m.x + m.width as i32 <= focused_monitor.x,
1708
+                                    Direction::Left => m.x + m_logical_w <= focused_monitor.x,
1699
-                                    Direction::Right => m.x >= focused_monitor.x + focused_monitor.width as i32,
1709
+                                    Direction::Right => m.x >= focused_monitor.x + focused_logical_w,
1700
-                                    Direction::Up => m.y + m.height as i32 <= focused_monitor.y,
1710
+                                    Direction::Up => m.y + m_logical_h <= focused_monitor.y,
1701
-                                    Direction::Down => m.y >= focused_monitor.y + focused_monitor.height as i32,
1711
+                                    Direction::Down => m.y >= focused_monitor.y + focused_logical_h,
1702
                                 }
1712
                                 }
1703
                             });
1713
                             });
1704
 
1714