output: decouple identity from wayland output
This commit is contained in:
parent
59e4e6dfb7
commit
a20deb0628
13 changed files with 110 additions and 113 deletions
|
|
@ -10,7 +10,6 @@ use {
|
|||
fixed::Fixed,
|
||||
format::Format,
|
||||
gfx_api::{FdSync, GfxApi, GfxFramebuffer},
|
||||
ifs::wl_output::OutputId,
|
||||
libinput::consts::DeviceCapability,
|
||||
utils::static_text::StaticText,
|
||||
video::drm::{
|
||||
|
|
@ -33,6 +32,8 @@ use {
|
|||
|
||||
pub mod transaction;
|
||||
|
||||
pub use jay_output_types::OutputId;
|
||||
|
||||
pub use jay_input_types::{
|
||||
AXIS_120, AxisSource, ButtonState, InputDeviceAccelProfile, InputDeviceClickMethod,
|
||||
InputDeviceGroupId, InputDeviceGroupIds, KeyState, Leds, PadButtonState, ScrollAxis, TabletId,
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ use {
|
|||
backend::{
|
||||
Backend, ButtonState, InputDevice, InputDeviceAccelProfile, InputDeviceCapability,
|
||||
InputDeviceClickMethod, InputDeviceGroupId, InputDeviceId, InputEvent, KeyState, Leds,
|
||||
TabletId, TabletInit, TabletPadGroupInit, TabletPadId, TabletPadInit, TransformMatrix,
|
||||
transaction::BackendConnectorTransactionError,
|
||||
OutputId, TabletId, TabletInit, TabletPadGroupInit, TabletPadId, TabletPadInit,
|
||||
TransformMatrix, transaction::BackendConnectorTransactionError,
|
||||
},
|
||||
backends::metal::{
|
||||
allocator::{RenderBufferError, ScanoutBufferError, ScanoutBufferErrors},
|
||||
|
|
@ -24,7 +24,6 @@ use {
|
|||
dbus::{DbusError, SignalHandler},
|
||||
drm_feedback::DrmFeedback,
|
||||
gfx_api::{GfxError, SyncFile},
|
||||
ifs::wl_output::OutputId,
|
||||
libinput::{
|
||||
LibInput, LibInputAdapter, LibInputError,
|
||||
consts::{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use {
|
|||
BackendDrmLessee, BackendEotfs, BackendEvent, BackendGammaLut, BackendGammaLutElement,
|
||||
BackendLuminance, CONCAP_CONNECTOR, CONCAP_MODE_SETTING, CONCAP_PHYSICAL_DISPLAY,
|
||||
Connector, ConnectorCaps, ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId,
|
||||
HardwareCursor, HardwareCursorUpdate, Mode, MonitorInfo,
|
||||
HardwareCursor, HardwareCursorUpdate, Mode, MonitorInfo, OutputId,
|
||||
transaction::{
|
||||
BackendConnectorTransaction, BackendConnectorTransactionError,
|
||||
BackendConnectorTransactionType, BackendConnectorTransactionTypeDyn,
|
||||
|
|
@ -27,10 +27,7 @@ use {
|
|||
edid::{CtaDataBlock, Descriptor, EdidExtension},
|
||||
format::{Format, XRGB8888},
|
||||
gfx_api::{FdSync, GfxApi, GfxContext, GfxFramebuffer},
|
||||
ifs::{
|
||||
wl_output::OutputId,
|
||||
wp_presentation_feedback::{KIND_HW_COMPLETION, KIND_VSYNC, KIND_ZERO_COPY},
|
||||
},
|
||||
ifs::wp_presentation_feedback::{KIND_HW_COMPLETION, KIND_VSYNC, KIND_ZERO_COPY},
|
||||
state::State,
|
||||
tree::OutputNode,
|
||||
udev::UdevDevice,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use {
|
|||
ButtonState, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId,
|
||||
DrmEvent, InputDevice, InputDeviceAccelProfile, InputDeviceCapability,
|
||||
InputDeviceClickMethod, InputDeviceId, InputEvent, KeyState, Mode, MonitorInfo,
|
||||
ScrollAxis, TransformMatrix,
|
||||
OutputId, ScrollAxis, TransformMatrix,
|
||||
transaction::{
|
||||
BackendAppliedConnectorTransaction, BackendConnectorTransaction,
|
||||
BackendConnectorTransactionError, BackendConnectorTransactionType,
|
||||
|
|
@ -20,7 +20,6 @@ use {
|
|||
gfx_api::{
|
||||
AcquireSync, GfxApi, GfxContext, GfxError, GfxFramebuffer, GfxTexture, ReleaseSync,
|
||||
},
|
||||
ifs::wl_output::OutputId,
|
||||
state::State,
|
||||
time::Time,
|
||||
utils::{
|
||||
|
|
|
|||
|
|
@ -33,12 +33,13 @@ use {
|
|||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
collections::hash_map::Entry,
|
||||
hash::{Hash, Hasher},
|
||||
rc::Rc,
|
||||
},
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub use jay_output_types::OutputId;
|
||||
|
||||
const SP_UNKNOWN: i32 = 0;
|
||||
#[expect(dead_code)]
|
||||
const SP_NONE: i32 = 1;
|
||||
|
|
@ -173,70 +174,6 @@ impl Default for PersistentOutputState {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, Debug)]
|
||||
pub struct OutputId {
|
||||
pub _connector: Option<String>,
|
||||
pub manufacturer: String,
|
||||
pub model: String,
|
||||
pub serial_number: String,
|
||||
pub hash: OutputIdHash,
|
||||
}
|
||||
|
||||
hash_type!(OutputIdHash);
|
||||
|
||||
impl PartialEq for OutputId {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.hash == other.hash
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for OutputId {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.hash.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl OutputId {
|
||||
pub fn new(
|
||||
connector: impl Into<String>,
|
||||
manufacturer: impl Into<String>,
|
||||
model: impl Into<String>,
|
||||
serial_number: impl Into<String>,
|
||||
) -> Rc<Self> {
|
||||
let connector = connector.into();
|
||||
let manufacturer = manufacturer.into();
|
||||
let model = model.into();
|
||||
let serial_number = serial_number.into();
|
||||
Self::new_(connector, manufacturer, model, serial_number)
|
||||
}
|
||||
|
||||
fn new_(
|
||||
connector: String,
|
||||
manufacturer: String,
|
||||
model: String,
|
||||
serial_number: String,
|
||||
) -> Rc<Self> {
|
||||
let connector = serial_number.is_empty().then_some(connector);
|
||||
let mut hasher = blake3::Hasher::new();
|
||||
hasher.update(&[connector.is_some() as u8]);
|
||||
let mut hash = |s: &str| {
|
||||
hasher.update(&(s.len() as u64).to_le_bytes());
|
||||
hasher.update(s.as_bytes());
|
||||
};
|
||||
connector.as_deref().map(&mut hash);
|
||||
hash(&manufacturer);
|
||||
hash(&model);
|
||||
hash(&serial_number);
|
||||
Rc::new(Self {
|
||||
_connector: connector,
|
||||
manufacturer,
|
||||
model,
|
||||
serial_number,
|
||||
hash: OutputIdHash(*hasher.finalize().as_bytes()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl WlOutputGlobal {
|
||||
pub fn clear(&self) {
|
||||
self.opt.clear();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use {
|
|||
AxisSource, Backend, BackendConnectorState, BackendEvent, ButtonState, Connector,
|
||||
ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId, InputDevice,
|
||||
InputDeviceAccelProfile, InputDeviceCapability, InputDeviceClickMethod, InputDeviceId,
|
||||
InputEvent, KeyState, Mode, MonitorInfo, ScrollAxis, TransformMatrix,
|
||||
InputEvent, KeyState, Mode, MonitorInfo, OutputId, ScrollAxis, TransformMatrix,
|
||||
transaction::{
|
||||
BackendAppliedConnectorTransaction, BackendConnectorTransaction,
|
||||
BackendConnectorTransactionError, BackendConnectorTransactionType,
|
||||
|
|
@ -20,7 +20,6 @@ use {
|
|||
format::XRGB8888,
|
||||
gfx_api::GfxError,
|
||||
gfx_apis::create_vulkan_allocator,
|
||||
ifs::wl_output::OutputId,
|
||||
it::{
|
||||
test_error::TestResult, test_gfx_api::TestGfxCtx, test_utils::test_expected_event::TEEH,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ use {
|
|||
crate::{
|
||||
backend::{
|
||||
BackendConnectorState, BackendEvent, ConnectorEvent, ConnectorKernelId, MonitorInfo,
|
||||
OutputId,
|
||||
},
|
||||
cmm::cmm_primaries::Primaries,
|
||||
format::XRGB8888,
|
||||
ifs::wl_output::OutputId,
|
||||
it::{test_backend::TestConnector, test_error::TestResult, testrun::TestRun},
|
||||
utils::numcell::NumCell,
|
||||
video::drm::ConnectorType,
|
||||
|
|
|
|||
|
|
@ -830,35 +830,3 @@ macro_rules! opaque {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! hash_type {
|
||||
($name:ident) => {
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct $name(pub [u8; 32]);
|
||||
|
||||
impl $name {
|
||||
#[allow(clippy::allow_attributes, dead_code)]
|
||||
pub fn hash(t: impl AsRef<[u8]>) -> Self {
|
||||
Self(*blake3::hash(t.as_ref()).as_bytes())
|
||||
}
|
||||
}
|
||||
|
||||
impl serde::Serialize for $name {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
self.0.serialize(serializer)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> serde::Deserialize<'de> for $name {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
<[u8; 32]>::deserialize(deserializer).map(Self)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use {
|
|||
async_engine::{Phase, SpawnedFuture},
|
||||
backend::{
|
||||
BackendConnectorState, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId,
|
||||
DrmDeviceId, HardwareCursor, HardwareCursorUpdate, Mode, MonitorInfo,
|
||||
DrmDeviceId, HardwareCursor, HardwareCursorUpdate, Mode, MonitorInfo, OutputId,
|
||||
transaction::{
|
||||
BackendAppliedConnectorTransaction, BackendConnectorTransaction,
|
||||
BackendConnectorTransactionError, BackendConnectorTransactionType,
|
||||
|
|
@ -18,7 +18,7 @@ use {
|
|||
GfxError, GfxFramebuffer, GfxRenderPass, GfxTexture, ReleaseSync, create_render_pass,
|
||||
},
|
||||
ifs::{
|
||||
wl_output::{BlendSpace, OutputId},
|
||||
wl_output::BlendSpace,
|
||||
wp_presentation_feedback::{
|
||||
KIND_HW_CLOCK, KIND_HW_COMPLETION, KIND_VSYNC, KIND_ZERO_COPY,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue