kms: Correctly apply disabled confs
This commit is contained in:
parent
544acecd2e
commit
bca72a9b0e
5 changed files with 43 additions and 62 deletions
|
|
@ -25,7 +25,6 @@ use smithay::{
|
|||
libinput::{LibinputInputBackend, LibinputSessionInterface},
|
||||
renderer::{
|
||||
damage::DamageTrackedRenderer,
|
||||
element::RenderElementStates,
|
||||
gles2::{Gles2Renderbuffer, Gles2Renderer},
|
||||
multigpu::{egl::EglGlesBackend, GpuManager},
|
||||
Bind,
|
||||
|
|
@ -246,20 +245,13 @@ pub fn init_backend(
|
|||
}
|
||||
}
|
||||
}
|
||||
data.state.common.output_configuration_state.update();
|
||||
|
||||
data.state.common.config.read_outputs(
|
||||
data.state.common.output_configuration_state.outputs(),
|
||||
&mut data.state.common.output_configuration_state,
|
||||
&mut data.state.backend,
|
||||
&mut data.state.common.shell,
|
||||
&data.state.common.event_loop_handle,
|
||||
);
|
||||
data.state.common.shell.refresh_outputs();
|
||||
data.state
|
||||
.common
|
||||
.config
|
||||
.write_outputs(data.state.common.output_configuration_state.outputs());
|
||||
|
||||
for surface in data
|
||||
.state
|
||||
.backend
|
||||
|
|
@ -473,27 +465,12 @@ impl State {
|
|||
self.common
|
||||
.output_configuration_state
|
||||
.add_heads(wl_outputs.iter());
|
||||
self.common.output_configuration_state.update();
|
||||
for output in wl_outputs {
|
||||
if let Err(err) = self.backend.kms().apply_config_for_output(
|
||||
&output,
|
||||
&mut self.common.shell,
|
||||
false,
|
||||
&self.common.event_loop_handle,
|
||||
) {
|
||||
slog_scope::warn!("Failed to initialize output: {}", err);
|
||||
}
|
||||
}
|
||||
self.common.config.read_outputs(
|
||||
self.common.output_configuration_state.outputs(),
|
||||
&mut self.common.output_configuration_state,
|
||||
&mut self.backend,
|
||||
&mut self.common.shell,
|
||||
&self.common.event_loop_handle,
|
||||
);
|
||||
self.common.shell.refresh_outputs();
|
||||
self.common
|
||||
.config
|
||||
.write_outputs(self.common.output_configuration_state.outputs());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -541,30 +518,15 @@ impl State {
|
|||
self.common
|
||||
.output_configuration_state
|
||||
.add_heads(outputs_added.iter());
|
||||
for output in outputs_added {
|
||||
if let Err(err) = self.backend.kms().apply_config_for_output(
|
||||
&output,
|
||||
&mut self.common.shell,
|
||||
false,
|
||||
&self.common.event_loop_handle,
|
||||
) {
|
||||
slog_scope::warn!("Failed to initialize output: {}", err);
|
||||
}
|
||||
}
|
||||
for output in outputs_removed {
|
||||
self.common.shell.remove_output(&output);
|
||||
}
|
||||
self.common.output_configuration_state.update();
|
||||
self.common.config.read_outputs(
|
||||
self.common.output_configuration_state.outputs(),
|
||||
&mut self.common.output_configuration_state,
|
||||
&mut self.backend,
|
||||
&mut self.common.shell,
|
||||
&self.common.event_loop_handle,
|
||||
);
|
||||
self.common.shell.refresh_outputs();
|
||||
self.common
|
||||
.config
|
||||
.write_outputs(self.common.output_configuration_state.outputs());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -593,22 +555,19 @@ impl State {
|
|||
self.common
|
||||
.output_configuration_state
|
||||
.remove_heads(outputs_removed.iter());
|
||||
self.common.output_configuration_state.update();
|
||||
|
||||
if self.backend.kms().session.is_active() {
|
||||
for output in outputs_removed {
|
||||
self.common.shell.remove_output(&output);
|
||||
}
|
||||
self.common.config.read_outputs(
|
||||
self.common.output_configuration_state.outputs(),
|
||||
&mut self.common.output_configuration_state,
|
||||
&mut self.backend,
|
||||
&mut self.common.shell,
|
||||
&self.common.event_loop_handle,
|
||||
);
|
||||
self.common.shell.refresh_outputs();
|
||||
self.common
|
||||
.config
|
||||
.write_outputs(self.common.output_configuration_state.outputs());
|
||||
} else {
|
||||
self.common.output_configuration_state.update();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
@ -858,10 +817,11 @@ impl KmsState {
|
|||
|
||||
if !output_config.enabled {
|
||||
if !test_only {
|
||||
shell.remove_output(output);
|
||||
if surface.surface.take().is_some() {
|
||||
// just drop it
|
||||
shell.remove_output(output);
|
||||
surface.pending = false;
|
||||
surface.dirty = false;
|
||||
}
|
||||
}
|
||||
false
|
||||
|
|
@ -885,7 +845,7 @@ impl KmsState {
|
|||
.ok_or(anyhow::anyhow!("Unknown mode"))?;
|
||||
|
||||
if !test_only {
|
||||
if let Some(gbm_surface) = surface.surface.as_mut() {
|
||||
let res = if let Some(gbm_surface) = surface.surface.as_mut() {
|
||||
if output_config.vrr != surface.vrr {
|
||||
surface.vrr = drm_helpers::set_vrr(
|
||||
drm,
|
||||
|
|
@ -917,9 +877,10 @@ impl KmsState {
|
|||
)
|
||||
})?;
|
||||
surface.surface = Some(target);
|
||||
shell.add_output(output);
|
||||
true
|
||||
}
|
||||
};
|
||||
shell.add_output(output);
|
||||
res
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,16 +213,13 @@ pub fn init_backend(
|
|||
.common
|
||||
.output_configuration_state
|
||||
.add_heads(std::iter::once(&output));
|
||||
state.common.output_configuration_state.update();
|
||||
state.common.shell.add_output(&output);
|
||||
state.common.config.read_outputs(
|
||||
std::iter::once(&output),
|
||||
&mut state.common.output_configuration_state,
|
||||
&mut state.backend,
|
||||
&mut state.common.shell,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
state.common.shell.refresh_outputs();
|
||||
state.common.config.write_outputs(std::iter::once(&output));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,16 +287,13 @@ pub fn init_backend(
|
|||
.common
|
||||
.output_configuration_state
|
||||
.add_heads(std::iter::once(&output));
|
||||
state.common.output_configuration_state.update();
|
||||
state.common.shell.add_output(&output);
|
||||
state.common.config.read_outputs(
|
||||
std::iter::once(&output),
|
||||
&mut state.common.output_configuration_state,
|
||||
&mut state.backend,
|
||||
&mut state.common.shell,
|
||||
&state.common.event_loop_handle,
|
||||
);
|
||||
state.common.shell.refresh_outputs();
|
||||
state.common.config.write_outputs(std::iter::once(&output));
|
||||
|
||||
event_loop
|
||||
.handle()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
use crate::{
|
||||
shell::{focus::FocusDirection, layout::tiling::Direction, Shell, WorkspaceAmount},
|
||||
state::{BackendData, Data},
|
||||
state::{BackendData, Data, State},
|
||||
wayland::protocols::output_configuration::OutputConfigurationState,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
pub use smithay::{
|
||||
|
|
@ -278,12 +279,12 @@ impl Config {
|
|||
|
||||
pub fn read_outputs(
|
||||
&mut self,
|
||||
outputs: impl Iterator<Item = impl std::borrow::Borrow<Output>>,
|
||||
output_state: &mut OutputConfigurationState<State>,
|
||||
backend: &mut BackendData,
|
||||
shell: &mut Shell,
|
||||
loop_handle: &LoopHandle<'_, Data>,
|
||||
) {
|
||||
let outputs = outputs.map(|x| x.borrow().clone()).collect::<Vec<_>>();
|
||||
let outputs = output_state.outputs().collect::<Vec<_>>();
|
||||
let mut infos = outputs
|
||||
.iter()
|
||||
.cloned()
|
||||
|
|
@ -307,6 +308,7 @@ impl Config {
|
|||
for (name, output_config) in infos.iter().map(|o| &o.connector).zip(configs.into_iter())
|
||||
{
|
||||
let output = outputs.iter().find(|o| &o.name() == name).unwrap().clone();
|
||||
let enabled = output_config.enabled;
|
||||
*output
|
||||
.user_data()
|
||||
.get::<RefCell<OutputConfig>>()
|
||||
|
|
@ -322,6 +324,12 @@ impl Config {
|
|||
);
|
||||
reset = true;
|
||||
break;
|
||||
} else {
|
||||
if enabled {
|
||||
output_state.enable_head(&output);
|
||||
} else {
|
||||
output_state.disable_head(&output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -331,6 +339,7 @@ impl Config {
|
|||
.into_iter()
|
||||
.zip(known_good_configs.into_iter())
|
||||
{
|
||||
let enabled = output_config.enabled;
|
||||
*output
|
||||
.user_data()
|
||||
.get::<RefCell<OutputConfig>>()
|
||||
|
|
@ -344,9 +353,18 @@ impl Config {
|
|||
output.name(),
|
||||
err
|
||||
);
|
||||
} else {
|
||||
if enabled {
|
||||
output_state.enable_head(&output);
|
||||
} else {
|
||||
output_state.disable_head(&output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output_state.update();
|
||||
self.write_outputs(output_state.outputs());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -421,6 +421,10 @@ impl Shell {
|
|||
}
|
||||
|
||||
pub fn add_output(&mut self, output: &Output) {
|
||||
if self.outputs.contains(output) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.outputs.push(output.clone());
|
||||
let mut state = self.workspace_state.update();
|
||||
|
||||
|
|
@ -445,6 +449,10 @@ impl Shell {
|
|||
}
|
||||
|
||||
pub fn remove_output(&mut self, output: &Output) {
|
||||
if !self.outputs.contains(output) {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut state = self.workspace_state.update();
|
||||
self.outputs.retain(|o| o != output);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue