PowerToys/doc/devdocs/modules/alwaysontop.md
Josh Soref bf16e10baf
Some checks failed
Spell checking / Check Spelling (push) Has been cancelled
Spell checking / Report (Push) (push) Has been cancelled
Spell checking / Report (PR) (push) Has been cancelled
Spell checking / Update PR (push) Has been cancelled
Updates for check-spelling v0.0.25 (#40386)
## Summary of the Pull Request

- #39572 updated check-spelling but ignored:
   > 🐣 Breaking Changes
[Code Scanning action requires a Code Scanning
Ruleset](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset)
If you use SARIF reporting, then instead of the workflow yielding an 
when it fails, it will rely on [github-advanced-security
🤖](https://github.com/apps/github-advanced-security) to report the
failure. You will need to adjust your checks for PRs.

This means that check-spelling hasn't been properly doing its job 😦.

I'm sorry, I should have pushed a thing to this repo earlier,...

Anyway, as with most refreshes, this comes with a number of fixes, some
are fixes for typos that snuck in before the 0.0.25 upgrade, some are
for things that snuck in after, some are based on new rules in
spell-check-this, and some are hand written patterns based on running
through this repository a few times.

About the 🐣 **breaking change**: someone needs to create a ruleset for
this repository (see [Code Scanning action requires a Code Scanning
Ruleset: Sample ruleset

](https://github.com/check-spelling/check-spelling/wiki/Breaking-Change:-Code-Scanning-action-requires-a-Code-Scanning-Ruleset#sample-ruleset)).

The alternative to adding a ruleset is to change the condition to not
use sarif for this repository. In general, I think the github
integration from sarif is prettier/more helpful, so I think that it's
the better choice.

You can see an example of it working in:
- https://github.com/check-spelling-sandbox/PowerToys/pull/23

---------

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
2025-07-08 17:16:52 -05:00

4.0 KiB

Always on Top

Public overview - Microsoft Learn

All Issues
Bugs
Pull Requests

Overview

The Always on Top module allows users to pin windows on top of others, ensuring they remain visible even when switching between applications. The module provides visual indicators (customizable borders) to identify which windows are pinned.

Features

  • Pin any window to stay on top of other windows
  • Customizable border color, opacity, and thickness around pinned windows
  • User-defined keyboard shortcut for toggling window pinning
  • Visual indicators to identify pinned windows

Architecture

Main Components

  • Hotkey Listener: Detects the user-defined hotkey to toggle the Always on Top state
  • AlwaysOnTop: Manages the state of windows, ensuring the selected window stays on top
  • Settings: Stores user preferences and configurations
  • WindowHook: Hooks all window events

Data Flow

  1. The Hotkey Listener detects the hotkey press and notifies the AlwaysOnTop
  2. The AlwaysOnTop updates the window state and interacts with the operating system to keep the window on top
  3. User preferences are saved and loaded from the Settings

Code Structure

Key Files

  • AlwaysOnTop.cpp: Contains the core logic for the module, including initialization and event handling
  • Settings.cpp: Defines the settings structure and provides methods to load and save settings
  • main.cpp: Starts thread and initializes AlwaysOnTop

Initialization

The module is initialized in the AlwaysOnTop class. During initialization, the following steps are performed:

  1. LoadSettings: The module loads user settings from a configuration file
  2. RegisterHotkey: The HotkeyManager registers the keyboard shortcut for pinning/unpinning windows
  3. SubscribeToEvents: Event handlers are attached to respond to user actions, such as pressing the hotkey

Pinning and Unpinning Windows

The AlwaysOnTop class handles the pinning and unpinning of windows. Key methods include:

  • PinTopmostWindow: Pins the specified window on top of others and applies visual indicators
  • UnpinTopmostWindows: Removes the pinning status and visual indicators from the specified window
  • AssignBorder: Applies a colored border around the pinned window based on user settings

Settings Management

The Settings class manages the module's settings. Key methods include:

  • LoadSettings: Loads settings from a configuration file
  • NotifyObservers: Distributes the data for the settings
  • GetDefaultSettings: Returns the default settings for the module

User Interface

The module provides a user interface for configuring settings in the PowerToys Settings UI. This interface is implemented using XAML and includes options for customizing the:

  • Border color
  • Border opacity
  • Border thickness
  • Keyboard shortcut

Development Environment Setup

Prerequisites

  • Visual Studio 2019 or later
  • Windows 10 SDK
  • PowerToys repository cloned from GitHub

Building and Testing

  1. Clone the repository: git clone https://github.com/microsoft/PowerToys.git
  2. Open PowerToys.sln in Visual Studio
  3. Select the Release configuration and build the solution
  4. Run PowerToys.exe from the output directory to test the module

Debug

  1. build the entire project
  2. launch the built Powertoys
  3. select AlwaysOnTop as the startup project in VS
  4. In the debug button, choose "Attach to process". image
  5. Attach to AlwaysOnTop.image