Always on top: window context menu to always on top#45773
Conversation
This comment has been minimized.
This comment has been minimized.
|
@vanzue |
There was a problem hiding this comment.
Pull request overview
Adds a configurable “Toggle always on top” entry into the system (title bar) menu of windows, exposing Always On Top via a discoverable UI instead of relying solely on the hotkey. This spans Settings UI (new toggle + persisted setting) and the AlwaysOnTop module (WinEvent hooks + system-menu item injection/handling).
Changes:
- Adds a new persisted setting (
show-in-system-menu) surfaced in Settings UI as “Show in window title bar menu”. - Extends the AlwaysOnTop module to inject/update/remove a system-menu item and trigger pin/unpin from that menu.
- Updates the PackageIdentity sparse package build target to call a
.cmdwrapper instead of invokingpwshdirectly.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/settings-ui/Settings.UI/ViewModels/AlwaysOnTopViewModel.cs | Adds ViewModel property/field to bind and persist the new setting. |
| src/settings-ui/Settings.UI/Strings/en-us/Resources.resw | Adds localized header/description strings for the new Settings toggle. |
| src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml | Adds a new SettingsCard with ToggleSwitch for “Show in window title bar menu”. |
| src/settings-ui/Settings.UI.Library/AlwaysOnTopProperties.cs | Adds the new show-in-system-menu JSON property with default value. |
| src/modules/alwaysontop/AlwaysOnTop/SettingsConstants.h | Introduces a new SettingId::ShowInSystemMenu for observer notifications. |
| src/modules/alwaysontop/AlwaysOnTop/Settings.h | Adds showInSystemMenu to the native settings struct. |
| src/modules/alwaysontop/AlwaysOnTop/Settings.cpp | Loads show-in-system-menu from the settings JSON and notifies observers. |
| src/modules/alwaysontop/AlwaysOnTop/Resources.resx | Adds localized string for the injected system-menu item label. |
| src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.h | Tracks the last system-menu window and declares UpdateSystemMenuItem. |
| src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp | Hooks menu-related WinEvents, injects/removes/updates the system-menu item, and handles invocation to toggle AOT. |
| src/PackageIdentity/PackageIdentity.vcxproj | Switches sparse package build step to a .cmd wrapper invocation. |
src/settings-ui/Settings.UI/SettingsXAML/Views/AlwaysOnTopPage.xaml
Outdated
Show resolved
Hide resolved
A true title bar button isn’t very straightforward to implement for third-party windows. Tools like Actual Window Manager achieve that via non-client area hooking and cross-process manipulation(said by chatgpt, I'm unaware of this), |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Co-authored-by: Niels Laute <niels.laute@live.nl>
| { | ||
| const static wchar_t* TOOL_WINDOW_CLASS_NAME = L"AlwaysOnTopWindow"; | ||
| const static wchar_t* WINDOW_IS_PINNED_PROP = L"AlwaysOnTop_Pinned"; | ||
| constexpr UINT SYSTEM_MENU_TOGGLE_ALWAYS_ON_TOP_COMMAND = 0xEFE0; |
There was a problem hiding this comment.
This value is interesting. I tried to ask Copilot, and ... it is mixed yes/no answer....
Summary of the Pull Request
Add an option to enable inject a window context menu to always on top this window.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
window-context-menu-aot.mp4