Skip to content

Fix: Display Output config being applied to wrong output#2020

Closed
stoorps wants to merge 2 commits intopop-os:masterfrom
stoorps:output-serial-matching
Closed

Fix: Display Output config being applied to wrong output#2020
stoorps wants to merge 2 commits intopop-os:masterfrom
stoorps:output-serial-matching

Conversation

@stoorps
Copy link

@stoorps stoorps commented Jan 23, 2026

Problem

Displays of the same make & model can confuse cosmic-randr & cosmic-comp, leading to the wrong configuration being applied. This presents as one display's rotation, scaling, position, etc. being applied to another. This occurs (at least in my experience) on ~50% of boots & re-connections of outputs.

Cause

The order of Display adapters is not guaranteed upon boot/connection, and therefore the names that are derived from this order (eg. DP-1 or HDMI-2) are not actually tied to a physical port, and can switch.

Solution

When restoring configuration from KDL, try to match via output.serial_number first, and fallback to name matching if serials are not present.

Changes

  • Add serial_number to outputs.ron configuration
  • Backwards compatibility & upgrade for old outputs.ron files

Dependencies

Test Plan

  • Builds successfully (with cosmic-randr on branch serial-number)
  • Old outputs.ron file is successfully migrated
  • Displays always configure correctly on boot (10/10 tries)
  • Displays always configure correctly on re-connection

Outstanding Decisions

There is a decision to make around backwards compatibility. Do we:

  1. Support old outputs.ron files, meaning that users facing this issue will have to change/delete their display config for the fix to have any effect
  2. Break compatibility and regenerate a default configuration, forcing all users to reconfigure their displays.

I have opted for option 1 at the moment (see suggestion in mod.rs), but will defer to maintainers to make the final decision.

Comment on lines +422 to +439
// 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;
}
}
Copy link
Author

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.

Comment on lines +549 to +555

// 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);
}
Copy link
Author

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.

@stoorps stoorps marked this pull request as ready for review January 23, 2026 22:51
@stoorps stoorps changed the title Displays: Support Serial Numbers for reliable config Fix: Display Output config being applied to wrong output Jan 23, 2026
@ids1024
Copy link
Member

ids1024 commented Jan 26, 2026

try to match via output.serial_number first, and fallback to name matching if serials are not present.

I have a pair of Viewsonic monitors that report the same serial number, but can be distinguished by manufacture date. So I don't think comparing just serial number will work. We should compare all the EDID info.

We already have an EdidProduct type in cosmic-comp that is used to determine which output a workspace belongs to (when monitors are removed and re-attached), and is persisted for pinned outputs. We probably want to use that in the output configuration as well.

(KDE, for comparison, just MD5 hashes the whole EDID data, and compares that, which serves the same purpose.)

@hojjatabdollahi
Copy link
Contributor

@ids1024 my PR also is trying to solve this problem, and it uses the whole EDID. Would you mind taking a look:
#1988

@stoorps
Copy link
Author

stoorps commented Jan 26, 2026

Apologies @hojjatabdollahi! I didn't see your PR otherwise I wouldn't have submitted mine.

@ids1024 That is a strange thing for them to do, it kind of defeats the purpose of a serial 😆

I'll close this and my cosmic-randr change down now. I'm on the popos mattermost under the same user if you want anything :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants