1
0
Fork 0
forked from wry/wry

config: move output schema into schema crate

This commit is contained in:
kossLAN 2026-05-29 17:04:27 -04:00
parent e94d8fec1f
commit fb65585bfa
No known key found for this signature in database
4 changed files with 140 additions and 93 deletions

View file

@ -6,6 +6,7 @@
pub mod animations;
pub mod options;
pub mod output;
pub mod theme;
pub use animations::{AnimationCurveConfig, Animations};
@ -13,4 +14,7 @@ pub use options::{
ColorManagement, Float, FocusHistory, Libei, RepeatRate, SimpleIm, Tearing, UiDrag, Vrr,
Xwayland,
};
pub use output::{
ConfigConnector, ConfigDrmDevice, ConnectorMatch, DrmDeviceMatch, Mode, Output, OutputMatch,
};
pub use theme::Theme;

View file

@ -0,0 +1,88 @@
use {
crate::{Tearing, Vrr},
jay_config::video::{BlendSpace, ColorSpace, Eotf, Format, GfxApi, Transform},
std::fmt::{Display, Formatter},
};
#[derive(Debug, Clone)]
pub enum OutputMatch {
Any(Vec<OutputMatch>),
All {
name: Option<String>,
connector: Option<String>,
serial_number: Option<String>,
manufacturer: Option<String>,
model: Option<String>,
},
}
#[derive(Debug, Clone)]
pub enum DrmDeviceMatch {
Any(Vec<DrmDeviceMatch>),
All {
name: Option<String>,
syspath: Option<String>,
vendor: Option<u32>,
vendor_name: Option<String>,
model: Option<u32>,
model_name: Option<String>,
devnode: Option<String>,
},
}
#[derive(Debug, Clone)]
pub struct Mode {
pub width: i32,
pub height: i32,
pub refresh_rate: Option<f64>,
}
impl Display for Mode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{} x {}", self.width, self.height)?;
if let Some(rr) = self.refresh_rate {
write!(f, " @ {rr}")?;
}
Ok(())
}
}
#[derive(Debug, Clone)]
pub struct Output {
pub name: Option<String>,
pub match_: OutputMatch,
pub x: Option<i32>,
pub y: Option<i32>,
pub scale: Option<f64>,
pub transform: Option<Transform>,
pub mode: Option<Mode>,
pub vrr: Option<Vrr>,
pub tearing: Option<Tearing>,
pub format: Option<Format>,
pub color_space: Option<ColorSpace>,
pub eotf: Option<Eotf>,
pub brightness: Option<Option<f64>>,
pub blend_space: Option<BlendSpace>,
pub use_native_gamut: Option<bool>,
}
#[derive(Debug, Clone)]
pub enum ConnectorMatch {
Any(Vec<ConnectorMatch>),
All { connector: Option<String> },
}
#[derive(Debug, Clone)]
pub struct ConfigConnector {
pub match_: ConnectorMatch,
pub enabled: bool,
}
#[derive(Debug, Clone)]
pub struct ConfigDrmDevice {
pub name: Option<String>,
pub match_: DrmDeviceMatch,
pub gfx_api: Option<GfxApi>,
pub direct_scanout_enabled: Option<bool>,
pub flip_margin_ms: Option<f64>,
}

View file

@ -28,14 +28,13 @@ use {
keyboard::{Keymap, ModifiedKeySym, mods::Modifiers, syms::KeySym},
logging::LogLevel,
status::MessageFormat,
video::{BlendSpace, ColorSpace, Eotf, Format, GfxApi, Transform},
video::GfxApi,
window::{ContentType, TileState, WindowType},
workspace::WorkspaceDisplayOrder,
},
std::{
cell::RefCell,
error::Error,
fmt::{Display, Formatter},
rc::Rc,
time::Duration,
},
@ -44,8 +43,9 @@ use {
};
pub use jay_config_schema::{
AnimationCurveConfig, Animations, ColorManagement, Float, FocusHistory, Libei, RepeatRate,
SimpleIm, Tearing, Theme, UiDrag, Vrr, Xwayland,
AnimationCurveConfig, Animations, ColorManagement, ConfigConnector, ConfigDrmDevice,
ConnectorMatch, DrmDeviceMatch, Float, FocusHistory, Libei, Mode, Output, OutputMatch,
RepeatRate, SimpleIm, Tearing, Theme, UiDrag, Vrr, Xwayland,
};
#[derive(Debug, Copy, Clone)]
@ -211,18 +211,6 @@ pub struct Status {
pub separator: Option<String>,
}
#[derive(Debug, Clone)]
pub enum OutputMatch {
Any(Vec<OutputMatch>),
All {
name: Option<String>,
connector: Option<String>,
serial_number: Option<String>,
manufacturer: Option<String>,
model: Option<String>,
},
}
#[derive(Default, Debug, Clone)]
pub struct GenericMatch<Match> {
pub name: Option<String>,
@ -303,62 +291,6 @@ pub struct WindowMatch {
pub content_types: Option<ContentType>,
}
#[derive(Debug, Clone)]
pub enum DrmDeviceMatch {
Any(Vec<DrmDeviceMatch>),
All {
name: Option<String>,
syspath: Option<String>,
vendor: Option<u32>,
vendor_name: Option<String>,
model: Option<u32>,
model_name: Option<String>,
devnode: Option<String>,
},
}
#[derive(Debug, Clone)]
pub struct Mode {
pub width: i32,
pub height: i32,
pub refresh_rate: Option<f64>,
}
impl Display for Mode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{} x {}", self.width, self.height)?;
if let Some(rr) = self.refresh_rate {
write!(f, " @ {rr}")?;
}
Ok(())
}
}
#[derive(Debug, Clone)]
pub struct Output {
pub name: Option<String>,
pub match_: OutputMatch,
pub x: Option<i32>,
pub y: Option<i32>,
pub scale: Option<f64>,
pub transform: Option<Transform>,
pub mode: Option<Mode>,
pub vrr: Option<Vrr>,
pub tearing: Option<Tearing>,
pub format: Option<Format>,
pub color_space: Option<ColorSpace>,
pub eotf: Option<Eotf>,
pub brightness: Option<Option<f64>>,
pub blend_space: Option<BlendSpace>,
pub use_native_gamut: Option<bool>,
}
#[derive(Debug, Clone)]
pub enum ConnectorMatch {
Any(Vec<ConnectorMatch>),
All { connector: Option<String> },
}
#[derive(Debug, Clone)]
pub enum InputMatch {
Any(Vec<InputMatch>),
@ -405,21 +337,6 @@ pub struct Exec {
pub envs: Vec<(String, String)>,
}
#[derive(Debug, Clone)]
pub struct ConfigConnector {
pub match_: ConnectorMatch,
pub enabled: bool,
}
#[derive(Debug, Clone)]
pub struct ConfigDrmDevice {
pub name: Option<String>,
pub match_: DrmDeviceMatch,
pub gfx_api: Option<GfxApi>,
pub direct_scanout_enabled: Option<bool>,
pub flip_margin_ms: Option<f64>,
}
#[derive(Debug, Clone)]
pub enum ConfigKeymap {
Named(String),

View file

@ -538,7 +538,11 @@ fn apply_recursive_match<'a, U>(
}
}
impl ConfigDrmDevice {
trait ConfigDrmDeviceExt {
fn apply(&self, d: DrmDevice);
}
impl ConfigDrmDeviceExt for ConfigDrmDevice {
fn apply(&self, d: DrmDevice) {
if let Some(api) = self.gfx_api {
d.set_gfx_api(api);
@ -552,7 +556,18 @@ impl ConfigDrmDevice {
}
}
impl DrmDeviceMatch {
trait DrmDeviceMatchExt {
fn matches(&self, d: DrmDevice, state: &State) -> bool;
fn matches_<'a>(
&'a self,
d: DrmDevice,
state: &'a State,
active: &mut AHashSet<&'a str>,
) -> bool;
}
impl DrmDeviceMatchExt for DrmDeviceMatch {
fn matches(&self, d: DrmDevice, state: &State) -> bool {
self.matches_(d, state, &mut AHashSet::new())
}
@ -754,7 +769,18 @@ impl Input {
}
}
impl OutputMatch {
trait OutputMatchExt {
fn matches(&self, c: Connector, state: &State) -> bool;
fn matches_<'a>(
&'a self,
c: Connector,
state: &'a State,
active: &mut AHashSet<&'a str>,
) -> bool;
}
impl OutputMatchExt for OutputMatch {
fn matches(&self, c: Connector, state: &State) -> bool {
if !c.connected() {
return false;
@ -815,7 +841,11 @@ impl OutputMatch {
}
}
impl ConnectorMatch {
trait ConnectorMatchExt {
fn matches(&self, c: Connector) -> bool;
}
impl ConnectorMatchExt for ConnectorMatch {
fn matches(&self, c: Connector) -> bool {
if !c.exists() {
return false;
@ -834,13 +864,21 @@ impl ConnectorMatch {
}
}
impl ConfigConnector {
trait ConfigConnectorExt {
fn apply(&self, c: Connector);
}
impl ConfigConnectorExt for ConfigConnector {
fn apply(&self, c: Connector) {
c.set_enabled(self.enabled);
}
}
impl Output {
trait OutputExt {
fn apply(&self, c: Connector);
}
impl OutputExt for Output {
fn apply(&self, c: Connector) {
if self.x.is_some() || self.y.is_some() {
let (old_x, old_y) = c.position();