Files
PowerToys/src/settings-ui
chakrik73 d2c53bf386 [ZoomIt] Add DemoMirror feature (#49607)
Mirror the screen, a selected region (Shift), or the window under the
cursor (Alt) onto a second monitor - including the mouse pointer - so a
demo can be shown on a presentation display without leaving the current
view. Adds the native MirrorWindow implementation, a DemoMirror options
tab (Ctrl+9 default, plus Track window region), and the corresponding
Settings UI (ZoomIt page group, view model, properties, and resources).

## Summary of the Pull Request

Adds a **DemoMirror** feature to ZoomIt. It mirrors the screen, a
selected region (Shift), or the window under the cursor (Alt) onto a
second monitor — including the mouse pointer — so a demo can be shown on
a presentation display without leaving the current view.

This introduces the native `MirrorWindow` implementation, a new
DemoMirror options tab (default hotkey **Ctrl+9**, plus a **Track window
region** option), and the corresponding Settings UI wiring (ZoomIt page
group, view model, properties, and localized resources).

## PR Checklist

- **Communication:** I've discussed this with core contributors already.
- **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]

## Detailed Description of the Pull Request / Additional comments

DemoMirror lets a presenter keep working on their primary display while
a second monitor shows a live mirror of a chosen source. Three capture
modes are supported via the DemoMirror hotkey (default **Ctrl+9**):

- **Full screen** — `Ctrl+9`: mirrors the entire source screen.
- **Region** — `Ctrl+Shift+9`: mirrors a user-selected rectangular
region.
- **Window** — `Ctrl+Alt+9`: mirrors the window currently under the
cursor. With the **Track window region** option enabled, the mirror
follows the window as it moves/resizes.

The mirror includes the mouse pointer so pointer movement and clicks are
visible on the presentation display.

**Native (C++ / `PowerToys.ZoomIt.exe`)**
- New `MirrorWindow.cpp` / `MirrorWindow.h` implementing the mirror
capture/render window. Mirror windows use `WS_EX_NOACTIVATE |
WS_EX_TRANSPARENT` so they never steal focus from the source.
- `Zoomit.cpp`: registers the DemoMirror hotkeys and wires the
start/stop handlers; the stop path checks `g_MirrorWindow.IsActive()`
and stops unconditionally (cursor-independent).
- `ZoomItSettings.h`: new `MirrorToggleKey` (default `Ctrl+9`) and
`MirrorTrackWindow` settings, added to the `RegSettings[]` table. Record
default kept distinct at `Ctrl+5`.
- `resource.h` / `ZoomIt.rc`: new DemoMirror options tab and controls
(`IDC_MIRROR_HOTKEY`, `IDC_MIRROR_TRACK_WINDOW`).
- `CaptureFrameWait.*` and `SelectRectangle.*` updated to support the
mirror capture/selection flow.
- `ZoomItSettingsInterop/ZoomItSettings.cpp`: exposes the new settings
across the interop bridge.

**Settings UI (WinUI 3)**
- New DemoMirror group on the ZoomIt page (`ZoomItPage.xaml`), backed by
`ZoomItViewModel.cs` and `ZoomItProperties.cs`.
- Localizable strings added to `Resources.resw`.

**Conflict resolution notes** (rebased on top of upstream `main`):
- Control-ID collision resolved by assigning distinct IDs
(`IDC_MIRROR_HOTKEY`, `IDC_MIRROR_TRACK_WINDOW`).
- `SelectRectangle` border-color: kept upstream `m_borderColor =
borderColor;`.
- `WM_USER` message-ID collision resolved by using `WM_USER_MIRROR_STOP
= WM_USER + 113`.

## Validation Steps Performed

Manually validated on a real dual-display setup (Surface laptop extended
to an external monitor):

- **Full screen** (`Ctrl+9`): source screen mirrored to the second
monitor, including the mouse pointer.
- **Region** (`Ctrl+Shift+9`): selected region mirrored correctly. 
- **Window** (`Ctrl+Alt+9`): window under the cursor mirrored; with
**Track window region** enabled, the mirror follows the window.
- **Stop/cancel**: DemoMirror stops reliably regardless of cursor
position; mirror windows never take focus (`WS_EX_NOACTIVATE |
WS_EX_TRANSPARENT`).
- **Hotkey defaults**: confirmed Record (`Ctrl+5`) and DemoMirror
(`Ctrl+9`) defaults are distinct and read independently from their own
registry/settings values (no cross-contamination).
- **Settings UI**: DemoMirror hotkey and Track window region options
round-trip correctly through the Settings UI and the interop bridge.
2026-07-31 19:39:26 -07:00
..