Keep track of scale in connector_disconnected

This commit is contained in:
Ottatop 2024-03-29 13:07:48 -05:00
parent d52192a2ba
commit 15d033d335
3 changed files with 13 additions and 20 deletions

View file

@ -774,25 +774,15 @@ impl tag_service_server::TagService for TagService {
.map(|id| id.0)
.collect::<Vec<_>>();
if let Some(saved_state) = state.config.connector_saved_states.get_mut(&output_name) {
let mut tags = saved_state.tags.clone();
tags.extend(new_tags.clone());
saved_state.tags = tags;
} else {
state.config.connector_saved_states.insert(
output_name.clone(),
crate::config::ConnectorSavedState {
tags: new_tags.clone(),
..Default::default()
},
);
}
state
.config
.connector_saved_states
.entry(output_name.clone())
.or_default()
.tags
.extend(new_tags.clone());
if let Some(output) = state
.space
.outputs()
.find(|output| output.name() == output_name.0)
{
if let Some(output) = output_name.output(state) {
output.with_state_mut(|state| {
state.tags.extend(new_tags.clone());
debug!("tags added, are now {:?}", state.tags);

View file

@ -998,9 +998,9 @@ impl State {
.connector_saved_states
.get(&OutputName(output.name()))
{
let ConnectorSavedState { loc, tags } = saved_state;
let ConnectorSavedState { loc, tags, scale } = saved_state;
output.change_current_state(None, None, None, Some(*loc));
output.change_current_state(None, None, *scale, Some(*loc));
self.space.map_output(&output, *loc);
output.with_state_mut(|state| state.tags = tags.clone());
@ -1050,6 +1050,7 @@ impl State {
ConnectorSavedState {
loc: output.current_location(),
tags: output.with_state(|state| state.tags.clone()),
scale: Some(output.current_scale()),
},
);
self.space.unmap_output(&output);

View file

@ -214,6 +214,8 @@ pub struct ConnectorSavedState {
pub loc: Point<i32, Logical>,
/// The output's previous tags
pub tags: Vec<Tag>,
/// The output's previous scale
pub scale: Option<smithay::output::Scale>,
}
/// Parse a metaconfig file in `config_dir`, if any.