Compare commits

...

12 Commits

Author SHA1 Message Date
Clint Rutkas
4939de08f4 Fix MSB3030 parallel-build race in ImageResizer.UnitTests
ImageResizerUI is a self-contained WinUI 3 app whose runtimeconfig.json and deps.json are written late into the shared WinUI3Apps output folder. ImageResizer.UnitTests references it only for types (InternalsVisibleTo), never launches the app, yet MSBuild pulled those two app runtime json files into the test's copy-to-output list. Under a highly parallel build the copy step could run before the files existed, producing MSB3030. Remove just those two never-needed files from the copy lists so the race is impossible; the referenced PowerToys.ImageResizer.dll is still copied so tests run normally.
2026-07-01 22:17:14 -07:00
Clint Rutkas
0ef68e4cd4 first part of cold full reboot fix 2026-07-01 21:53:57 -07:00
Michael Jolley
0afe525f31 Fix memory leaks in Command Palette: unsubscribe event handlers and dispose resources (#48884)
## Summary

Fixes 6 memory leaks in Command Palette caused by event handlers not
being unsubscribed and disposable resources not being released.

## Changes

| File | Fix |
|------|-----|
| `MainListPage.cs` | Replace lambda on static
`AllAppsCommandProvider.Page.PropChanged` with named method; unsubscribe
in `Dispose()` |
| `WinRTExtensionService.cs` | Unsubscribe static `PackageCatalog`
events (`PackageInstalling`/`Uninstalling`/`Updating`) in `Dispose()` |
| `MainWindow.xaml.cs` | Unsubscribe all event handlers in `Dispose()`
(`SizeChanged`, `SettingsChanged`, `ActualThemeChanged`,
`XamlRoot.Changed`, `CardElement.SizeChanged`, timer `Tick`,
`ThemeChanged`, `KeyPressed`); replace lambda with named method |
| `ContentFormControl.xaml.cs` | Unsubscribe previous
`RenderedAdaptiveCard.Action` before subscribing to new card |
| `BlurImageControl.cs` | Track `LoadedImageSurface` and unsubscribe
`LoadCompleted` before loading a new image |
| `ShowFileInFolderCommand.cs` | Dispose `Process` object returned by
`Process.Start()` (handle leak) |

## Validation

- [x] Build clean (`tools\build\build.ps1 -Path src\modules\cmdpal
-Platform x64 -Configuration Debug`) — exit code 0
- [x] All 1809 CmdPal unit tests pass (2 pre-existing skips)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 18:59:55 +02:00
Michael Jolley
a43fb12d6f cmdpal: Support Enter key to submit FormContent (Adaptive Card) inputs (#48768)
## Summary

Adds Enter key support for submitting Adaptive Card forms in the Command
Palette. When a user presses Enter inside a single-line `Input.Text`
field, the form is automatically submitted using the first
`Action.Submit` or `Action.Execute` action on the card.

## Problem

When extensions use `FormContent` with Adaptive Cards, pressing Enter
inside an `Input.Text` field does not trigger submission. Users must
click the submit button with their mouse (or tab to it), breaking
keyboard-only workflows like login/unlock forms.

## Solution

Added a `KeyDown` event handler on the rendered Adaptive Card's
`FrameworkElement` in `ContentFormControl.xaml.cs`:

- Intercepts `VirtualKey.Enter` when the source is a `TextBox` that
doesn't accept returns (single-line)
- Finds the first `AdaptiveSubmitAction` or `AdaptiveExecuteAction` on
the card
- Calls `HandleSubmit` with that action and the current user inputs via
`RenderedAdaptiveCard.UserInputs.AsJson()`

Multiline text inputs (`AcceptsReturn = true`) are excluded so Enter
still inserts newlines.

## Validation

- Single file change in `ContentFormControl.xaml.cs`
- Uses existing `HandleSubmit` path — same behavior as clicking the
submit button
- No impact on cards without submit/execute actions
- No impact on multiline text inputs

Fixes #46003

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 10:48:32 -05:00
Christian Gaarden Gaardmark
bc56443443 New++ updated attribution (#49047)
## Summary of the Pull Request
* Updated New+ attribution text and link after conversation with Niels
* Text="Based on Christian Gaardmark's New++ from the Productivity Plus
Pack"
*
Link="https://www.onegreatworld.com/products/productivity-plus-pack/?ref=settings_pt"

## PR Checklist
- [ ] Closes: #xxx
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [n/a] **Tests:** Added/updated and all pass
- [n/a] **Localization:** All end-user-facing strings can be localized
- [n/a] **Dev docs:** Added/updated
- [n/a] **New binaries:** Added on the required places
- [n/a] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [n/a] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [n/a] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [n/a] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [n/a] **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

## Detailed Description of the Pull Request / Additional comments
* Text="Based on Christian Gaardmark's New++ from the Productivity Plus
Pack"
*
Link="https://www.onegreatworld.com/products/productivity-plus-pack/?ref=settings_pt"

## Validation Steps Performed
1. Manually confirmed visual layout
2. Manually confirmed link

<img width="470" height="65" alt="image"
src="https://github.com/user-attachments/assets/56d6e454-89cf-4a26-b570-b162df51f4a9"
/>

cc:
@niels9001
2026-07-01 14:18:05 +02:00
Clint Rutkas
3298625b67 Cancel stale Quick Accent toolbar render timer (#48944)
## Summary

Quick Accent's ShowToolbar queues a delayed render of the accent menu
through Task.Delay(...).ContinueWith(...). The continuation only checked
_visible before rendering, so a timer started by an earlier key press
could still fire for a **newer** summon — or one that had already been
hidden — popping the accent menu earlier than the configured delay
intended.

This was surfaced while reviewing the press-and-hold work in #48937, but
it is a pre-existing race independent of that feature, so it ships on
its own.

## Fix

- Tag each `ShowToolbar` summon with an incrementing `_showGeneration`
id and capture it in the local closure.
- The delayed continuation now renders only when it is still the most
recent summon (`generation == _showGeneration`) **and** `_visible`.
- Bump the generation when the toolbar hides, so any in-flight timer
queued before the hide is cancelled.

Everything runs on the UI thread (the dispatcher marshals
`ShowToolbar`/hide and the continuation uses
`FromCurrentSynchronizationContext`), so the counter needs no locking.

## Validation

- Built `PowerAccent.UI` (C++ hook + Core) Debug|x64 — 0 warnings, 0
errors.
- Manual: rapid repeated taps of an accent-capable letter no longer
flash the menu early from a leftover timer; normal hold-to-open and
navigation/commit are unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 15:36:50 +08:00
Clint Rutkas
ae9f241ef1 [FancyZones] Harden three shutdown races in WorkArea / ZonesOverlay / OnThreadExecutor (#48473)
## Summary

Four small shutdown-/teardown-race fixes in FancyZones that I spotted
while reading through the work-area and overlay teardown sequence for an
unrelated review. Each one is independently safe in the happy path, but
in combination they can crash the FancyZones host process during display
changes, monitor configuration changes, a settings toggle mid-drag, or
normal exit.

## Issues fixed

### 1. `~ZonesOverlay` joins a non-joinable thread when the constructor
early-returns
`ZonesOverlay::ZonesOverlay` can return early in two places — if
`GetClientRect` fails or if `CreateHwndRenderTarget` returns a failure
HRESULT (both reachable in the wild during a display-driver TDR or when
a monitor is disconnected mid-init). When that happens, `m_renderThread`
is never started and stays default-constructed. The destructor
unconditionally calls `m_renderThread.join()`, which on a non-joinable
thread is undefined behavior (MSVC throws `std::system_error`); thrown
from an implicit-noexcept destructor it calls `std::terminate()`.

Fix: guard the wake-up-and-join sequence with `if
(m_renderThread.joinable())`.

### 2. `~WorkArea` returns the HWND to the window pool before the
renderer is torn down
`WorkArea`'s explicit destructor body calls
`windowPool.FreeZonesOverlayWindow(m_window)` first, and only afterwards
does implicit member destruction run `~ZonesOverlay` (which joins the
render thread). Between those two steps the HWND is back in the pool and
immediately eligible for reuse by the next `NewZonesOverlayWindow` call,
while the still-alive render thread is using `m_renderTarget` to draw
into it. If the pool hands the same HWND to a freshly-built
`ZonesOverlay`, two render targets target the same window concurrently.

Fix: reset `m_zonesOverlay` (which joins the render thread) before
returning the window to the pool.

### 3. `~OnThreadExecutor` writes `_shutdown_request` outside the mutex
The destructor mutates the shutdown flag without holding `_task_mutex`,
then calls `_task_cv.notify_one()`. The worker checks the same flag
inside `_task_cv.wait(lock, predicate)`. The atomic does make the value
visible eventually, but if the notify lands in the narrow window where
the worker has just evaluated the predicate as false and is about to
atomically release the lock and sleep, the wakeup can be missed and
`_worker_thread.join()` hangs.

Fix: take `_task_mutex` around the `_shutdown_request = true` write so
it pairs correctly with the `cv.wait`.

### 4. `WindowMouseSnap` keeps a dangling `WorkArea*` across
`WorkAreaConfiguration::Clear()`
`FancyZones::UpdateWorkAreas()` rebuilds `m_workAreaConfiguration`
whenever monitor state changes mid-session, and the
`SpanZonesAcrossMonitors` settings toggle hits the same `Clear()`. If
the user is mid-drag at the moment one of these runs, the
`WindowMouseSnap` instance owned by `FancyZones` is still holding both a
`const` reference to the map being cleared (`m_activeWorkAreas`) and a
raw `WorkArea*` into one of the entries that's about to be destroyed
(`m_currentWorkArea`). The next `WM_MOUSEMOVE` -> `MoveSizeUpdate()`
then dereferences a freed pointer. `WindowMouseSnap`'s destructor only
resets window transparency, so relying on it doesn't help; the snapper
has to be torn down explicitly.

Fix: call `FancyZones::MoveSizeEnd()` (which already tears down the
snapper cleanly and is a no-op when the snapper is null) before each
`m_workAreaConfiguration.Clear()` call on these paths.

## Risk

Low. All four changes are localized to teardown / reconfiguration paths
and only tighten existing destruction sequences — the steady-state
behavior of `ZonesOverlay::Render`/`Show`/`Hide`, the work-area public
API, `OnThreadExecutor::submit`/`cancel`, and `WindowMouseSnap` drag
handling is unchanged. The `WorkArea` reordering is the most behavioral
change; it now guarantees the render thread has stopped using the HWND
before the pool can recycle it, which is what the existing
implicit-member-destruction order already implied but couldn't enforce
given the explicit destructor body.

## Validation

Spot-built locally; this repo's `dotnet restore` runtime-pack issue
(unrelated to this PR — same NU1102 pattern that's affecting other open
PRs) prevents a full `Build.cmd` here, but the C++ FancyZones modules
involved are unchanged in their public surface and are exercised by
existing unit tests in `FancyZonesTests` for the WorkArea code paths.

---

ADO: https://microsoft.visualstudio.com/OS/_workitems/edit/54653316/

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 15:35:03 +08:00
Jiří Polášek
67a9fa2d13 CmdPal: Ensure that directory paths passed from Bookmarks is quoted (#48955)
This PR ensures that directory paths passed from Bookmarks through
`CommandLauncher` to Windows Explorer are properly quoted. In current
implementation the directory path that should be opened through Windows
Explorer is not quoted and if it contains a space then Explorer will
treat it as multiple arguments instead.

<!-- 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

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #48672 
<!-- - [ ] 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
2026-06-30 23:24:01 -05:00
Clint Rutkas
1cfc923bdb Fix mismatched WebView2 versions, upgrade WebView2 (#49051) 2026-06-30 18:18:06 -05:00
Clint Rutkas
2dd802f367 Fixing Windows.ImplementationLibrary mismatch between proj and package.config (#49050)
In the vcxproj files, it lists it correctly for
Microsoft.Windows.ImplementationLibrary.1.0.260126.7 but the package
files are incorrect
2026-06-30 18:17:27 -05:00
Clint Rutkas
a0d17406ba Updating MessagePack (#49029)
Version bump on Message Pack
2026-06-30 14:26:32 +02:00
Copilot
4a27c5d5f9 New+: Fix French translation guidance (Nouveau+ not Nouveauté+) (#47225)
## Summary of the Pull Request

French translation of "New+" was rendered as "Nouveauté+" ("Novelty+")
instead of "Nouveau+" ("New+"), inconsistent with how Windows itself
translates the "New" context menu item in French. This updates
translator guidance comments in the English resource files to explicitly
call out the correct French form.

## 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
- [ ] [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

## Detailed Description of the Pull Request / Additional comments

Translator-facing `<comment>` fields updated across three resource files
to explicitly state the correct French translation and flag the wrong
one:

- **`NewShellExtensionContextMenu/resources.resx`** and
**`NewShellExtensionContextMenu.win10/resources.resx`** —
`context_menu_item_new`:
> _"…e.g. Danish it would become Ny+, **French it would become Nouveau+
(not Nouveauté+)**"_

- **`Settings.UI/Strings/en-us/Resources.resw`** — five `NewPlus.*` /
`Oobe_NewPlus.*` strings:
> _"…Localize product name in accordance with Windows New. **e.g. French
would be Nouveau+ (not Nouveauté+)**"_

Actual `.lcl` translation files are managed by the CDPX localization
pipeline; these comment updates feed directly into the guidance the
localization team sees when updating those files.

## Validation Steps Performed

Comment-only changes to XML resource files; no runtime behavior
affected. Verified all targeted entries were updated and no existing
checked-in `Nouveauté` strings remain in the repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
2026-06-30 17:06:25 +08:00
34 changed files with 405 additions and 145 deletions

View File

@@ -1234,6 +1234,8 @@ NOTSRCCOPY
NOTSRCERASE
Notupdated
notwindows
NOTXORPEN
Nouveaut
nowarn
NOZORDER
NPH

View File

@@ -2,6 +2,34 @@
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
Cold "Rebuild All" ordering fix for native PackageReference projects.
A handful of native projects use <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
(Microsoft.CommandPalette.Extensions, Microsoft.Terminal.UI, PowerToys.MeasureToolCore,
FindMyMouse, PowerRenameUILib, runner). For those, the CppWinRT configuration - most importantly
the MIDL default <EnableWindowsRuntime>true</EnableWindowsRuntime> that makes IInspectable /
IUnknown resolvable - only arrives via the restore-generated obj\*.nuget.g.props.
On a cold "Rebuild All", MSBuild evaluates the project (resolving imports) before the in-session
NuGet restore regenerates those obj props, so MIDL runs in non-WinRT mode and fails with
"MIDL2009: undefined symbol IInspectable". Because Microsoft.CommandPalette.Extensions and
Microsoft.Terminal.UI are winmd producers consumed (by file path) across the entire Command
Palette graph, that single race cascades into dozens of downstream CS0006/CS0234 failures. A
second build "works" only because restore has since written the obj props. This is why the
RestoreThenBuild PowerShell helper (two separate msbuild invocations) already avoids the issue.
Statically importing the committed CppWinRT props here makes the WinRT MIDL configuration present
at evaluation time regardless of restore ordering, so it is durable across Visual Studio, the
build scripts, and CI. It is scoped to PackageReference-style vcxproj only (the ~100 other native
projects already import this same committed package directly), and the Exists() guard plus
CppWinRT's own import guards keep it a safe no-op once restore has run.
-->
<Import Project="$(MSBuildThisFileDirectory)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props"
Condition="'$(MSBuildProjectExtension)' == '.vcxproj'
and '$(RestoreProjectStyle)' == 'PackageReference'
and Exists('$(MSBuildThisFileDirectory)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
<!-- Skip building C++ test projects when BuildTests=false -->
<PropertyGroup Condition="'$(_IsSkippedTestProject)' == 'true'">
<UsePrecompiledHeaders>false</UsePrecompiledHeaders>

View File

@@ -13,4 +13,25 @@
-->
<Import Project="$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg.targets"
Condition="'$(MSBuildProjectExtension)' == '.vcxproj' and '$(VcpkgEnabled)' == 'true' and Exists('$(VcpkgRoot)\scripts\buildsystems\msbuild\vcpkg.targets')" />
<!--
Cold "Rebuild All" ordering fix (matching partner to the CppWinRT props import in Cpp.Build.props).
Native PackageReference projects (Microsoft.CommandPalette.Extensions, Microsoft.Terminal.UI,
PowerToys.MeasureToolCore, FindMyMouse, PowerRenameUILib, runner) receive the CppWinRT MIDL
metadata wiring (CppWinRTMidlResponseFile, AdditionalMetadataDirectories, the MdMerge step that
produces the .winmd) only from the restore-generated obj\*.nuget.g.targets. On a cold "Rebuild
All" that file has not been regenerated yet when the project is evaluated, so MIDL cannot resolve
IInspectable / IUnknown and the Command Palette graph fails with MIDL2009 - until a second build.
Importing the committed CppWinRT targets here - after Microsoft.Cpp.targets, exactly where the
statically-wired native projects put their own CppWinRT ExtensionTargets import - makes that wiring
present regardless of restore ordering. Scoped to PackageReference-style vcxproj only; the Exists()
guard and CppWinRT's own import guards make it a safe no-op once restore has run or for the ~100
native projects that already import this committed package directly.
-->
<Import Project="$(MSBuildThisFileDirectory)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.targets"
Condition="'$(MSBuildProjectExtension)' == '.vcxproj'
and '$(RestoreProjectStyle)' == 'PackageReference'
and Exists('$(MSBuildThisFileDirectory)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
</Project>

View File

@@ -26,7 +26,7 @@
<PackageVersion Include="CommunityToolkit.WinUI.Controls.Sizers" Version="8.2.251219" />
<PackageVersion Include="CommunityToolkit.WinUI.Converters" Version="8.2.251219" />
<PackageVersion Include="CommunityToolkit.WinUI.Extensions" Version="8.2.251219" />
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
<PackageVersion Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.2" />
<PackageVersion Include="CommunityToolkit.Labs.WinUI.Controls.MarkdownTextBlock" Version="0.1.260116-build.2514" />
<PackageVersion Include="ControlzEx" Version="6.0.0" />
<PackageVersion Include="HelixToolkit" Version="2.24.0" />
@@ -38,7 +38,7 @@
<PackageVersion Include="Mages" Version="3.0.0" />
<PackageVersion Include="Markdig.Signed" Version="0.34.0" />
<!-- Including MessagePack to force version, since it's used by StreamJsonRpc but contains vulnerabilities. After StreamJsonRpc updates the version of MessagePack, we can upgrade StreamJsonRpc instead. -->
<PackageVersion Include="MessagePack" Version="3.1.3" />
<PackageVersion Include="MessagePack" Version="3.1.7" />
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.102" />
<PackageVersion Include="Microsoft.CommandPalette.Extensions" Version="0.9.260303001" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="10.0.8" />
@@ -64,7 +64,7 @@
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.MistralAI" Version="1.71.0-alpha" />
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.Ollama" Version="1.71.0-alpha" />
<PackageVersion Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.3719.77" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.4022.49" />
<!-- Package Microsoft.Win32.SystemEvents added as a hack for being able to exclude the runtime assets so they don't conflict with 8.0.1. This is a dependency of System.Drawing.Common but the 8.0.1 version wasn't published to nuget. -->
<PackageVersion Include="Microsoft.Win32.SystemEvents" Version="10.0.8" />
<PackageVersion Include="Microsoft.WindowsPackageManager.ComInterop" Version="1.10.340" />
@@ -76,7 +76,7 @@
This is present due to a bug in CsWinRT where WPF projects cause the analyzer to fail.
-->
<PackageVersion Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
<PackageVersion Include="Microsoft.Windows.ImplementationLibrary" Version="1.0.250325.1"/>
<PackageVersion Include="Microsoft.Windows.ImplementationLibrary" Version="1.0.250325.1" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.6901" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="2.2.0" />
<PackageVersion Include="Microsoft.WindowsAppSDK.Foundation" Version="2.1.0" />
@@ -151,4 +151,4 @@
<PackageVersion Include="Microsoft.VariantAssignment.Client" Version="2.4.17140001" />
<PackageVersion Include="Microsoft.VariantAssignment.Contract" Version="3.0.16990001" />
</ItemGroup>
</Project>
</Project>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.250325.1" targetFramework="native" />
</packages>
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.260126.7" targetFramework="native" />
</packages>

View File

@@ -39,6 +39,7 @@
</ItemGroup>
<ItemGroup>
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natstepfilter" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.250325.1" targetFramework="native" />
</packages>
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.260126.7" targetFramework="native" />
</packages>

View File

@@ -119,7 +119,7 @@
</resheader>
<data name="context_menu_item_new" xml:space="preserve">
<value>New+</value>
<comment>The main context menu item that users click on. This should be localized to match New in Windows. e.g. Danish it would become Ny+</comment>
<comment>The main context menu item that users click on. This should be localized to match New in Windows. e.g. Danish it would become Ny+, French it would become Nouveau+ (not Nouveauté+)</comment>
</data>
<data name="context_menu_item_open_templates" xml:space="preserve">
<value>Open templates</value>

View File

@@ -119,7 +119,7 @@
</resheader>
<data name="context_menu_item_new" xml:space="preserve">
<value>New+</value>
<comment>The main context menu item that users click on. This should be localized to match New in Windows. e.g. Danish it would become Ny+</comment>
<comment>The main context menu item that users click on. This should be localized to match New in Windows. e.g. Danish it would become Ny+, French it would become Nouveau+ (not Nouveauté+)</comment>
</data>
<data name="context_menu_item_open_templates" xml:space="preserve">
<value>Open templates</value>

View File

@@ -0,0 +1,98 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text;
namespace Microsoft.CmdPal.Common.Helpers;
public static class ShellArgumentBuilder
{
public static string BuildArguments(params string[] arguments)
{
if (arguments.Length <= 0)
{
return string.Empty;
}
var stringBuilder = new StringBuilder();
foreach (var argument in arguments)
{
AppendArgument(stringBuilder, argument);
}
return stringBuilder.ToString();
}
private static void AppendArgument(StringBuilder stringBuilder, string argument)
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(' ');
}
if (argument.Length == 0 || ShouldBeQuoted(argument))
{
stringBuilder.Append('"');
var index = 0;
while (index < argument.Length)
{
var c = argument[index++];
if (c == '\\')
{
var numBackSlash = 1;
while (index < argument.Length && argument[index] == '\\')
{
index++;
numBackSlash++;
}
if (index == argument.Length)
{
stringBuilder.Append('\\', numBackSlash * 2);
}
else if (argument[index] == '"')
{
stringBuilder.Append('\\', (numBackSlash * 2) + 1);
stringBuilder.Append('"');
index++;
}
else
{
stringBuilder.Append('\\', numBackSlash);
}
continue;
}
if (c == '"')
{
stringBuilder.Append('\\');
stringBuilder.Append('"');
continue;
}
stringBuilder.Append(c);
}
stringBuilder.Append('"');
}
else
{
stringBuilder.Append(argument);
}
}
private static bool ShouldBeQuoted(string argument)
{
foreach (var c in argument)
{
if (char.IsWhiteSpace(c) || c == '"')
{
return true;
}
}
return false;
}
}

View File

@@ -94,6 +94,7 @@ internal sealed partial class HttpCachingClient : IDisposable
public void Dispose()
{
_httpClient.Dispose();
_cacheHandler.Dispose();
}
private static bool IsSupportedHttpUri(Uri resourceUri)

View File

@@ -146,13 +146,7 @@ public sealed partial class MainListPage : DynamicListPage,
// The all apps page will kick off a BG thread to start loading apps.
// We just want to know when it is done.
var allApps = AllAppsCommandProvider.Page;
allApps.PropChanged += (s, p) =>
{
if (p.PropertyName == nameof(allApps.IsLoading))
{
IsLoading = ActuallyLoading();
}
};
allApps.PropChanged += AllApps_PropChanged;
WeakReferenceMessenger.Default.Register<ClearSearchMessage>(this);
WeakReferenceMessenger.Default.Register<UpdateFallbackItemsMessage>(this);
@@ -172,6 +166,14 @@ public sealed partial class MainListPage : DynamicListPage,
}
}
private void AllApps_PropChanged(object? sender, IPropChangedEventArgs e)
{
if (e.PropertyName == nameof(AllAppsCommandProvider.Page.IsLoading))
{
IsLoading = ActuallyLoading();
}
}
private void PinnedCommands_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
_defaultViewDirty = true;
@@ -782,6 +784,8 @@ public sealed partial class MainListPage : DynamicListPage,
_tlcManager.TopLevelCommands.CollectionChanged -= Commands_CollectionChanged;
_tlcManager.PinnedCommands.CollectionChanged -= PinnedCommands_CollectionChanged;
AllAppsCommandProvider.Page.PropChanged -= AllApps_PropChanged;
if (_settingsService is not null)
{
_settingsService.SettingsChanged -= SettingsChangedHandler;

View File

@@ -541,6 +541,9 @@ public partial class WinRTExtensionService : IExtensionService, IDisposable
{
if (disposing)
{
_catalog.PackageInstalling -= Catalog_PackageInstalling;
_catalog.PackageUninstalling -= Catalog_PackageUninstalling;
_catalog.PackageUpdating -= Catalog_PackageUpdating;
_getInstalledExtensionsLock.Dispose();
}

View File

@@ -94,6 +94,7 @@ internal sealed partial class BlurImageControl : Control
private SpriteVisual? _effectVisual;
private CompositionEffectBrush? _effectBrush;
private CompositionSurfaceBrush? _imageBrush;
private LoadedImageSurface? _lastLoadedSurface;
public BlurImageControl()
{
@@ -379,10 +380,20 @@ internal sealed partial class BlurImageControl : Control
}
Logger.LogDebug($"Starting load of BlurImageControl from '{bitmapImage.UriSource}'");
// Each call to LoadImageAsync creates a new LoadedImageSurface backed by native
// composition resources. The old surface becomes unrooted once the brush points at
// the new one, so it isn't leaked, but dispose it explicitly so the unmanaged
// resources are released deterministically instead of waiting for finalization.
var previousSurface = _lastLoadedSurface;
var loadedSurface = LoadedImageSurface.StartLoadFromUri(bitmapImage.UriSource);
_lastLoadedSurface = loadedSurface;
loadedSurface.LoadCompleted += OnLoadedSurfaceOnLoadCompleted;
SetLoadedSurfaceToBrush(loadedSurface);
_effectBrush?.SetSourceParameter(ImageSourceParameterName, _imageBrush);
previousSurface?.Dispose();
}
catch (Exception ex)
{

View File

@@ -8,7 +8,9 @@ using Microsoft.CmdPal.UI.ViewModels;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Automation;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Windows.System;
namespace Microsoft.CmdPal.UI.Controls;
@@ -22,6 +24,7 @@ public sealed partial class ContentFormControl : UserControl
// tree. If this gets GC'ed, then it'll revoke our Action handler, and the
// form will do seemingly nothing.
private RenderedAdaptiveCard? _renderedCard;
private AdaptiveCard? _adaptiveCard;
public ContentFormViewModel? ViewModel { get => _viewModel; set => AttachViewModel(value); }
@@ -95,9 +98,11 @@ public sealed partial class ContentFormControl : UserControl
private void DisplayCard(AdaptiveCardParseResult result)
{
_renderedCard = _renderer.RenderAdaptiveCard(result.AdaptiveCard);
_adaptiveCard = result.AdaptiveCard;
ContentGrid.Children.Clear();
if (_renderedCard.FrameworkElement is not null)
{
_renderedCard.FrameworkElement.KeyDown += OnFormKeyDown;
ContentGrid.Children.Add(_renderedCard.FrameworkElement);
// Use the Loaded event to ensure we focus after the card is in the visual tree
@@ -114,8 +119,9 @@ public sealed partial class ContentFormControl : UserControl
private void OnFrameworkElementLayoutUpdated(object? sender, object e)
{
// Only fix once — unhook after first layout pass
if (_renderedCard?.FrameworkElement is FrameworkElement element)
// Only fix once — unhook from sender (not _renderedCard, which may have been
// reassigned by the time this fires).
if (sender is FrameworkElement element)
{
element.LayoutUpdated -= OnFrameworkElementLayoutUpdated;
FixToggleAccessibilityNames(element);
@@ -276,6 +282,50 @@ public sealed partial class ContentFormControl : UserControl
return null;
}
private void OnFormKeyDown(object sender, KeyRoutedEventArgs e)
{
// Snapshot the fields so a subsequent DisplayCard call can't swap the
// rendered/parsed card out from under us mid-method. This keeps the
// resolved submit action and the gathered inputs from the same card.
var renderedCard = _renderedCard;
var adaptiveCard = _adaptiveCard;
if (e.Key != VirtualKey.Enter || renderedCard == null || adaptiveCard == null)
{
return;
}
// Only submit when Enter is pressed inside a single-line TextBox
if (e.OriginalSource is TextBox textBox && !textBox.AcceptsReturn)
{
// Find the first Submit or Execute action on the card
IAdaptiveActionElement? submitAction = null;
foreach (var action in adaptiveCard.Actions)
{
if (action is AdaptiveSubmitAction or AdaptiveExecuteAction)
{
submitAction = action;
break;
}
}
if (submitAction != null)
{
e.Handled = true;
// Validate (and gather) the inputs before submitting. AsJson() only
// returns the values cached by a successful ValidateInputs() call, so
// skipping this would submit an empty payload. This mirrors what the
// renderer does internally when a submit button is clicked.
var inputs = renderedCard.UserInputs;
if (inputs.ValidateInputs(submitAction))
{
ViewModel?.HandleSubmit(submitAction, inputs.AsJson());
}
}
}
}
private void Rendered_Action(RenderedAdaptiveCard sender, AdaptiveActionEventArgs args) =>
ViewModel?.HandleSubmit(args.Action, args.Inputs.AsJson());
}

View File

@@ -192,7 +192,7 @@ public sealed partial class MainWindow : WindowEx,
App.Current.Services.GetRequiredService<ISettingsService>().SettingsChanged += SettingsChangedHandler;
// Make sure that we update the acrylic theme when the OS theme changes
RootElement.ActualThemeChanged += (s, e) => DispatcherQueue.TryEnqueue(UpdateBackdrop);
RootElement.ActualThemeChanged += RootElement_ActualThemeChanged;
// Hardcoding event name to avoid bringing in the PowerToys.interop dependency. Event name must match CMDPAL_SHOW_EVENT from shared_constants.h
NativeEventWaiter.WaitForEventLoop("Local\\PowerToysCmdPal-ShowEvent-62336fcd-8611-4023-9b30-091a6af4cc5a", () =>
@@ -222,6 +222,11 @@ public sealed partial class MainWindow : WindowEx,
UpdateBackdrop();
}
private void RootElement_ActualThemeChanged(FrameworkElement sender, object args)
{
DispatcherQueue.TryEnqueue(UpdateBackdrop);
}
private static void LocalKeyboardListener_OnKeyPressed(object? sender, LocalKeyboardListenerKeyPressedEventArgs e)
{
if (e.Key == VirtualKey.GoBack)
@@ -1683,6 +1688,9 @@ public sealed partial class MainWindow : WindowEx,
public void Dispose()
{
_themeService.ThemeChanged -= ThemeServiceOnThemeChanged;
App.Current.Services.GetRequiredService<ISettingsService>().SettingsChanged -= SettingsChangedHandler;
_localKeyboardListener.Dispose();
_windowThemeSynchronizer.Dispose();
DisposeAcrylic();

View File

@@ -22,6 +22,7 @@ public sealed partial class ExtensionsPage : Page
private readonly SettingsViewModel? viewModel;
private readonly Dictionary<string, WeakReference<SettingsCard>> _vmToCardMap = new();
private readonly Dictionary<SettingsCard, ProviderSettingsViewModel> _cardToVmMap = new();
public ExtensionsPage()
{
@@ -31,6 +32,23 @@ public sealed partial class ExtensionsPage : Page
var themeService = App.Current.Services.GetService<IThemeService>()!;
var settingsService = App.Current.Services.GetRequiredService<ISettingsService>();
viewModel = new SettingsViewModel(topLevelCommandManager, _mainTaskScheduler, themeService, settingsService);
Unloaded += ExtensionsPage_Unloaded;
}
private void ExtensionsPage_Unloaded(object sender, RoutedEventArgs e)
{
// ProviderSettingsViewModel subscribes to its CommandProviderWrapper (owned by the
// singleton TopLevelCommandManager), so a live VM roots this page through the
// PropertyChanged handler below. Drain any VMs still hooked when the page is torn
// down; SettingsCard_DataContextChanged only unhooks the ones that get recycled.
foreach (var vm in _cardToVmMap.Values)
{
vm.PropertyChanged -= ProviderViewModel_PropertyChanged;
}
_cardToVmMap.Clear();
_vmToCardMap.Clear();
}
private void SettingsCard_Click(object sender, RoutedEventArgs e)
@@ -46,16 +64,28 @@ public sealed partial class ExtensionsPage : Page
private void SettingsCard_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
{
// Store the card reference keyed by Id (not the VM itself) to avoid leaking VM references
if (sender is SettingsCard card && card.DataContext is ProviderSettingsViewModel newVm)
if (sender is SettingsCard card)
{
_vmToCardMap[newVm.Id] = new WeakReference<SettingsCard>(card);
newVm.PropertyChanged += ProviderViewModel_PropertyChanged;
// Immediately update automation name in case DisplayName is already available
if (card.Content is ToggleSwitch toggle && !string.IsNullOrEmpty(newVm.DisplayName))
// Unsubscribe from the previous ViewModel to prevent handler accumulation
// when virtualization recycles items with a new DataContext.
if (_cardToVmMap.TryGetValue(card, out var oldVm))
{
AutomationProperties.SetName(toggle, newVm.DisplayName);
oldVm.PropertyChanged -= ProviderViewModel_PropertyChanged;
_cardToVmMap.Remove(card);
}
// Store the card reference keyed by Id (not the VM itself) to avoid leaking VM references
if (card.DataContext is ProviderSettingsViewModel newVm)
{
_vmToCardMap[newVm.Id] = new WeakReference<SettingsCard>(card);
_cardToVmMap[card] = newVm;
newVm.PropertyChanged += ProviderViewModel_PropertyChanged;
// Immediately update automation name in case DisplayName is already available
if (card.Content is ToggleSwitch toggle && !string.IsNullOrEmpty(newVm.DisplayName))
{
AutomationProperties.SetName(toggle, newVm.DisplayName);
}
}
}
}

View File

@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.CmdPal.Common.Helpers;
namespace Microsoft.CmdPal.Common.UnitTests.Helpers;
[TestClass]
public class ShellArgumentBuilderTests
{
[DataTestMethod]
[DataRow("plain", "plain")]
[DataRow("C:\\Program Files\\PowerToys", "\"C:\\Program Files\\PowerToys\"")]
[DataRow("say \"hello\"", "\"say \\\"hello\\\"\"")]
[DataRow("", "\"\"")]
[DataRow("C:\\Program Files\\", "\"C:\\Program Files\\\\\"")]
public void BuildArguments_FormatsSingleArgument(string argument, string expected)
{
var actual = ShellArgumentBuilder.BuildArguments(argument);
Assert.AreEqual(expected, actual);
}
[TestMethod]
public void BuildArguments_FormatsMultipleArguments()
{
var actual = ShellArgumentBuilder.BuildArguments("plain", "C:\\Program Files\\PowerToys", "two words");
Assert.AreEqual("plain \"C:\\Program Files\\PowerToys\" \"two words\"", actual);
}
}

View File

@@ -5,6 +5,7 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
using ManagedCommon;
using Microsoft.CmdPal.Common.Helpers;
namespace Microsoft.CmdPal.Ext.Bookmarks.Helpers;
@@ -24,7 +25,7 @@ internal static class CommandLauncher
// You can notice the difference with Recycle Bin for example:
// - "explorer ::{645FF040-5081-101B-9F08-00AA002F954E}"
// - "::{645FF040-5081-101B-9F08-00AA002F954E}"
return ShellHelpers.OpenInShell("explorer.exe", classification.Target);
return ShellHelpers.OpenInShell("explorer.exe", ShellArgumentBuilder.BuildArguments(classification.Target));
case LaunchMethod.ActivateAppId:
return ActivateAppId(classification.Target, classification.Arguments);

View File

@@ -11,6 +11,7 @@
<ProjectPriFileName>Microsoft.CmdPal.Ext.Bookmarks.pri</ProjectPriFileName>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Microsoft.CmdPal.Common\Microsoft.CmdPal.Common.csproj" />
<ProjectReference Include="..\..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
<ProjectReference Include="..\..\ext\Microsoft.CmdPal.Ext.Indexer\Microsoft.CmdPal.Ext.Indexer.csproj" />
</ItemGroup>

View File

@@ -2,7 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text;
using Microsoft.CmdPal.Common.Helpers;
using Microsoft.CommandPalette.Extensions.Toolkit;
namespace Microsoft.CmdPal.Ext.Shell.Helpers;
@@ -42,98 +42,7 @@ public class ShellListPageHelpers
executable = segments[0];
if (segments.Length > 1)
{
arguments = ArgumentBuilder.BuildArguments(segments[1..]);
}
}
private static class ArgumentBuilder
{
internal static string BuildArguments(string[] arguments)
{
if (arguments.Length <= 0)
{
return string.Empty;
}
var stringBuilder = new StringBuilder();
foreach (var argument in arguments)
{
AppendArgument(stringBuilder, argument);
}
return stringBuilder.ToString();
}
private static void AppendArgument(StringBuilder stringBuilder, string argument)
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(' ');
}
if (argument.Length == 0 || ShouldBeQuoted(argument))
{
stringBuilder.Append('\"');
var index = 0;
while (index < argument.Length)
{
var c = argument[index++];
if (c == '\\')
{
var numBackSlash = 1;
while (index < argument.Length && argument[index] == '\\')
{
index++;
numBackSlash++;
}
if (index == argument.Length)
{
stringBuilder.Append('\\', numBackSlash * 2);
}
else if (argument[index] == '\"')
{
stringBuilder.Append('\\', (numBackSlash * 2) + 1);
stringBuilder.Append('\"');
index++;
}
else
{
stringBuilder.Append('\\', numBackSlash);
}
continue;
}
if (c == '\"')
{
stringBuilder.Append('\\');
stringBuilder.Append('\"');
continue;
}
stringBuilder.Append(c);
}
stringBuilder.Append('\"');
}
else
{
stringBuilder.Append(argument);
}
}
private static bool ShouldBeQuoted(string s)
{
foreach (var c in s)
{
if (char.IsWhiteSpace(c) || c == '\"')
{
return true;
}
}
return false;
arguments = ShellArgumentBuilder.BuildArguments(segments[1..]);
}
}
}

View File

@@ -27,7 +27,7 @@ public partial class ShowFileInFolderCommand : InvokableCommand
try
{
var argument = "/select, \"" + _path + "\"";
Process.Start("explorer.exe", argument);
using var process = Process.Start("explorer.exe", argument);
}
catch (Exception)
{

View File

@@ -866,6 +866,14 @@ void FancyZones::UpdateWorkAreas(bool updateWindowPositions) noexcept
std::vector<FancyZonesDataTypes::MonitorId> monitors = { FancyZonesDataTypes::MonitorId{ .monitor = nullptr, .deviceId = { .id = ZonedWindowProperties::MultiMonitorName, .instanceId = ZonedWindowProperties::MultiMonitorInstance } } };
if (ShouldWorkAreasBeRecreated(monitors, currentVirtualDesktop, m_workAreaConfiguration.GetAllWorkAreas()))
{
// WindowMouseSnap caches a raw WorkArea* in m_currentWorkArea and the
// WorkArea map by reference. WorkAreaConfiguration::Clear() destroys
// every unique_ptr<WorkArea> (and hence the inner ZonesOverlay and
// its std::mutex). If a drag is in flight, the next MoveSizeUpdate
// would dereference that dangling WorkArea* and lock the freed
// mutex. Drain the active drag first so subsequent drag messages
// hit the snapper's `if (m_windowMouseSnapper)` guard and no-op.
MoveSizeEnd();
m_workAreaConfiguration.Clear();
FancyZonesDataTypes::WorkAreaId workAreaId;
@@ -882,6 +890,8 @@ void FancyZones::UpdateWorkAreas(bool updateWindowPositions) noexcept
if (ShouldWorkAreasBeRecreated(monitors, currentVirtualDesktop, workAreas))
{
// See comment above the matching Clear() in the span-zones branch.
MoveSizeEnd();
m_workAreaConfiguration.Clear();
for (const auto& monitor : monitors)
{
@@ -1094,6 +1104,9 @@ void FancyZones::SettingsUpdate(SettingId id)
break;
case SettingId::SpanZonesAcrossMonitors:
{
// See UpdateWorkAreas() — same WindowMouseSnap dangling-WorkArea*
// hazard if the user toggles this setting mid-drag.
MoveSizeEnd();
m_workAreaConfiguration.Clear();
PostMessageW(m_window, WM_PRIV_INIT, NULL, NULL);
}

View File

@@ -48,7 +48,14 @@ void OnThreadExecutor::worker_thread()
OnThreadExecutor::~OnThreadExecutor()
{
_shutdown_request = true;
{
// Modify the shared shutdown flag while holding the mutex so the
// worker reliably observes it on its next wake. Without this, a notify
// racing the worker entering _task_cv.wait can be missed and the join
// below hangs forever.
std::lock_guard lock{ _task_mutex };
_shutdown_request = true;
}
_task_cv.notify_one();
_worker_thread.join();
}

View File

@@ -115,6 +115,11 @@ WorkArea::WorkArea(HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& u
WorkArea::~WorkArea()
{
// Tear down the renderer (joining its background thread) before returning
// the HWND to the pool. Otherwise, the render thread can still be drawing
// through m_renderTarget into an HWND that has already been recycled by a
// subsequent NewZonesOverlayWindow call.
m_zonesOverlay.reset();
windowPool.FreeZonesOverlayWindow(m_window);
}

View File

@@ -340,13 +340,19 @@ void ZonesOverlay::DrawActiveZoneSet(const ZonesMap& zones,
ZonesOverlay::~ZonesOverlay()
{
// Constructor early-returns (e.g. CreateHwndRenderTarget failing during a
// display-driver TDR) leave m_renderThread default-constructed; calling
// join() on a non-joinable thread terminates the process.
if (m_renderThread.joinable())
{
std::unique_lock lock(m_mutex);
m_abortThread = true;
m_shouldRender = true;
{
std::unique_lock lock(m_mutex);
m_abortThread = true;
m_shouldRender = true;
}
m_cv.notify_all();
m_renderThread.join();
}
m_cv.notify_all();
m_renderThread.join();
if (m_renderTarget)
{

View File

@@ -26,6 +26,31 @@
<ProjectReference Include="..\ui\ImageResizerUI.csproj" />
</ItemGroup>
<!--
MSB3030 parallel-build race hardening.
ImageResizerUI is a self-contained WinUI 3 app whose PowerToys.ImageResizer.runtimeconfig.json
and PowerToys.ImageResizer.deps.json are written late into the shared WinUI3Apps output folder.
This unit test project references ImageResizerUI only for its types (see InternalsVisibleTo
"ImageResizer.Test" in ImageResizerUI.csproj); it never launches the app, so it does not need
those two app runtime json files. During a highly parallel "Build All" the test's
copy-to-output step can run before those files exist, producing:
MSB3030: Could not copy the file "...\PowerToys.ImageResizer.runtimeconfig.json" because it was not found.
Removing just those two never-needed files from this project's copy-to-output lists makes the
race impossible. The referenced PowerToys.ImageResizer.dll is still copied, so tests run normally.
-->
<Target Name="ExcludeReferencedAppRuntimeJsonFromCopy"
AfterTargets="GetCopyToOutputDirectoryItems">
<ItemGroup>
<_SourceItemsToCopyToOutputDirectory
Remove="@(_SourceItemsToCopyToOutputDirectory)"
Condition="'%(Filename)%(Extension)' == 'PowerToys.ImageResizer.runtimeconfig.json' or '%(Filename)%(Extension)' == 'PowerToys.ImageResizer.deps.json'" />
<_SourceItemsToCopyToOutputDirectoryAlways
Remove="@(_SourceItemsToCopyToOutputDirectoryAlways)"
Condition="'%(Filename)%(Extension)' == 'PowerToys.ImageResizer.runtimeconfig.json' or '%(Filename)%(Extension)' == 'PowerToys.ImageResizer.deps.json'" />
</ItemGroup>
</Target>
<ItemGroup>
<Content Include="Test.gif">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View File

@@ -59,7 +59,6 @@
</PropertyGroup>
<!-- Props that are constant for both Debug and Release configurations -->
<PropertyGroup Label="Configuration">
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutDir>
<CharacterSet>Unicode</CharacterSet>
<SpectreMitigation>Spectre</SpectreMitigation>
@@ -164,7 +163,7 @@
<Import Project="..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.7\build\native\Microsoft.VCRTForwarders.140.targets" Condition="Exists('..\..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.7\build\native\Microsoft.VCRTForwarders.140.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Web.WebView2.1.0.4022.49\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.4022.49\build\native\Microsoft.Web.WebView2.targets')" />
</ImportGroup>
<Import Project="..\..\..\..\deps\spdlog.props" />
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
@@ -181,7 +180,7 @@
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.7\build\native\Microsoft.VCRTForwarders.140.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.VCRTForwarders.140.1.0.7\build\native\Microsoft.VCRTForwarders.140.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.4022.49\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Web.WebView2.1.0.4022.49\build\native\Microsoft.Web.WebView2.targets'))" />
</Target>
<Target Name="FakeResourcesPriMerge" BeforeTargets="FinalizeBuildStatus" DependsOnTargets="CopyFilesToOutputDirectory">
<Message Text="Renaming Microsoft.UI.Xaml.pri to resources.pri" />

View File

@@ -3,6 +3,6 @@
<package id="Microsoft.Toolkit.Win32.UI.XamlApplication" version="6.1.3" targetFramework="native" />
<package id="Microsoft.UI.Xaml" version="2.8.2-prerelease.220830001" targetFramework="native" />
<package id="Microsoft.VCRTForwarders.140" version="1.0.7" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2903.40" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.4022.49" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.250303.1" targetFramework="native" />
</packages>

View File

@@ -15,7 +15,6 @@
<OutDir>..\..\..\..\$(Platform)\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Label="Configuration">
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -101,7 +100,7 @@
<Import Project="..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\..\..\..\packages\Microsoft.Web.WebView2.1.0.4022.49\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.4022.49\build\native\Microsoft.Web.WebView2.targets')" />
</ImportGroup>
<Import Project="..\..\..\..\deps\spdlog.props" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
@@ -114,7 +113,7 @@
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Toolkit.Win32.UI.XamlApplication.6.1.3\build\native\Microsoft.Toolkit.Win32.UI.XamlApplication.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.props'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.UI.Xaml.2.8.2-prerelease.220830001\build\native\Microsoft.UI.Xaml.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Web.WebView2.1.0.2903.40\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\..\..\..\packages\Microsoft.Web.WebView2.1.0.4022.49\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Microsoft.Web.WebView2.1.0.4022.49\build\native\Microsoft.Web.WebView2.targets'))" />
</Target>
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(SolutionDir)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory)\..\KeyboardManagerEditor\ resource.base.h resource.h KeyboardManagerEditor.base.rc KeyboardManagerEditor.rc" />

View File

@@ -2,6 +2,6 @@
<packages>
<package id="Microsoft.Toolkit.Win32.UI.XamlApplication" version="6.1.3" targetFramework="native" />
<package id="Microsoft.UI.Xaml" version="2.8.2-prerelease.220830001" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2903.40" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.4022.49" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.250303.1" targetFramework="native" />
</packages>

View File

@@ -22,6 +22,7 @@ public partial class PowerAccent : IDisposable
private const double ScreenMinPadding = 150;
private bool _visible;
private int _showGeneration;
private string[] _characters = Array.Empty<string>();
private string[] _characterDescriptions = Array.Empty<string>();
private int _selectedIndex = -1;
@@ -98,6 +99,10 @@ public partial class PowerAccent : IDisposable
_initialShiftState = WindowsFunctions.IsShiftState();
_visible = true;
// Each summon gets a generation id so a delayed render queued by an earlier
// press can't fire for a newer one (or after the toolbar was hidden).
int generation = ++_showGeneration;
_characters = GetCharacters(letterKey);
_characterDescriptions = GetCharacterDescriptions(_characters);
_showUnicodeDescription = _settingService.ShowUnicodeDescription;
@@ -105,7 +110,7 @@ public partial class PowerAccent : IDisposable
Task.Delay(_settingService.InputTime).ContinueWith(
t =>
{
if (_visible)
if (_visible && generation == _showGeneration)
{
OnChangeDisplay?.Invoke(true, _characters);
}
@@ -237,6 +242,7 @@ public partial class PowerAccent : IDisposable
OnChangeDisplay?.Invoke(false, null);
_selectedIndex = -1;
_visible = false;
_showGeneration++;
}
private void ProcessNextChar(TriggerKey triggerKey, bool shiftPressed)

View File

@@ -207,7 +207,7 @@
<controls:PageLink x:Uid="NewPlus_Learn_More" Link="https://aka.ms/PowerToysOverview_NewPlus" />
</controls:SettingsPageControl.PrimaryLinks>
<controls:SettingsPageControl.SecondaryLinks>
<controls:PageLink Link="https://www.linkedin.com/in/christian-gaardmark/" Text="Christian Gaardmark" />
<controls:PageLink Link="https://www.onegreatworld.com/products/productivity-plus-pack/?ref=settings_pt" Text="Based on Christian Gaardmark's New++ from the Productivity Plus Pack" />
</controls:SettingsPageControl.SecondaryLinks>
</controls:SettingsPageControl>

View File

@@ -4432,22 +4432,22 @@ Activate by holding the key for the character you want to add an accent to, then
</data>
<data name="NewPlus.ModuleTitle" xml:space="preserve">
<value>New+</value>
<comment>New+ is the name of the utility. Localize product name in accordance with Windows New</comment>
<comment>New+ is the name of the utility. Localize product name in accordance with Windows New. e.g. French would be Nouveau+ (not Nouveauté+)</comment>
</data>
<data name="NewPlus.ModuleDescription" xml:space="preserve">
<value>Create files and folders from a personalized set of templates</value>
</data>
<data name="NewPlus_Product_Name.Content" xml:space="preserve">
<value>New+</value>
<comment>New+ is the name of the utility. Localize product name in accordance with Windows New</comment>
<comment>New+ is the name of the utility. Localize product name in accordance with Windows New. e.g. French would be Nouveau+ (not Nouveauté+)</comment>
</data>
<data name="NewPlus_Learn_More.Text" xml:space="preserve">
<value>Learn more about New+</value>
<comment>New+ learn more link. Localize product name in accordance with Windows New</comment>
<comment>New+ learn more link. Localize product name in accordance with Windows New. e.g. French would be Nouveau+ (not Nouveauté+)</comment>
</data>
<data name="NewPlus_Enable_Toggle.Header" xml:space="preserve">
<value>New+</value>
<comment>Localize product name in accordance with Windows New</comment>
<comment>Localize product name in accordance with Windows New. e.g. French would be Nouveau+ (not Nouveauté+)</comment>
</data>
<data name="NewPlus_TemplatesNotBackupAndRestoreWarning.Title" xml:space="preserve">
<value>PowerToys "Back up and Restore" feature doesn't take templates into account at this moment. If you use that feature, templates will have to be copied manually.</value>
@@ -4534,7 +4534,7 @@ Activate by holding the key for the character you want to add an accent to, then
</data>
<data name="Oobe_NewPlus.Title" xml:space="preserve">
<value>New+</value>
<comment>New+ is the name of the utility. Localize product name in accordance with Windows New</comment>
<comment>New+ is the name of the utility. Localize product name in accordance with Windows New. e.g. French would be Nouveau+ (not Nouveauté+)</comment>
</data>
<data name="Oobe_NewPlus.Description" xml:space="preserve">
<value>Create files and folders from a personalized set of templates.</value>