config: move output schema into schema crate
This commit is contained in:
parent
e94d8fec1f
commit
fb65585bfa
4 changed files with 140 additions and 93 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
pub mod animations;
|
pub mod animations;
|
||||||
pub mod options;
|
pub mod options;
|
||||||
|
pub mod output;
|
||||||
pub mod theme;
|
pub mod theme;
|
||||||
|
|
||||||
pub use animations::{AnimationCurveConfig, Animations};
|
pub use animations::{AnimationCurveConfig, Animations};
|
||||||
|
|
@ -13,4 +14,7 @@ pub use options::{
|
||||||
ColorManagement, Float, FocusHistory, Libei, RepeatRate, SimpleIm, Tearing, UiDrag, Vrr,
|
ColorManagement, Float, FocusHistory, Libei, RepeatRate, SimpleIm, Tearing, UiDrag, Vrr,
|
||||||
Xwayland,
|
Xwayland,
|
||||||
};
|
};
|
||||||
|
pub use output::{
|
||||||
|
ConfigConnector, ConfigDrmDevice, ConnectorMatch, DrmDeviceMatch, Mode, Output, OutputMatch,
|
||||||
|
};
|
||||||
pub use theme::Theme;
|
pub use theme::Theme;
|
||||||
|
|
|
||||||
88
jay-config-schema/src/output.rs
Normal file
88
jay-config-schema/src/output.rs
Normal 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>,
|
||||||
|
}
|
||||||
|
|
@ -28,14 +28,13 @@ use {
|
||||||
keyboard::{Keymap, ModifiedKeySym, mods::Modifiers, syms::KeySym},
|
keyboard::{Keymap, ModifiedKeySym, mods::Modifiers, syms::KeySym},
|
||||||
logging::LogLevel,
|
logging::LogLevel,
|
||||||
status::MessageFormat,
|
status::MessageFormat,
|
||||||
video::{BlendSpace, ColorSpace, Eotf, Format, GfxApi, Transform},
|
video::GfxApi,
|
||||||
window::{ContentType, TileState, WindowType},
|
window::{ContentType, TileState, WindowType},
|
||||||
workspace::WorkspaceDisplayOrder,
|
workspace::WorkspaceDisplayOrder,
|
||||||
},
|
},
|
||||||
std::{
|
std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
error::Error,
|
error::Error,
|
||||||
fmt::{Display, Formatter},
|
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
},
|
},
|
||||||
|
|
@ -44,8 +43,9 @@ use {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use jay_config_schema::{
|
pub use jay_config_schema::{
|
||||||
AnimationCurveConfig, Animations, ColorManagement, Float, FocusHistory, Libei, RepeatRate,
|
AnimationCurveConfig, Animations, ColorManagement, ConfigConnector, ConfigDrmDevice,
|
||||||
SimpleIm, Tearing, Theme, UiDrag, Vrr, Xwayland,
|
ConnectorMatch, DrmDeviceMatch, Float, FocusHistory, Libei, Mode, Output, OutputMatch,
|
||||||
|
RepeatRate, SimpleIm, Tearing, Theme, UiDrag, Vrr, Xwayland,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
|
@ -211,18 +211,6 @@ pub struct Status {
|
||||||
pub separator: Option<String>,
|
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)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub struct GenericMatch<Match> {
|
pub struct GenericMatch<Match> {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
|
|
@ -303,62 +291,6 @@ pub struct WindowMatch {
|
||||||
pub content_types: Option<ContentType>,
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum InputMatch {
|
pub enum InputMatch {
|
||||||
Any(Vec<InputMatch>),
|
Any(Vec<InputMatch>),
|
||||||
|
|
@ -405,21 +337,6 @@ pub struct Exec {
|
||||||
pub envs: Vec<(String, String)>,
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum ConfigKeymap {
|
pub enum ConfigKeymap {
|
||||||
Named(String),
|
Named(String),
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
fn apply(&self, d: DrmDevice) {
|
||||||
if let Some(api) = self.gfx_api {
|
if let Some(api) = self.gfx_api {
|
||||||
d.set_gfx_api(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 {
|
fn matches(&self, d: DrmDevice, state: &State) -> bool {
|
||||||
self.matches_(d, state, &mut AHashSet::new())
|
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 {
|
fn matches(&self, c: Connector, state: &State) -> bool {
|
||||||
if !c.connected() {
|
if !c.connected() {
|
||||||
return false;
|
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 {
|
fn matches(&self, c: Connector) -> bool {
|
||||||
if !c.exists() {
|
if !c.exists() {
|
||||||
return false;
|
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) {
|
fn apply(&self, c: Connector) {
|
||||||
c.set_enabled(self.enabled);
|
c.set_enabled(self.enabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Output {
|
trait OutputExt {
|
||||||
|
fn apply(&self, c: Connector);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OutputExt for Output {
|
||||||
fn apply(&self, c: Connector) {
|
fn apply(&self, c: Connector) {
|
||||||
if self.x.is_some() || self.y.is_some() {
|
if self.x.is_some() || self.y.is_some() {
|
||||||
let (old_x, old_y) = c.position();
|
let (old_x, old_y) = c.position();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue