Repository navigation
[PowerDisplay] Allow waking a monitor from standby via power-state On - #48628
Merged
Merged
Conversation
…#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>
Kai Tao (vanzue)
approved these changes
Jun 15, 2026
Yu Leng (moooyo)
enabled auto-merge (squash)
June 15, 2026 04:43
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Detailed Description of the Pull Request / Additional comments
MonitorViewModel.HandlePowerStateSelectionChangedearly-returned when the selected power state was On (0x01), soSetPowerStateAsyncwas 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 writing0x01turns it back on (this is the same mechanism Twinkle Tray uses).Off (Hard)/0x05may still require a physical wake on some monitors, since that state can cut the DDC command channel.Cleanup included in this PR:
PowerStateItem.PowerStateOnconstant (its only consumer was the deleted guard).SetPowerState[RelayCommand](the generatedSetPowerStateCommandhad zero references — the XAML wiresSelectionChanged, not a command).SetPowerStateAsyncdoc comment from the one-directional framing to a neutral bidirectional description.Net change: 2 files, +5 / −24.
Validation Steps Performed
MSBuild PowerDisplay.csproj -p:Platform=x64 -p:Configuration=Debug(CoreCompile) — 0 errors / 0 warnings.PowerStateOnorSetPowerStateCommand; the power-state ListView binds onlyItemsSource+SelectionChanged(noSelectedItembinding), so opening the flyout cannot spuriously re-fire a selection.No automated test was added: with the guard removed the handler is an unconditional pass-through (identical in shape to
HandleInputSourceSelectionChanged), and it is anasync voidWinUI event handler over real DDC/CI hardware, which is outside thePowerDisplay.Libunit-test seam.🤖 Generated with Claude Code