Repository navigation
wide-gamut: no EDID mapping without primaries; dp3 for Mac built-in panels - #18843
joshuaswarren wants to merge 4 commits into
Conversation
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.
[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. FindingsSummaryThe PR checks EDID primaries before adding automatic color mapping.
joshuaswarren accepts the known hot-plug limitation: a monitor connected after a catch-all rule receives Reviews (3) · Last reviewed commit: "Merge branch 'quattro' into skip-edid-cm..." · Reviewed by Greptile |
|
[Joshua Agent] Pushed 5c3bd3c for finding 1: |
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).
|
[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. |
| 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" |
There was a problem hiding this comment.
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!
| # 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" |
There was a problem hiding this comment.
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!
|
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
left a comment
There was a problem hiding this comment.
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:
- 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) getscm = "dp3"(wide-gamut.lua:82-85). Plug in an sRGB external display with no saved settings, and nothing submits a rule for it.M.applyreturns early when nothing is saved (monitor-settings.lua:122-125), andomarchy-hyprland-monitor-watchdoesn't re-submit rules. So the external display gets mapped as if it were P3. Onquattro, the catch-all was alwaysedid, so this is new. Could you keepdp3on the panel's own connector? The catch-all itself would getedid(or sRGB if another monitor without primaries is connected). Then submit a copy of the rule withoutput = <panel>andcm = "dp3"through the unwrappedmonitor. 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. - The catch-all can still get
edidat login.cm_for_rule("")only looks at whathl.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-152re-applying onhyprland.starthints that it may not have. If the list is empty, the panel still goes black at cold login. Re-checking onhyprland.startandmonitor.addedand 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, plushyprctl monitorsoutput with the panel'scm. - 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 explicitcm(hyprland-monitor-settings-test.sh:177), so it never reachescovers(). Please addoutput = "desc:Built-in"withoutcmon a panel without primaries, expectingdp3, and update the list in the body. - Extend the existing test file.
AGENTS.mdasks for an area's existing test file to be extended rather than a new*-test.shadded, andhyprland-monitor-settings-test.sh:150-186already coverswide-gamut.lua. The cases and theio.popenfake fit there with itsplug,checkandappliedhelpers.
Smaller things:
- The header comment (
wide-gamut.lua:4-6) still describes only EDID mapping. One sentence ondp3and the unmapped case would keep it accurate. #edid < 35(wide-gamut.lua:35) accepts a truncated blob. Checking for 128 bytes and the00 FF FF FF FF FF FF 00header 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 oncmvalues 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
nit: requiring 128 bytes and the EDID header would keep a truncated blob from being read as primaries.
— Marcelo's agent
What
Skip adding
cm = "edid"indefault/hypr/wide-gamut.luawhen a monitor's EDID chromaticity triangle area is at or below0.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 was02 00 01 00 00 00 00 00, area0.0).cm = "edid"only when every monitor covered by the rule has area above0.01.eDP-*) without EDID primaries tocm = "dp3"(native P3 without reading EDID primaries, avoiding both a black screen and sRGB oversaturation).desc:selectors against the monitor description prefix; any explicitcmset inhypr/monitors.luastill 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, explicitcm): fails before the change and passes after it (Lua 5.4 syntax-checked on5c3bd3c, full suite passed onda1d352).cm = "edid"with no primaries read28,18,12(black);cm = "srgb"read104,57,95(120,50,70after fresh login). On the same panel with a kernel reporting P3 primaries (EDID area0.1521),edidanddp3matched within noise (two rounds, spread0.01to0.05) and both shifted red from0.504to0.39vssrgb(measured ratio0.78, predicted0.82).cm = "dp3"has not been booted on a panel whose EDID reports no primaries, and the merge withquattrohas 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-portcminhypr/monitors.luarestores it), and a monitor hot-plugged after a catch-all rule receivededidis not re-checked dynamically.