Add time to scroll event (#240)

closes #239
This commit is contained in:
Vassili-Dev
2025-01-20 11:32:51 -05:00
committed by GitHub
parent 9ce00da31c
commit a8504df879

View File

@@ -5,6 +5,7 @@ use async_trait::async_trait;
use std::collections::HashMap;
use std::io;
use std::os::fd::{AsFd, OwnedFd};
use std::time::{SystemTime, UNIX_EPOCH};
use wayland_client::backend::WaylandError;
use wayland_client::WEnum;
@@ -177,6 +178,11 @@ struct VirtualInput {
impl VirtualInput {
fn consume_event(&self, event: Event) -> Result<(), ()> {
let now: u32 = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.as_millis() as u32;
match event {
Event::Pointer(e) => {
match e {
@@ -197,7 +203,7 @@ impl VirtualInput {
PointerEvent::AxisDiscrete120 { axis, value } => {
let axis: Axis = (axis as u32).try_into()?;
self.pointer
.axis_discrete(0, axis, value as f64 / 6., value / 120);
.axis_discrete(now, axis, value as f64 / 6., value / 120);
self.pointer.frame();
}
}