use { crate::{ async_engine::SpawnedFuture, backend::transaction::{ BackendConnectorTransaction, BackendConnectorTransactionError, BackendConnectorTransactionType, BackendConnectorTransactionTypeDyn, }, drm_feedback::DrmFeedback, format::Format, gfx_api::{FdSync, GfxApi, GfxFramebuffer}, video::drm::{ConnectorType, DrmConnector, DrmError, DrmVersion}, }, std::{ any::Any, error::Error, fmt::{Debug, Display, Formatter}, rc::Rc, }, uapi::{OwnedFd, c}, }; pub mod transaction; pub use jay_output_types::{ BackendColorSpace, BackendConnectorState, BackendConnectorStateSerial, BackendConnectorStateSerials, BackendEotfs, BackendGammaLut, BackendGammaLutElement, BackendLuminance, CONCAP_CONNECTOR, CONCAP_MODE_SETTING, CONCAP_PHYSICAL_DISPLAY, ConnectorCaps, ConnectorId, ConnectorIds, DrmDeviceId, DrmDeviceIds, Mode, MonitorInfo, OutputId, }; pub use jay_input_types::{ AXIS_120, AxisSource, ButtonState, InputDeviceAccelProfile, InputDeviceCapability, InputDeviceClickMethod, InputDeviceGroupId, InputDeviceGroupIds, InputDeviceId, InputDeviceIds, InputEvent, KeyState, Leds, PadButtonState, ScrollAxis, SwitchEvent, TabletId, TabletIds, TabletInit, TabletPadGroupInit, TabletPadId, TabletPadIds, TabletPadInit, TabletRingEventSource, TabletStripEventSource, TabletTool2dChange, TabletToolCapability, TabletToolChanges, TabletToolId, TabletToolIds, TabletToolInit, TabletToolPositionChange, TabletToolType, TabletToolWheelChange, ToolButtonState, TransformMatrix, }; pub trait Backend: Any { fn run(self: Rc) -> SpawnedFuture>>; fn clear(&self) { // nothing } fn switch_to(&self, vtnr: u32) { let _ = vtnr; } fn import_environment(&self) -> bool { false } fn supports_presentation_feedback(&self) -> bool { false } fn get_input_fds(&self) -> Vec> { vec![] } } #[derive(Copy, Clone, Debug)] pub struct ConnectorKernelId { pub ty: ConnectorType, pub idx: u32, } impl Display for ConnectorKernelId { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}-{}", self.ty, self.idx) } } pub trait Connector: Any { fn id(&self) -> ConnectorId; fn kernel_id(&self) -> ConnectorKernelId; fn event(&self) -> Option; fn on_change(&self, cb: Rc); fn damage(&self); fn drm_dev(&self) -> Option; fn effectively_locked(&self) -> bool; fn state(&self) -> BackendConnectorState; fn caps(&self) -> ConnectorCaps { ConnectorCaps::none() } fn drm_feedback(&self) -> Option> { None } fn drm_object_id(&self) -> Option { None } fn before_non_desktop_override_update(&self, overrd: Option) { let _ = overrd; } fn transaction_type(&self) -> Box { #[derive(Hash, Eq, PartialEq)] struct UnimplementedConnectorTransactionType; impl BackendConnectorTransactionType for UnimplementedConnectorTransactionType {} Box::new(UnimplementedConnectorTransactionType) } fn create_transaction( &self, ) -> Result, BackendConnectorTransactionError> { Err(BackendConnectorTransactionError::TransactionsNotSupported( self.kernel_id(), )) } fn gamma_lut_size(&self) -> Option { None } fn name(&self) -> String { self.kernel_id().to_string() } } #[derive(Debug)] pub enum ConnectorEvent { Connected(MonitorInfo), HardwareCursor(Option>), Disconnected, Removed, Unavailable, Available, State(BackendConnectorState), FormatsChanged(Rc>), } pub trait HardwareCursorUpdate { fn set_enabled(&mut self, enabled: bool); fn get_buffer(&self) -> Rc; fn set_position(&mut self, x: i32, y: i32); fn swap_buffer(&mut self, sync: Option); fn size(&self) -> (i32, i32); } pub trait HardwareCursor: Debug { fn damage(&self); } pub trait InputDevice { fn id(&self) -> InputDeviceId; fn removed(&self) -> bool; fn event(&self) -> Option; fn on_change(&self, cb: Rc); fn grab(&self, grab: bool); fn has_capability(&self, cap: InputDeviceCapability) -> bool; fn left_handed(&self) -> Option { None } fn set_left_handed(&self, left_handed: bool); fn accel_profile(&self) -> Option { None } fn set_accel_profile(&self, profile: InputDeviceAccelProfile); fn accel_speed(&self) -> Option { None } fn set_accel_speed(&self, speed: f64); fn transform_matrix(&self) -> Option { None } fn set_transform_matrix(&self, matrix: TransformMatrix); fn calibration_matrix(&self) -> Option<[[f32; 3]; 2]> { None } fn set_calibration_matrix(&self, m: [[f32; 3]; 2]) { let _ = m; } fn name(&self) -> Rc; fn dev_t(&self) -> Option { None } fn tap_enabled(&self) -> Option { None } fn set_tap_enabled(&self, enabled: bool); fn drag_enabled(&self) -> Option { None } fn set_drag_enabled(&self, enabled: bool); fn drag_lock_enabled(&self) -> Option { None } fn set_drag_lock_enabled(&self, enabled: bool); fn natural_scrolling_enabled(&self) -> Option { None } fn set_natural_scrolling_enabled(&self, enabled: bool); fn click_method(&self) -> Option { None } fn set_click_method(&self, method: InputDeviceClickMethod); fn middle_button_emulation_enabled(&self) -> Option { None } fn set_middle_button_emulation_enabled(&self, enabled: bool); fn tablet_info(&self) -> Option> { None } fn tablet_pad_info(&self) -> Option> { None } fn set_enabled_leds(&self, leds: Leds) { let _ = leds; } } pub enum BackendEvent { NewDrmDevice(Rc), NewConnector(Rc), NewInputDevice(Rc), DevicesEnumerated, } pub enum DrmEvent { #[expect(dead_code)] Removed, GfxApiChanged, } pub trait BackendDrmDevice { fn id(&self) -> DrmDeviceId; fn event(&self) -> Option; fn on_change(&self, cb: Rc); fn dev_t(&self) -> c::dev_t; fn make_render_device(&self); fn set_gfx_api(&self, api: GfxApi); fn gtx_api(&self) -> GfxApi; fn version(&self) -> Result; fn set_direct_scanout_enabled(&self, enabled: bool); fn is_render_device(&self) -> bool; fn direct_scanout_enabled(&self) -> bool { false } fn gfx_fast_ram_access(&self) -> bool { false } fn create_lease( self: Rc, lessee: Rc, connector_ids: &[ConnectorId], ) { let _ = lessee; let _ = connector_ids; } fn set_flip_margin(&self, margin: u64) { let _ = margin; } } pub trait BackendDrmLease { fn fd(&self) -> &Rc; } pub trait BackendDrmLessee { fn created(&self, lease: Rc); }