refactor(output config): move to config crate

this allows the greeter to easily sync to the user config
This commit is contained in:
Ashley Wulber 2025-08-19 16:51:37 -04:00 committed by Ashley Wulber
parent 4a385d5535
commit 416b66b776
17 changed files with 283 additions and 194 deletions

View file

@ -5,13 +5,14 @@ use crate::{
kms::render::gles::GbmGlowBackend,
render::{init_shaders, output_elements, CursorMode, GlMultiRenderer, CLEAR_COLOR},
},
config::{AdaptiveSync, EdidProduct, OutputConfig, OutputState, ScreenFilter},
config::{CompTransformDef, EdidProduct, ScreenFilter},
shell::Shell,
utils::{env::dev_list_var, prelude::*},
wayland::handlers::screencopy::PendingImageCopyData,
};
use anyhow::{Context, Result};
use cosmic_comp_config::output::{AdaptiveSync, OutputConfig, OutputState};
use libc::dev_t;
use smithay::{
backend::{
@ -1008,7 +1009,7 @@ fn populate_modes(
position,
max_bpc,
scale,
transform,
transform: CompTransformDef::from(transform).0,
// Try opportunistic VRR by default,
// if not supported this will be turned off on `resume`,
// when we have the `Surface` to actually check for support.

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::{
config::{AdaptiveSync, OutputState, ScreenFilter},
config::{CompOutputConfig, ScreenFilter},
shell::Shell,
state::BackendData,
utils::{env::dev_var, prelude::*},
@ -9,6 +9,7 @@ use crate::{
use anyhow::{Context, Result};
use calloop::LoopSignal;
use cosmic_comp_config::output::{AdaptiveSync, OutputState};
use indexmap::IndexMap;
use render::gles::GbmGlowBackend;
use smithay::{
@ -798,7 +799,7 @@ impl<'a> KmsGuard<'a> {
// reconfigure existing
for (crtc, surface) in device.inner.surfaces.iter_mut() {
let output_config = surface.output.config();
let output_config = CompOutputConfig(surface.output.config());
let drm = &mut device.drm;
let conn = surface.connector;
@ -814,7 +815,7 @@ impl<'a> KmsGuard<'a> {
// and then select the closest refresh rate (e.g. to match 59.98 as 60)
.min_by_key(|mode| {
let refresh_rate = drm_helpers::calculate_refresh_rate(**mode);
(output_config.mode.1.unwrap() as i32 - refresh_rate as i32).abs()
(output_config.0.mode.1.unwrap() as i32 - refresh_rate as i32).abs()
})
.ok_or(anyhow::anyhow!("Unable to find matching mode"))?;
@ -876,7 +877,7 @@ impl<'a> KmsGuard<'a> {
compositor
};
if let Some(bpc) = output_config.max_bpc {
if let Some(bpc) = output_config.0.max_bpc {
if let Err(err) = drm_helpers::set_max_bpc(drm.device(), conn, bpc) {
warn!(
?bpc,
@ -887,7 +888,7 @@ impl<'a> KmsGuard<'a> {
}
}
let vrr = output_config.vrr;
let vrr = output_config.0.vrr;
std::mem::drop(output_config);
let compositor_ref = drm.compositors().get(crtc).unwrap().lock().unwrap();
@ -928,7 +929,7 @@ impl<'a> KmsGuard<'a> {
surface.output.set_adaptive_sync(AdaptiveSync::Disabled);
}
} else {
let vrr = output_config.vrr;
let vrr = output_config.0.vrr;
std::mem::drop(output_config);
if vrr != surface.output.adaptive_sync() {
if match surface.output.adaptive_sync_support() {
@ -1030,7 +1031,7 @@ impl<'a> KmsGuard<'a> {
Some(
all_outputs
.iter()
.find(|output| &output.name() == conn)
.find(|output| output.name() == *conn)
.cloned()
.ok_or(anyhow::anyhow!("Unable to find mirroring output"))?,
)

View file

@ -6,7 +6,7 @@ use crate::{
init_shaders, output_elements, CursorMode, GlMultiError, GlMultiRenderer,
PostprocessOutputConfig, PostprocessShader, PostprocessState, CLEAR_COLOR,
},
config::{AdaptiveSync, ScreenFilter},
config::ScreenFilter,
shell::Shell,
state::SurfaceDmabufFeedback,
utils::prelude::*,
@ -23,6 +23,7 @@ use crate::{
use anyhow::{Context, Result};
use calloop::channel::Channel;
use cosmic_comp_config::output::AdaptiveSync;
use smithay::{
backend::{
allocator::{

View file

@ -2,12 +2,13 @@
use crate::{
backend::render,
config::{OutputConfig, ScreenFilter},
config::ScreenFilter,
shell::{Devices, SeatExt},
state::{BackendData, Common},
utils::prelude::*,
};
use anyhow::{anyhow, Context, Result};
use cosmic_comp_config::output::{OutputConfig, TransformDef};
use smithay::{
backend::{
drm::NodeType,
@ -167,7 +168,7 @@ pub fn init_backend(
output.user_data().insert_if_missing(|| {
RefCell::new(OutputConfig {
mode: ((size.w, size.h), None),
transform: Transform::Flipped180.into(),
transform: TransformDef::Flipped180,
..Default::default()
})
});

View file

@ -2,12 +2,13 @@
use crate::{
backend::render,
config::{OutputConfig, ScreenFilter},
config::ScreenFilter,
shell::{Devices, SeatExt},
state::{BackendData, Common},
utils::prelude::*,
};
use anyhow::{anyhow, Context, Result};
use cosmic_comp_config::output::OutputConfig;
use smithay::{
backend::{
allocator::{