Skip to content

[PowerDisplay] Add HDR SDR brightness controls and shortcuts - #49479

Closed
Gavin 北稱 (gavinzhangth) wants to merge 1 commit into
microsoft:mainfrom
gavinzhangth:feature/power-display-hdr-sdr-controls
Closed

[PowerDisplay] Add HDR SDR brightness controls and shortcuts#49479
Gavin 北稱 (gavinzhangth) wants to merge 1 commit into
microsoft:mainfrom
gavinzhangth:feature/power-display-hdr-sdr-controls

Conversation

@gavinzhangth

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Adds HDR-aware SDR content brightness controls and configurable adjustment shortcuts to Power Display.

  • Detects active HDR per display and exposes the Windows SDR content brightness level separately from the physical monitor backlight.
  • Adds an optional SDR Replaces Primary Slider setting so the main and linked brightness controls target SDR content brightness while HDR is active.
  • Adds user-bindable increase/decrease shortcuts for brightness, contrast, display volume, and SDR content brightness.
  • Uses the existing adjustment increment for both mouse-wheel and shortcut changes.
  • Keeps new shortcut fields unbound and the SDR primary-slider preference disabled by default for settings compatibility.

PR Checklist

  • Closes: [PowerDisplay] Add HDR SDR content brightness controls and adjustment shortcuts #49478
  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all relevant tests pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Not applicable; this PR adds no executables, DLL projects, or external dependencies
  • Documentation updated: No public documentation change is included

Detailed Description of the Pull Request / Additional comments

Power Display currently controls monitor hardware brightness through WMI or DDC/CI. On an HDR desktop, Windows has a separate SDR reference-white control that changes how ordinary SDR content is presented without changing the physical backlight or HDR highlights.

This change:

  1. Extends the DisplayConfig inventory with Advanced Color state and SDR white-level queries.
    • Windows 11 Advanced Color v2 state distinguishes active HDR from WCG.
    • The legacy Advanced Color query remains as a fallback.
    • The SDR control is only surfaced when HDR is active and the current white level can be read.
  2. Maps the Windows SDR white-level range (10006000) to the flyout's 0100 slider.
  3. Adds an SDR-labeled flyout row and an optional setting that replaces each HDR display's primary brightness target with SDR content brightness.
  4. Routes linked brightness and ordinary brightness shortcuts through the same primary-target selection, including mixed HDR/SDR multi-monitor setups.
  5. Registers eight optional in-process adjustment hotkeys and includes them in Settings conflict discovery and the dashboard when bound.

Compatibility boundary

The Windows SDK publicly exposes the SDR white-level getter but not a corresponding setter. The write path uses the private DisplayConfigSetDeviceInfo request type used by Windows Settings (0xFFFFFFEE). It is isolated in HdrSdrBrightnessController, capability-gated by successful public state/read queries, and returns a normal failed monitor operation if Windows or a display driver rejects it.

The new settings fields are optional and constructor-defaulted, so existing settings.json files deserialize without migration.

No new third-party dependencies, binaries, GPO behavior, elevation behavior, installer changes, or Runner/Settings IPC contracts are introduced.

Validation Steps Performed

  • Ran the repository XamlStyler against both modified XAML files.
  • Built PowerDisplay.csproj, x64 Debug, with the repository build script.
  • Built PowerToys.Settings.csproj, x64 Debug, with the repository build script.
  • Built PowerDisplay.Lib.UnitTests.csproj, x64 Debug.
  • Ran 14 focused SDR conversion and settings/shortcut serialization tests: 14 passed.
  • Ran the complete Power Display library test assembly: 196 passed / 199 total. The three failures are existing crash-recovery tests that require the PowerToys.Interop.Constants COM class to be registered in standalone VSTest (REGDB_E_CLASSNOTREG).
  • Manually validated on an HDR display:
    • SDR content brightness changes affect SDR content.
    • The SDR label renders without clipping.
    • HDR-off capability gating hides the control.
    • SDR Replaces Primary Slider routes the main slider as expected.
    • Adjustment shortcuts work while the flyout is hidden.
    • Power Display starts successfully after the XAML layout change.

Local builds used /p:SpectreMitigation=false because the local Visual Studio installation does not include the Spectre-mitigated libraries, and suppressed an existing unrelated C4819 warning from the ZoomIt header.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@gavinzhangth
Gavin 北稱 (gavinzhangth) marked this pull request as ready for review July 24, 2026 05:17
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@gavinzhangth

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

/// Private device-info request used by the Windows HDR settings page to commit the
/// SDR content brightness value. This is deliberately isolated behind capability checks.
/// </summary>
public const uint DisplayconfigDeviceInfoSetSdrWhiteLevel = 0xFFFFFFEE;

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.

/// The associated device-info type is private, so callers must capability-gate failures.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct DisplayConfigSetSdrWhiteLevel

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.

Any document provide this structure? or give any evidence?

public struct DisplayConfigSdrWhiteLevel
{
public DisplayConfigDeviceInfoHeader Header;
public uint SdrWhiteLevel;

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.

No document here. seems.

@moooyo moooyo left a comment

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.

ok, seems it will use some undocumented API. Niels Laute (@niels9001) any suggestion?

@niels9001

Copy link
Copy Markdown
Collaborator

ok, seems it will use some undocumented API. Niels Laute (@niels9001) any suggestion?

moooyo We can't use undocumented APIs. Is this something we could integrate into the CI so it scans for unofficial/undocumented APIs in case we are not doing that already?

@moooyo

moooyo commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Close this PR due to undocumented API usage.

@moooyo moooyo closed this Jul 27, 2026
@moooyo

moooyo commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

ok, seems it will use some undocumented API. Niels Laute (@niels9001) any suggestion?

moooyo We can't use undocumented APIs. Is this something we could integrate into the CI so it scans for unofficial/undocumented APIs in case we are not doing that already?

will investigate. But seems no any same pattern can help us to use.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PowerDisplay] Add HDR SDR content brightness controls and adjustment shortcuts

3 participants