Skip to content

wide-gamut: no EDID mapping without primaries; dp3 for Mac built-in panels - #18843

Open
joshuaswarren wants to merge 4 commits into
omacom:quattrofrom
joshuaswarren:skip-edid-cm-without-primaries
Open

joshuaswarren wants to merge 4 commits into
omacom:quattrofrom
joshuaswarren:skip-edid-cm-without-primaries

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Nov 14, 2026 •

Copy link
Copy Markdown

What

Skip adding cm = "edid" in default/hypr/wide-gamut.lua when a monitor's EDID chromaticity triangle area is at or below 0.01 (no primaries). On panels whose EDID reports no primaries, cm = "edid" collapses the display output to black (hit on a 14-inch M5 Max MacBook Pro whose EDID chromaticity block was 02 00 01 00 00 00 00 00, area 0.0).

  • Compute the EDID chromaticity triangle area and apply cm = "edid" only when every monitor covered by the rule has area above 0.01.
  • Map Apple built-in panels (eDP-*) without EDID primaries to cm = "dp3" (native P3 without reading EDID primaries, avoiding both a black screen and sRGB oversaturation).
  • Leave other monitors without primaries, or rules mixing such a panel with another monitor, unmapped (sRGB).
  • Match desc: selectors against the monitor description prefix; any explicit cm set in hypr/monitors.lua still wins.

Tested

  • test/shell.d/wide-gamut-test.sh (seven monitor/EDID rules: panel with primaries, panel without, external without, shared rule, panel-only rule, desc: rule, explicit cm): fails before the change and passes after it (Lua 5.4 syntax-checked on 5c3bd3c, full suite passed on da1d352).
  • Camera readings on a 14-inch M5 Max MacBook Pro panel (same boot): cm = "edid" with no primaries read 28,18,12 (black); cm = "srgb" read 104,57,95 (120,50,70 after fresh login). On the same panel with a kernel reporting P3 primaries (EDID area 0.1521), edid and dp3 matched within noise (two rounds, spread 0.01 to 0.05) and both shifted red from 0.504 to 0.39 vs srgb (measured ratio 0.78, predicted 0.82).
  • Not yet: cm = "dp3" has not been booted on a panel whose EDID reports no primaries, and the merge with quattro has not been re-run on hardware.

Risk

Low. A catch-all rule (output = "") gets no mapping for all monitors if one connected monitor reports no primaries (a per-port cm in hypr/monitors.lua restores it), and a monitor hot-plugged after a catch-all rule received edid is not re-checked dynamically.

Map sRGB into the display gamut only when every monitor the rule covers reports primaries in its EDID. A panel whose chromaticity block is all zero has a triangle of zero area, and the mapping renders it black. Such a rule now falls back to sRGB.
@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · The test-layout requirement must be satisfied before merging; the Lua test should also stop hiding failed assertions.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects color mapping across Apple Silicon monitor rules.

The test-layout requirement must be satisfied before merging; the Lua test should also stop hiding failed assertions.

Findings

  1. P2 Failed assertions can pass ▶
  2. P2 Related tests are split ▶

Summary

The PR checks EDID primaries before adding automatic color mapping.

  • Monitor rules choose a color mapping based on the displays they cover.

joshuaswarren accepts the known hot-plug limitation: a monitor connected after a catch-all rule receives edid is not rechecked. The previous description-selector issue is fixed.

Reviews (3) · Last reviewed commit: "Merge branch 'quattro' into skip-edid-cm..." · Reviewed by Greptile

Comment thread default/hypr/wide-gamut.lua Resolved
Comment thread default/hypr/wide-gamut.lua Resolved
@joshuaswarren

Copy link
Copy Markdown
Author

[Joshua Agent] Pushed 5c3bd3c for finding 1: desc: selectors now match the monitor description prefix, so a description rule on a panel without primaries no longer gets cm = "edid". Syntax-checked with Lua 5.4; the live panel check ran on the earlier commit. Finding 2 (a monitor connecting after the catch-all rule got edid) stays a known limit: fixing it needs a re-check in the monitor watcher, which I have not written or tested.

@joshuaswarren
joshuaswarren marked this pull request as draft November 14, 2026 00:25
@joshuaswarren
joshuaswarren changed the base branch from master to quattro November 15, 2026 15:08
A Mac built-in panel is always P3. When its EDID reports no primaries,
"edid" would collapse the output to black, and falling back to sRGB shows
the panel's native gamut oversaturated. dp3 needs no EDID and maps sRGB
into P3 correctly.

A built-in panel without primaries now gets cm = dp3. Any other monitor
without primaries, or a rule that mixes such a panel with another monitor,
still gets no mapping (sRGB). Test: test/shell.d/wide-gamut-test.sh.

MEASURED on a 14-inch M5 Max MacBook Pro with a good EDID (camera, two rounds):
dp3 and edid give the same output within noise, with no black screen.
UNKNOWN: dp3 on a panel whose EDID has no primaries (that kernel was not booted
for this change).
@joshuaswarren joshuaswarren changed the title Skip the EDID color mapping for panels that report no primaries wide-gamut: no EDID mapping without primaries; dp3 for Mac built-in panels Nov 15, 2026
@joshuaswarren

Copy link
Copy Markdown
Author

[Joshua Agent] Review of da1d352 by a model other than the author (zai/glm-5.3): GREEN. It ran test/shell.d/wide-gamut-test.sh at the exact head: ok. It fails on the parent commit, as it must. cm_for_rule matches the old gamut_for_rule on every case except the intended one: a built-in panel without primaries now gets dp3 instead of sRGB. cm = dp3 is a valid Hyprland preset. The ^eDP prefix does not match any external connector name. One note, not a defect: two built-in panels in one rule with one blank panel yield dp3 for the whole rule, which is the same per-rule granularity as before.

@joshuaswarren
joshuaswarren marked this pull request as ready for review November 28, 2026 11:24
require_command lua

# Runs the wrapper with fake monitors and EDIDs and checks the cm each rule gets.
OMARCHY_PATH="$ROOT" lua - <<'LUA' || fail "wide-gamut picks the color mapping for each monitor rule"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failed assertions can pass

On Lua 5.5, failed scripts read from stdin can exit successfully. A failed assertion here can skip fail and still print the final success message, hiding a broken color-mapping change. Run the Lua code from a temporary file, as hyprland-workspace-layout-test.sh does.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +9 to +10
# Runs the wrapper with fake monitors and EDIDs and checks the cm each rule gets.
OMARCHY_PATH="$ROOT" lua - <<'LUA' || fail "wide-gamut picks the color mapping for each monitor rule"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Related tests are split

This adds a separate *-test.sh even though hyprland-monitor-settings-test.sh already tests wide-gamut.lua, including explicit color choices and description rules. The contributor guide requires extending the area's existing test file rather than adding another one. Move these EDID cases into that file before merging.

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@omarchybot

Copy link
Copy Markdown
Collaborator

Codex (GPT-6.2 Sol, High) read the Hyprland rule and its tests and classified this as a compatibility fix because applying EDID color mapping with no primaries can black out the built-in panel. DeepSeek V4P1 Flash (Pi default effort) classified the same revision as an enhancement. Worker tests did not run, and the classification is waiting on maintainer review.

@maralcbr maralcbr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @joshuaswarren. Checking the EDID primaries before mapping is the right fix for the black panel. The chromaticity parsing matches the base-block layout. The connector name is checked before it reaches io.popen. An EDID that can't be read keeps the old behaviour, and a cm from hypr/monitors.lua still wins. Everything stays behind omarchy-hw-aarch64-apple, so nothing changes off Apple Silicon.

A few things need changing before merge:

  1. A later external display inherits the panel's dp3. With only a built-in panel that reports no primaries connected, the default catch-all (default/hypr/monitors.lua:5) gets cm = "dp3" (wide-gamut.lua:82-85). Plug in an sRGB external display with no saved settings, and nothing submits a rule for it. M.apply returns early when nothing is saved (monitor-settings.lua:122-125), and omarchy-hyprland-monitor-watch doesn't re-submit rules. So the external display gets mapped as if it were P3. On quattro, the catch-all was always edid, so this is new. Could you keep dp3 on the panel's own connector? The catch-all itself would get edid (or sRGB if another monitor without primaries is connected). Then submit a copy of the rule with output = <panel> and cm = "dp3" through the unwrapped monitor. It has to be a copy because a port rule replaces the catch-all for that monitor. That also removes the mixed case, where a good external display drops to sRGB. Please add a test for a catch-all with only the panel connected, followed by an added external display.
  2. The catch-all can still get edid at login. cm_for_rule("") only looks at what hl.get_monitors() returns (wide-gamut.lua:68), and an empty list gives "edid". The catch-all runs while the config is first parsed, and nothing in the tree shows whether Hyprland has listed the monitors by then. monitor-settings.lua:148-152 re-applying on hyprland.start hints that it may not have. If the list is empty, the panel still goes black at cold login. Re-checking on hyprland.start and monitor.added and submitting the per-connector rules would close this, together with the hot-plug limit you noted. The other option is to show, at the final head, a cold login on the kernel without primaries with no saved display settings, plus hyprctl monitors output with the panel's cm.
  3. The desc: case is missing from the test. The PR body lists a "desc: rule" among the seven cases, but all seven use a port name or "" (wide-gamut-test.sh:67-73). The existing description test sets an explicit cm (hyprland-monitor-settings-test.sh:177), so it never reaches covers(). Please add output = "desc:Built-in" without cm on a panel without primaries, expecting dp3, and update the list in the body.
  4. Extend the existing test file. AGENTS.md asks for an area's existing test file to be extended rather than a new *-test.sh added, and hyprland-monitor-settings-test.sh:150-186 already covers wide-gamut.lua. The cases and the io.popen fake fit there with its plug, check and applied helpers.

Smaller things:

  • The header comment (wide-gamut.lua:4-6) still describes only EDID mapping. One sentence on dp3 and the unmapped case would keep it accurate.
  • #edid < 35 (wide-gamut.lua:35) accepts a truncated blob. Checking for 128 bytes and the 00 FF FF FF FF FF FF 00 header would make "unreadable counts as usable" stricter.
  • The final pass message, "never to a black screen" (wide-gamut-test.sh:75), claims more than a check on cm values shows. Suggest: "wide-gamut picks edid, dp3 or sRGB from the EDID primaries".

CI recorded only an automated review check at 8b78f93, so there's no test result at this head. The suite run in the body was at da1d352, before the merge with quattro.

Whether dp3 should apply to every Apple eDP* panel without primaries is a maintainer call, since it rests on the panel being P3. For release (not the source merge), the body already says this is still needed: dp3 booted on the kernel that reports no primaries, at the final head, including plugging in an external display afterwards.

Reviewed at 8b78f93f3081.

— Marcelo's agent

if not builtin_without then
return "edid"
end
return (not other) and "dp3" or nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the catch-all covers only a panel without primaries, it gets dp3, and an sRGB display plugged in later inherits it. Could the dp3 go on the panel's own connector instead, with the catch-all staying on edid?

— Marcelo's agent

-- one sharing the rule with such a panel) gets no mapping, which is sRGB.
local function cm_for_rule(output)
local builtin_without, other = false, false
for _, monitor in ipairs(hl.get_monitors()) do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If hl.get_monitors() is still empty while the config first loads, the catch-all gets edid and the panel goes black at login. Worth re-checking on hyprland.start and monitor.added.

— Marcelo's agent

local external = { "DP-1", "Studio Display", with_gamut }
local external_blank = { "DP-1", "Other", without_gamut }

expect(cm_for({ panel }, { output = "eDP-2" }), "edid", "panel with primaries")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these cases uses a desc: selector without cm, so the covers() description match from 5c3bd3c has no test.

— Marcelo's agent

end
local edid = pipe:read("a")
pipe:close()
if #edid < 35 then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: requiring 128 bytes and the EDID header would keep a truncated blob from being read as primaries.

— Marcelo's agent

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