-
Notifications
You must be signed in to change notification settings - Fork 215
Fix: Display Output config being applied to wrong output #2020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -417,11 +417,28 @@ impl Config { | |
| .collect::<Vec<_>>(); | ||
| infos.sort(); | ||
|
|
||
| if let Some(configs) = self | ||
| .dynamic_conf | ||
| .outputs() | ||
| .config | ||
| .get(&infos) | ||
| let outputs_config = self.dynamic_conf.outputs(); | ||
|
|
||
| // Backward-compatible lookup: older `outputs.ron` files won't have `serial_number`. | ||
| // If a strict match fails, retry with serial numbers ignored. | ||
| // This prevents bricking a users config and resetting to default. | ||
| let mut used_fallback_key = false; | ||
| let mut infos_key = infos.clone(); | ||
| let mut configs_ref_opt = outputs_config.config.get(&infos); | ||
| if configs_ref_opt.is_none() { | ||
| let mut infos_no_serial = infos.clone(); | ||
| for info in &mut infos_no_serial { | ||
| info.serial_number = None; | ||
| } | ||
| infos_no_serial.sort(); | ||
| if let Some(cfgs) = outputs_config.config.get(&infos_no_serial) { | ||
| infos_key = infos_no_serial; | ||
| configs_ref_opt = Some(cfgs); | ||
| used_fallback_key = true; | ||
| } | ||
| } | ||
|
|
||
| if let Some(configs) = configs_ref_opt | ||
| .filter(|configs| { | ||
| if configs | ||
| .iter() | ||
|
|
@@ -453,7 +470,10 @@ impl Config { | |
| .collect::<Vec<_>>(); | ||
|
|
||
| let mut found_outputs = Vec::new(); | ||
| for (name, output_config) in infos.iter().map(|o| &o.connector).zip(configs.into_iter()) | ||
| for (name, output_config) in infos_key | ||
| .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.clone(); | ||
|
|
@@ -466,6 +486,7 @@ impl Config { | |
| } | ||
|
|
||
| let mut backend = backend.lock(); | ||
| let mut applied_config_ok = false; | ||
| if let Err(err) = backend.apply_config_for_outputs( | ||
| false, | ||
| loop_handle, | ||
|
|
@@ -513,6 +534,7 @@ impl Config { | |
| } | ||
| } | ||
| } else { | ||
| applied_config_ok = true; | ||
| for (output, enabled) in found_outputs { | ||
| if enabled == OutputState::Enabled { | ||
| output_state.enable_head(&output); | ||
|
|
@@ -524,6 +546,13 @@ impl Config { | |
|
|
||
| output_state.update(); | ||
| self.write_outputs(output_state.outputs()); | ||
|
|
||
| // One-time migration: if we only found a config by ignoring serial numbers, | ||
| // persist the now-known serial-aware key and remove the old key. | ||
| if used_fallback_key && applied_config_ok { | ||
| let mut outputs_mut = self.dynamic_conf.outputs_mut(); | ||
| outputs_mut.config.remove(&infos_key); | ||
| } | ||
|
Comment on lines
+549
to
+555
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional backwards compatibility. Can be removed and a default display configuration will be created. |
||
| } else { | ||
| if outputs | ||
| .iter() | ||
|
|
@@ -963,10 +992,15 @@ pub struct CompOutputInfo(OutputInfo); | |
| impl From<Output> for CompOutputInfo { | ||
| fn from(o: Output) -> CompOutputInfo { | ||
| let physical = o.physical_properties(); | ||
| let serial_number = match physical.serial_number.as_str().trim() { | ||
| "" | "Unknown" => None, | ||
| s => Some(s.to_string()), | ||
| }; | ||
| CompOutputInfo(OutputInfo { | ||
| connector: o.name(), | ||
| make: physical.make, | ||
| model: physical.model, | ||
| serial_number, | ||
| }) | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional backwards compatibility. Can be removed and a default display configuration will be created.