tenseleyflow/hyprkvm / e6efc58

Browse files

fix: use axis_discrete for proper wheel scroll injection

Wayland compositors need axis_discrete events for mouse wheel scrolling.
Added axis_source(Wheel) and axis_discrete() calls with proper discrete
step calculation.
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
e6efc5820fddc26d4789f4bf3f9574e0f0a1663f
Parents
70f52eb
Tree
7168600

1 changed file

StatusFile+-
M hyprkvm-daemon/src/input/emulation.rs 21 2
hyprkvm-daemon/src/input/emulation.rsmodified
@@ -86,11 +86,30 @@ impl VirtualPointer {
8686
             .unwrap()
8787
             .as_millis() as u32;
8888
 
89
+        tracing::debug!("INJECT SCROLL: h={}, v={}", horizontal, vertical);
90
+
91
+        // Set axis source to wheel
92
+        use wayland_client::protocol::wl_pointer::AxisSource;
93
+        self.pointer.axis_source(AxisSource::Wheel);
94
+
8995
         if vertical.abs() > 0.001 {
90
-            self.pointer.axis(time, WlAxis::VerticalScroll, vertical);
96
+            // Calculate discrete steps (each notch is typically 15 units)
97
+            let discrete = (vertical / 15.0).round() as i32;
98
+            if discrete != 0 {
99
+                // Send discrete scroll for wheel mice
100
+                self.pointer.axis_discrete(time, WlAxis::VerticalScroll, vertical, discrete);
101
+            } else {
102
+                // Fallback to smooth scroll for small values
103
+                self.pointer.axis(time, WlAxis::VerticalScroll, vertical);
104
+            }
91105
         }
92106
         if horizontal.abs() > 0.001 {
93
-            self.pointer.axis(time, WlAxis::HorizontalScroll, horizontal);
107
+            let discrete = (horizontal / 15.0).round() as i32;
108
+            if discrete != 0 {
109
+                self.pointer.axis_discrete(time, WlAxis::HorizontalScroll, horizontal, discrete);
110
+            } else {
111
+                self.pointer.axis(time, WlAxis::HorizontalScroll, horizontal);
112
+            }
94113
         }
95114
         self.pointer.frame();
96115
         let _ = self.connection.flush();