Skip to content

Always on top: window context menu to always on top#45773

Merged
vanzue merged 8 commits intomainfrom
dev/vanzue/aat-window-context-menu
Feb 27, 2026
Merged

Always on top: window context menu to always on top#45773
vanzue merged 8 commits intomainfrom
dev/vanzue/aat-window-context-menu

Conversation

@vanzue
Copy link
Copy Markdown
Contributor

@vanzue vanzue commented Feb 24, 2026

Summary of the Pull Request

Add an option to enable inject a window context menu to always on top this window.

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

Validation Steps Performed

window-context-menu-aot.mp4

@github-actions

This comment has been minimized.

@vanzue vanzue changed the title Initial dev Always on top: window context menu to always on top Feb 24, 2026
@htcfreek
Copy link
Copy Markdown
Collaborator

@vanzue
Is a button in the title bar possible? A button would be easier to access.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .cmd wrapper instead of invoking pwsh directly.

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.

@vanzue
Copy link
Copy Markdown
Contributor Author

vanzue commented Feb 25, 2026

@vanzue Is a button in the title bar possible? A button would be easier to access.

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),
Which increases complexity and compatibility risk.
Compared to that, extending the system menu (like Dexpot does) is much safer and more consistent with how Windows expects integrations to behave

@vanzue vanzue marked this pull request as ready for review February 25, 2026 05:19
@vanzue
Copy link
Copy Markdown
Contributor Author

vanzue commented Feb 25, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@vanzue
Copy link
Copy Markdown
Contributor Author

vanzue commented Feb 25, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@vanzue
Copy link
Copy Markdown
Contributor Author

vanzue commented Feb 25, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@vanzue vanzue added the Product-Always On Top Refers to the idea of a Always on Top Powertoy label Feb 25, 2026
@vanzue vanzue requested a review from Copilot February 26, 2026 09:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Co-authored-by: Niels Laute <niels.laute@live.nl>
@vanzue vanzue enabled auto-merge (squash) February 27, 2026 08:44
@vanzue vanzue merged commit 494c14f into main Feb 27, 2026
15 checks passed
@vanzue vanzue deleted the dev/vanzue/aat-window-context-menu branch February 27, 2026 08:46
{
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;
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.

This value is interesting. I tried to ask Copilot, and ... it is mixed yes/no answer....

@zateutsch zateutsch added this to the PowerToys 0.98 milestone Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Always On Top Refers to the idea of a Always on Top Powertoy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inject "Toggle always on top" item in title bar menu of every window

7 participants