Skip to content

[PowerDisplay] Allow waking a monitor from standby via power-state On - #48628

Merged
Yu Leng (moooyo) merged 1 commit into
mainfrom
yuleng/pd/f/11
Jun 15, 2026
Merged

Yu Leng (moooyo) merged 1 commit into
mainfrom
yuleng/pd/f/11

Conversation

@moooyo

@moooyo Yu Leng (moooyo) commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Power Display could put a monitor to sleep but never wake it back up. Selecting On in the per-monitor power-state list was a hard-coded no-op, so the DDC/CI wake command (VCP 0xD6 = 0x01) was never sent. This removes that guard so selecting On wakes the display, and cleans up the dead code/comment left behind by the original one-directional design.

PR Checklist

  • 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 pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

MonitorViewModel.HandlePowerStateSelectionChanged early-returned when the selected power state was On (0x01), so SetPowerStateAsync was never called for On and the wake write never reached the monitor. As a result Power Display's power control was one-directional: it could send Standby/Suspend/Off but could never turn a monitor back on.

The guard dates back to the very first power-state commit and was paired with a single-monitor assumption — "the monitor must be on to see the UI", so On was treated as the always-current state and skipped. A later change made the selection reflect the monitor's real power state (so a monitor in the list can legitimately be asleep), and multi-monitor support means the flyout can be shown on monitor A while the user wants to wake monitor B. Those changes invalidated the assumption, but the action-side guard survived a subsequent refactor.

The lower layers already do the right thing: MonitorManager.SetPowerStateAsync → DdcCiController.SetPowerStateAsync → SetVcpFeatureAsync(monitor, 0xD6, value) passes the value through unchanged, so the fix is purely removing the UI-layer guard. DDC/CI stays reachable while the panel is in Standby/Suspend/Off(DPM), so writing 0x01 turns it back on (this is the same mechanism Twinkle Tray uses). Off (Hard) / 0x05 may still require a physical wake on some monitors, since that state can cut the DDC command channel.

Cleanup included in this PR:

  • Removed the now-unused PowerStateItem.PowerStateOn constant (its only consumer was the deleted guard).
  • Removed the dead SetPowerState [RelayCommand] (the generated SetPowerStateCommand had zero references — the XAML wires SelectionChanged, not a command).
  • Updated the SetPowerStateAsync doc comment from the one-directional framing to a neutral bidirectional description.

Net change: 2 files, +5 / −24.

Validation Steps Performed

  • Build: MSBuild PowerDisplay.csproj -p:Platform=x64 -p:Configuration=Debug (CoreCompile) — 0 errors / 0 warnings.
  • Static check: repo-wide grep confirms no remaining references to PowerStateOn or SetPowerStateCommand; the power-state ListView binds only ItemsSource + SelectionChanged (no SelectedItem binding), so opening the flyout cannot spuriously re-fire a selection.
  • Manual (requires a DDC/CI monitor): enable Power state control for a monitor → open its flyout and select Standby or Off (DPM) (screen blanks) → reopen the flyout and select On → the display wakes.

No automated test was added: with the guard removed the handler is an unconditional pass-through (identical in shape to HandleInputSourceSelectionChanged), and it is an async void WinUI event handler over real DDC/CI hardware, which is outside the PowerDisplay.Lib unit-test seam.

🤖 Generated with Claude Code

…#48428)

HandlePowerStateSelectionChanged short-circuited when the selected power state was On (0x01), so the DDC/CI wake write was never sent and Power Display could only put monitors to sleep, never turn them back on. The guard dated back to a single-monitor assumption ("the monitor must be on to see the UI") that a later real-state read and multi-monitor support invalidated.

Remove the guard so selecting On sends VCP 0xD6=0x01 and wakes the display (DDC/CI stays reachable in Standby/Suspend/Off(DPM)). Also drop the now-unused PowerStateOn constant and the dead SetPowerState RelayCommand, and refresh the one-directional doc comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@moooyo
Yu Leng (moooyo) enabled auto-merge (squash) June 15, 2026 04:43
@moooyo

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).
@moooyo
Yu Leng (moooyo) merged commit ff3c1f9 into main Jun 15, 2026
16 checks passed
@moooyo
Yu Leng (moooyo) deleted the yuleng/pd/f/11 branch June 15, 2026 06:13
Boliang Zhang (LegendaryBlair) pushed a commit that referenced this pull request Jun 22, 2026
…#48628)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

Power Display could put a monitor to sleep but never wake it back up.
Selecting **On** in the per-monitor power-state list was a hard-coded
no-op, so the DDC/CI wake command (VCP `0xD6` = `0x01`) was never sent.
This removes that guard so selecting **On** wakes the display, and
cleans up the dead code/comment left behind by the original
one-directional design.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #48428
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [x] **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 pass
- [x] **Localization:** All end-user-facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

`MonitorViewModel.HandlePowerStateSelectionChanged` early-returned when
the selected power state was **On** (`0x01`), so `SetPowerStateAsync`
was never called for On and the wake write never reached the monitor. As
a result Power Display's power control was one-directional: it could
send Standby/Suspend/Off but could never turn a monitor back on.

The guard dates back to the very first power-state commit and was paired
with a single-monitor assumption — *"the monitor must be on to see the
UI"*, so On was treated as the always-current state and skipped. A later
change made the selection reflect the monitor's real power state (so a
monitor in the list can legitimately be asleep), and multi-monitor
support means the flyout can be shown on monitor A while the user wants
to wake monitor B. Those changes invalidated the assumption, but the
action-side guard survived a subsequent refactor.

The lower layers already do the right thing:
`MonitorManager.SetPowerStateAsync` →
`DdcCiController.SetPowerStateAsync` → `SetVcpFeatureAsync(monitor,
0xD6, value)` passes the value through unchanged, so the fix is purely
removing the UI-layer guard. DDC/CI stays reachable while the panel is
in Standby/Suspend/Off(DPM), so writing `0x01` turns it back on (this is
the same mechanism Twinkle Tray uses). `Off (Hard)` / `0x05` may still
require a physical wake on some monitors, since that state can cut the
DDC command channel.

Cleanup included in this PR:
- Removed the now-unused `PowerStateItem.PowerStateOn` constant (its
only consumer was the deleted guard).
- Removed the dead `SetPowerState` `[RelayCommand]` (the generated
`SetPowerStateCommand` had zero references — the XAML wires
`SelectionChanged`, not a command).
- Updated the `SetPowerStateAsync` doc comment from the one-directional
framing to a neutral bidirectional description.

Net change: 2 files, +5 / −24.

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

- **Build:** `MSBuild PowerDisplay.csproj -p:Platform=x64
-p:Configuration=Debug` (CoreCompile) — **0 errors / 0 warnings**.
- **Static check:** repo-wide grep confirms no remaining references to
`PowerStateOn` or `SetPowerStateCommand`; the power-state ListView binds
only `ItemsSource` + `SelectionChanged` (no `SelectedItem` binding), so
opening the flyout cannot spuriously re-fire a selection.
- **Manual (requires a DDC/CI monitor):** enable *Power state control*
for a monitor → open its flyout and select **Standby** or **Off (DPM)**
(screen blanks) → reopen the flyout and select **On** → the display
wakes.

No automated test was added: with the guard removed the handler is an
unconditional pass-through (identical in shape to
`HandleInputSourceSelectionChanged`), and it is an `async void` WinUI
event handler over real DDC/CI hardware, which is outside the
`PowerDisplay.Lib` unit-test seam.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Yu Leng <yuleng@microsoft.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit ff3c1f9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants