Always on top: Add transparent support for on topped window #44815
Always on top: Add transparent support for on topped window #44815
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This pull request adds transparency adjustment support to the Always on Top module, allowing users to dynamically adjust the opacity of pinned windows using keyboard shortcuts (modifier keys + '+' or '-'). The implementation includes shared transparency utilities in common/utils/window.h that are reused by both AlwaysOnTop and FancyZones modules.
Changes:
- Added transparency adjustment hotkeys (modifier + '+' for increase, modifier + '-' for decrease) with 20%-100% opacity range
- Created shared window transparency utilities in common/utils/window.h for applying and restoring transparency
- Refactored FancyZones (WindowDrag and WindowMouseSnap) to use the new shared transparency utilities
- Added UI documentation and sound effects for transparency adjustments
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| src/settings-ui/Settings.UI/Strings/en-us/Resources.resw | Updated activation shortcut description and added transparency adjustment documentation |
| src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml | Added transparency info card to settings UI |
| src/modules/alwaysontop/AlwaysOnTopModuleInterface/dllmain.cpp | Extended hotkey registration to support 3 hotkeys (pin, increase/decrease opacity) and added event handles |
| src/modules/alwaysontop/AlwaysOnTop/Sound.h | Added new sound types for opacity changes and removed unused member |
| src/modules/alwaysontop/AlwaysOnTop/SettingsConstants.h | Added trailing comma to enum (style change) |
| src/modules/alwaysontop/AlwaysOnTop/Settings.h | Added transparency range constants (min 20%, max 100%, step 10%) |
| src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.h | Added transparency methods and window state tracking structures |
| src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp | Implemented transparency adjustment logic, window resolution, and state management |
| src/common/utils/window.h | Added shared transparency utilities (MakeWindowTransparent, RestoreWindowTransparency) |
| src/common/interop/shared_constants.h | Added event name constants for opacity increase/decrease events |
| src/modules/fancyzones/FancyZonesLib/WindowMouseSnap.h | Refactored to use WindowTransparencyProperties structure |
| src/modules/fancyzones/FancyZonesLib/WindowMouseSnap.cpp | Simplified to use shared transparency utilities |
| src/modules/fancyzones/FancyZonesLib/WindowDrag.h | Refactored to use WindowTransparencyProperties structure |
| src/modules/fancyzones/FancyZonesLib/WindowDrag.cpp | Simplified to use shared transparency utilities |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.Unrecognized words (1)Metacharacter These words are not needed and should be removedROOTOWNERSome files were automatically ignored 🙈These sample patterns would exclude them: You should consider adding them to: File matching is via Perl regular expressions. To check these files, more of their words need to be in the dictionary than not. You can use To accept these unrecognized words as correct, update file exclusions, and remove the previously acknowledged and now absent words, you could run the following commands... in a clone of the git@github.com:microsoft/PowerToys.git repository curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/c635c2f3f714eec2fcf27b643a1919b9a811ef2e/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/21430389029/attempts/1' &&
git commit -m 'Update check-spelling metadata'Warnings
|
| Count | |
|---|---|
| 2 |
See
If the flagged items are 🤯 false positives
If items relate to a ...
-
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txtfile matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^refers to the file's path from the root of the repository, so^README\.md$would exclude README.md (on whichever branch you're using). -
well-formed pattern.
If you can write a pattern that would match it,
try adding it to thepatterns.txtfile.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
<!-- 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 Transparency support (best-effort) > Not every window can be made transparent. Transparency is applied on a best-effort basis and depends on how the target app/window is built and rendered. ## When it may not work * Windows with special rendering pipelines (e.g., certain hardware-accelerated / compositor-managed surfaces). * Some tool/popup/owned windows where the foreground window isn’t the actual surface being drawn. ## How it works (high-level) * Resolve the best target window (preferring the top-level/root window over transient children). * Apply Windows’ standard layered-window alpha mechanism (per-window opacity) to adjust transparency. * When unpinned, Restore the original opacity/state when possible. If transparency doesn’t change, it means the window doesn’t support this mechanism in its current configuration. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [X] Closes: #43278 #42929 #28773 <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [ ] **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 - [ ] [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 <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed https://github.com/user-attachments/assets/c97a87f2-3126-4e19-990f-8c684dbeb631 <img width="1119" height="426" alt="image" src="https://github.com/user-attachments/assets/547671ee-81d3-4c94-8199-bf0c4b1b7760" /> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary of the Pull Request
Transparency support (best-effort)
When it may not work
How it works (high-level)
If transparency doesn’t change, it means the window doesn’t support this mechanism in its current configuration.
PR Checklist
add window opacity to Always On Top #43278
Always on top window transparency #42929
Controle de opacidade #28773
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
always.on.top.transparency.support.for.window.mp4