Skip to content

Commit 97c1de8

Browse files
CmdPal: Light, dark, pink, and unicorns (#43505)
<!-- 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 This PR introduces user settings for app mode themes (dark, light, or system) and background customization options, including custom colors, system accent colors, or custom images. - Adds a new page to the Settings window with new appearance settings and moves some existing settings there as well. - Introduces a new core-level service abstraction, `IThemeService`, that holds the state for the current theme. - Uses the helper class `ResourceSwapper` to update application-level XAML resources. The way WinUI / XAML handles these is painful, and XAML Hot Reload is pain². Initialization must be lazy, as XAML resources can only be accessed after the window is activated. - `ThemeService` takes app and system settings and selects one of the registered `IThemeProvider`s to calculate visuals and choose the appropriate XAML resources. - At the moment, there are two: - `NormalThemeProvider` - Provides the current uncolorized light and dark styles - `ms-appx:///Styles/Theme.Normal.xaml` - `ColorfulThemeProvider` - Style that matches the Windows 11 visual style (based on the Start menu) and colors - `ms-appx:///Styles/Theme.Colorful.xaml` - Applied when the background is colorized or a background image is selected - The app theme is applied only on the main window (`WindowThemeSynchronizer` helper class can be used to synchronize other windows if needed). - Adds a new dependency on `Microsoft.Graphics.Win2D`. - Adds a custom color picker popup; the one from the Community Toolkit occasionally loses the selected color. - Flyby: separates the keyword tag and localizable label for pages in the Settings window navigation. ## Pictures? Pictures! <img width="2027" height="1276" alt="image" src="https://github.com/user-attachments/assets/e3485c71-7faa-495b-b455-b313ea6046ee" /> <img width="3776" height="2025" alt="image" src="https://github.com/user-attachments/assets/820fa823-34d4-426d-b066-b1049dc3266f" /> Matching Windows accent color and tint: <img width="3840" height="2160" alt="image" src="https://github.com/user-attachments/assets/65f3b608-e282-4894-b7c8-e014a194f11f" /> <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] Closes: #38444 - [ ] **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 --------- Co-authored-by: Niels Laute <[email protected]>
1 parent 0f8cf94 commit 97c1de8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4141
-115
lines changed

.github/actions/spell-check/expect.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ BITSPIXEL
141141
bla
142142
BLACKFRAME
143143
BLENDFUNCTION
144+
blittable
144145
Blockquotes
145146
blt
146147
BLURBEHIND
@@ -250,6 +251,7 @@ colorformat
250251
colorhistory
251252
colorhistorylimit
252253
COLORKEY
254+
colorref
253255
comctl
254256
comdlg
255257
comexp
@@ -1860,8 +1862,10 @@ Uniquifies
18601862
unitconverter
18611863
unittests
18621864
UNLEN
1865+
Uninitializes
18631866
UNORM
18641867
unremapped
1868+
Unsubscribes
18651869
unvirtualized
18661870
unwide
18671871
unzoom

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<PackageVersion Include="Microsoft.Data.Sqlite" Version="9.0.10" />
4141
<!-- Including Microsoft.Bcl.AsyncInterfaces to force version, since it's used by Microsoft.SemanticKernel. -->
4242
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.10" />
43+
<PackageVersion Include="Microsoft.Graphics.Win2D" Version="1.3.2" />
4344
<PackageVersion Include="Microsoft.Windows.CppWinRT" Version="2.0.240111.5" />
4445
<PackageVersion Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.16" />
4546
<PackageVersion Include="Microsoft.Extensions.AI" Version="9.9.1" />

src/common/ManagedCsWin32/CLSID.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public static partial class CLSID
1616
public static readonly Guid CollatorDataSource = new Guid("9E175B8B-F52A-11D8-B9A5-505054503030");
1717
public static readonly Guid ApplicationActivationManager = new Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C");
1818
public static readonly Guid VirtualDesktopManager = new("aa509086-5ca9-4c25-8f95-589d3c07b48a");
19+
public static readonly Guid DesktopWallpaper = new("C2CF3110-460E-4FC1-B9D0-8A1C0C9CC4BD");
1920
}

src/common/ManagedCsWin32/Ole32.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public static partial int CoCreateInstance(
1616
CLSCTX dwClsContext,
1717
ref Guid riid,
1818
out IntPtr rReturnedComObject);
19+
20+
[LibraryImport("ole32.dll")]
21+
internal static partial int CoInitializeEx(nint pvReserved, uint dwCoInit);
22+
23+
[LibraryImport("ole32.dll")]
24+
internal static partial void CoUninitialize();
1925
}
2026

2127
[Flags]

src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/ShellViewModel.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace Microsoft.CmdPal.Core.ViewModels;
1515

1616
public partial class ShellViewModel : ObservableObject,
17+
IDisposable,
1718
IRecipient<PerformCommandMessage>,
1819
IRecipient<HandleCommandResultMessage>
1920
{
@@ -460,4 +461,12 @@ public void CancelNavigation()
460461
{
461462
_navigationCts?.Cancel();
462463
}
464+
465+
public void Dispose()
466+
{
467+
_handleInvokeTask?.Dispose();
468+
_navigationCts?.Dispose();
469+
470+
GC.SuppressFinalize(this);
471+
}
463472
}

0 commit comments

Comments
 (0)