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

View file

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

View file

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