1
0
Fork 0
forked from wry/wry

backend: move interface ids into type crates

This commit is contained in:
kossLAN 2026-05-29 12:51:31 -04:00
parent 46d39becd4
commit be1511a7be
No known key found for this signature in database
5 changed files with 95 additions and 46 deletions

View file

@ -22,7 +22,6 @@ use {
any::Any,
error::Error,
fmt::{Debug, Display, Formatter},
hash::Hash,
rc::Rc,
},
uapi::{OwnedFd, Packed, Pod, c},
@ -30,22 +29,18 @@ use {
pub mod transaction;
pub use jay_output_types::OutputId;
pub use jay_output_types::{ConnectorId, ConnectorIds, DrmDeviceId, DrmDeviceIds, Mode, OutputId};
pub use jay_input_types::{
AXIS_120, AxisSource, ButtonState, InputDeviceAccelProfile, InputDeviceCapability,
InputDeviceClickMethod, InputDeviceGroupId, InputDeviceGroupIds, KeyState, Leds,
PadButtonState, ScrollAxis, TabletId, TabletIds, TabletInit, TabletPadGroupInit, TabletPadId,
TabletPadIds, TabletPadInit, TabletRingEventSource, TabletStripEventSource,
TabletTool2dChange, TabletToolCapability, TabletToolChanges, TabletToolId, TabletToolIds,
TabletToolInit, TabletToolPositionChange, TabletToolType, TabletToolWheelChange,
ToolButtonState,
InputDeviceClickMethod, InputDeviceGroupId, InputDeviceGroupIds, InputDeviceId,
InputDeviceIds, KeyState, Leds, PadButtonState, ScrollAxis, TabletId, TabletIds, TabletInit,
TabletPadGroupInit, TabletPadId, TabletPadIds, TabletPadInit, TabletRingEventSource,
TabletStripEventSource, TabletTool2dChange, TabletToolCapability, TabletToolChanges,
TabletToolId, TabletToolIds, TabletToolInit, TabletToolPositionChange, TabletToolType,
TabletToolWheelChange, ToolButtonState, TransformMatrix,
};
linear_ids!(ConnectorIds, ConnectorId);
linear_ids!(InputDeviceIds, InputDeviceId);
linear_ids!(DrmDeviceIds, DrmDeviceId);
pub trait Backend: Any {
fn run(self: Rc<Self>) -> SpawnedFuture<Result<(), Box<dyn Error>>>;
fn clear(&self) {
@ -69,38 +64,6 @@ pub trait Backend: Any {
}
}
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct Mode {
pub width: i32,
pub height: i32,
pub refresh_rate_millihz: u32,
}
impl Mode {
pub fn refresh_nsec(&self) -> u64 {
match self.refresh_rate_millihz {
0 => u64::MAX,
n => 1_000_000_000_000 / (n as u64),
}
}
pub fn size(&self) -> (i32, i32) {
(self.width, self.height)
}
}
impl Display for Mode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}x{}@{}",
self.width,
self.height,
self.refresh_rate_millihz as f64 / 1000.0,
)
}
}
#[derive(Clone, Debug)]
pub struct MonitorInfo {
pub modes: Option<Vec<Mode>>,
@ -202,8 +165,6 @@ pub trait HardwareCursor: Debug {
fn damage(&self);
}
pub type TransformMatrix = [[f64; 2]; 2];
pub trait InputDevice {
fn id(&self) -> InputDeviceId;
fn removed(&self) -> bool;