1
0
Fork 0
forked from wry/wry

wayland: add times to all input events

This commit is contained in:
Julian Orth 2022-05-26 12:25:59 +02:00
parent 568341a3d0
commit 145e4dbc24
16 changed files with 235 additions and 101 deletions

View file

@ -12,6 +12,7 @@ use {
ifs::wl_seat::PX_PER_SCROLL,
render::{Framebuffer, RenderContext, RenderError, RenderResult, Texture},
state::State,
time::now_usec,
utils::{
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, numcell::NumCell,
queue::AsyncQueue, syncqueue::SyncQueue,
@ -761,13 +762,17 @@ impl XBackend {
7 => (ScrollAxis::Horizontal, 1),
_ => unreachable!(),
};
seat.mouse_event(InputEvent::AxisSource(AxisSource::Wheel));
seat.mouse_event(InputEvent::AxisDiscrete(val, axis));
seat.mouse_event(InputEvent::Axis(
Fixed::from_f64(val as f64 * PX_PER_SCROLL),
seat.mouse_event(InputEvent::AxisSource {
source: AxisSource::Wheel,
});
seat.mouse_event(InputEvent::AxisDiscrete { dist: val, axis });
seat.mouse_event(InputEvent::Axis {
dist: Fixed::from_f64(val as f64 * PX_PER_SCROLL),
axis,
));
seat.mouse_event(InputEvent::Frame);
});
seat.mouse_event(InputEvent::AxisFrame {
time_usec: now_usec(),
});
}
} else {
const BTN_LEFT: u32 = 0x110;
@ -781,7 +786,11 @@ impl XBackend {
3 => BTN_RIGHT,
n => BTN_SIDE + n - 8,
};
seat.mouse_event(InputEvent::Button(button, state));
seat.mouse_event(InputEvent::Button {
time_usec: now_usec(),
button,
state,
});
}
}
Ok(())
@ -794,7 +803,11 @@ impl XBackend {
) -> Result<(), XBackendError> {
let event: XiKeyPress = event.parse()?;
if let Some(seat) = self.seats.get(&event.deviceid) {
seat.kb_event(InputEvent::Key(event.detail - 8, state));
seat.kb_event(InputEvent::Key {
time_usec: now_usec(),
key: event.detail - 8,
state,
});
}
Ok(())
}
@ -824,11 +837,12 @@ impl XBackend {
self.outputs.get(&event.event),
self.mouse_seats.get(&event.deviceid),
) {
seat.mouse_event(InputEvent::ConnectorPosition(
win.id,
Fixed::from_1616(event.event_x),
Fixed::from_1616(event.event_y),
));
seat.mouse_event(InputEvent::ConnectorPosition {
time_usec: now_usec(),
connector: win.id,
x: Fixed::from_1616(event.event_x),
y: Fixed::from_1616(event.event_y),
});
}
Ok(())
}
@ -842,11 +856,12 @@ impl XBackend {
(Some(a), Some(b)) => (a, b),
_ => return Ok(()),
};
seat.mouse_event(InputEvent::ConnectorPosition(
win.id,
Fixed::from_1616(event.event_x),
Fixed::from_1616(event.event_y),
));
seat.mouse_event(InputEvent::ConnectorPosition {
time_usec: now_usec(),
connector: win.id,
x: Fixed::from_1616(event.event_x),
y: Fixed::from_1616(event.event_y),
});
Ok(())
}