From 27c4b1be0ed828b4b5305f965c18f74f5e5bca42 Mon Sep 17 00:00:00 2001 From: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> Date: Tue, 19 Apr 2022 22:00:28 +0200 Subject: [PATCH] [settings-ui] Settings WinUI3 (#17797) * Add Settings.WinUI3 project * New namespace * Activation and Services * Assets and Behaviors * Converters and Helpers * Controls * View and ViewModels * Styles and Themes * OOBE * Strings * Small App moves * [check] Project files - publish profiles and launchSettings.json * [using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name workaround * [WIP] Workarounds to make it work * Fix suppressed warnings - naming * Add code analysis * Fix KBMPage and App dispatcher Fix MessageBox - replace with MessageDialog * Fix ImageResizerPage & mark ColorPickerButton with TODO * Add icon to windows Cleanup MainWindow.xaml.cs and OobeWindow.xaml.cs MainWindows and OobeWindow management * App Icon No framework and runtime subdirs * Remove PowerToys.Settings and Settings.UI from solution Update output paths * Installer work & publish.cmd * Fix dispatcher crashes * Fix crashes * Add all dlls to installer Cleanup installer Add OpenOOBE and OpenScoobe logic Fix minor issues Fix update scenario - REINSTALLMODE * Rename back namespaces, project name and project dir * [wip] move to winappsdk 1.1 * Fix propagating isElevated & installer runtimes dlls * Remove obsolete dir/file * PowerToys.Interop to netstandard2.0 * Move everything to .Net6 * [Settings] Always launch settings process non-elevated (#17791) * Move back to WinAppSdk 1.0.1 * Add Settings.WinUI3 project * New namespace * Activation and Services * Assets and Behaviors * Converters and Helpers * Controls * View and ViewModels * Styles and Themes * OOBE * Strings * Small App moves * [check] Project files - publish profiles and launchSettings.json * [using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name workaround * [WIP] Workarounds to make it work * Fix suppressed warnings - naming * Add code analysis * Fix KBMPage and App dispatcher Fix MessageBox - replace with MessageDialog * Fix ImageResizerPage & mark ColorPickerButton with TODO * Add icon to windows Cleanup MainWindow.xaml.cs and OobeWindow.xaml.cs MainWindows and OobeWindow management * App Icon No framework and runtime subdirs * Remove PowerToys.Settings and Settings.UI from solution Update output paths * Installer work & publish.cmd * Fix dispatcher crashes * Fix crashes * Add all dlls to installer Cleanup installer Add OpenOOBE and OpenScoobe logic Fix minor issues Fix update scenario - REINSTALLMODE * Rename back namespaces, project name and project dir * [wip] move to winappsdk 1.1 * Fix propagating isElevated & installer runtimes dlls * Remove obsolete dir/file * PowerToys.Interop to netstandard2.0 * Move everything to .Net6 * [Settings] Always launch settings process non-elevated (#17791) * Move back to WinAppSdk 1.0.1 * Revert merge conflict ARM64 removal * Fix KBM Browse overlay image button * Bring back settings publish profile * Update release.yml * Change target frameworkd windows version * [Setup] Add Windows Application Runtime SDK (#17809) * Update requirements doc * Update compiling docs * Fix signing * Fix Settings exe and dll versions * Add exception for dlls that have version 1.0.0.0 * Fix powershell condition Co-authored-by: Andrey Nekrasov --- .github/actions/spell-check/expect.txt | 5 + .pipelines/ESRPSigning_core.json | 2 +- .pipelines/release.yml | 2 +- .pipelines/versionAndSignCheck.ps1 | 16 +- PowerToys.sln | 48 +- README.md | 1 + doc/devdocs/readme.md | 3 +- doc/devdocs/settingsv2/project-overview.md | 10 +- doc/devdocs/settingsv2/runner-ipc.md | 2 +- doc/devdocs/settingsv2/ui-architecture.md | 6 +- doc/devdocs/settingsv2/xaml-island-tweaks.md | 30 - installer/PowerToysSetup/PowerToys.wxs | 15 + installer/PowerToysSetup/Product.wxs | 92 +-- installer/PowerToysSetup/publish.cmd | 2 +- .../CustomAction.cpp | 1 - src/ActionRunner/actionRunner.vcxproj | 2 + src/ActionRunner/packages.config | 1 + src/Update/PowerToys.Update.vcxproj | 2 + src/Update/packages.config | 1 + src/common/ManagedCommon/ManagedCommon.csproj | 2 +- .../Telemetry/ManagedTelemetry.csproj | 2 +- src/common/interop/PowerToys.Interop.vcxproj | 9 +- src/common/utils/elevation.h | 75 ++- .../AwakeModuleInterface.vcxproj | 2 + .../AwakeModuleInterface/packages.config | 1 + .../Microsoft.Launcher.vcxproj | 2 + .../launcher/Microsoft.Launcher/dllmain.cpp | 47 +- .../Microsoft.Launcher/packages.config | 1 + .../PowerLauncher.Telemetry.csproj | 2 +- .../previewpane/powerpreview/packages.config | 1 + .../powerpreview/powerpreview.vcxproj | 2 + src/runner/settings_window.cpp | 40 +- src/runner/tray_icon.cpp | 2 +- src/settings-ui/PowerToys.Settings/App.xaml | 8 - .../PowerToys.Settings/App.xaml.cs | 77 --- .../Helpers/NativeMethods.cs | 21 - .../PowerToys.Settings/MainWindow.xaml | 22 - .../PowerToys.Settings/MainWindow.xaml.cs | 203 ------- .../PowerToys.Settings/OobeWindow.xaml | 18 - .../PowerToys.Settings/OobeWindow.xaml.cs | 103 ---- .../PowerToys.Settings.csproj | 69 --- src/settings-ui/PowerToys.Settings/Program.cs | 117 ---- src/settings-ui/PowerToys.Settings/Utils.cs | 117 ---- .../PowerToys.Settings/app.manifest | 13 - .../Settings.UI.Library.csproj | 2 +- .../ViewModels/ImageResizerViewModel.cs | 2 +- .../ViewModels/KeyboardManagerViewModel.cs | 2 +- .../Settings.UI.UnitTests.csproj | 2 +- src/settings-ui/Settings.UI/App.xaml | 12 +- src/settings-ui/Settings.UI/App.xaml.cs | 226 ++++++- .../Assets/LockScreenLogo.scale-200.png | Bin 1430 -> 432 bytes .../Assets/SplashScreen.scale-200.png | Bin 7700 -> 5372 bytes .../Assets/Square150x150Logo.scale-200.png | Bin 2937 -> 1755 bytes .../Assets/Square44x44Logo.scale-200.png | Bin 1647 -> 637 bytes ...x44Logo.targetsize-24_altform-unplated.png | Bin 1255 -> 283 bytes .../Settings.UI/Assets/StoreLogo.png | Bin 1451 -> 456 bytes .../Assets/Wide310x150Logo.scale-200.png | Bin 3204 -> 2097 bytes .../Behaviors/NavigationViewHeaderBehavior.cs | 7 +- .../CheckBoxWithDescriptionControl.cs | 8 +- .../Controls/ColorPickerButton.xaml | 4 +- .../Controls/ColorPickerButton.xaml.cs | 16 +- .../Controls/FancyZonesPreviewControl.xaml | 2 +- .../Controls/FancyZonesPreviewControl.xaml.cs | 6 +- .../IsEnabledTextBlock/IsEnabledTextBlock.cs | 4 +- .../Controls/KeyVisual/KeyVisual.cs | 7 +- .../OOBEPageControl/OOBEPageControl.xaml.cs | 4 +- .../Settings.UI/Controls/Setting/Setting.cs | 7 +- .../SettingExpander/SettingExpander.cs | 10 +- .../Controls/SettingsGroup/SettingsGroup.cs | 11 +- .../SettingsGroupAutomationPeer.cs | 2 +- .../SettingsPageControl.xaml | 3 +- .../SettingsPageControl.xaml.cs | 5 +- .../ShortcutControl/ShortcutControl.xaml.cs | 120 ++-- .../ShortcutDialogContentControl.xaml | 8 +- .../ShortcutDialogContentControl.xaml.cs | 16 +- .../ShortcutWithTextLabelControl.xaml | 2 +- .../ShortcutWithTextLabelControl.xaml.cs | 15 +- .../Converters/AwakeModeToIntConverter.cs | 2 +- ...ationShakeMouseIntToVisibilityConverter.cs | 4 +- .../ImageResizerFitToStringConverter.cs | 11 +- .../ImageResizerUnitToStringConverter.cs | 10 +- .../Converters/UpdateStateToBoolConverter.cs | 7 +- .../Settings.UI/GlobalSuppressions.cs | 75 +++ .../Settings.UI/Helpers/NativeMethods.cs | 13 +- .../Settings.UI/Helpers/NavHelper.cs | 2 +- .../Helpers/POINT.cs | 2 +- .../Helpers/RECT.cs | 2 +- .../Helpers/WINDOWPLACEMENT.cs | 2 +- .../Settings.UI/ICoreWindowInterop.cs | 18 - src/settings-ui/Settings.UI/Interop.cs | 29 - src/settings-ui/Settings.UI/MainWindow.xaml | 15 + .../Settings.UI/MainWindow.xaml.cs | 108 ++++ ...ToysModulesEnum.cs => PowerToysModules.cs} | 2 +- .../OOBE/Views/OobeAlwaysOnTop.xaml | 2 +- .../OOBE/Views/OobeAlwaysOnTop.xaml.cs | 8 +- .../Settings.UI/OOBE/Views/OobeAwake.xaml | 2 +- .../Settings.UI/OOBE/Views/OobeAwake.xaml.cs | 8 +- .../OOBE/Views/OobeColorPicker.xaml | 2 +- .../OOBE/Views/OobeColorPicker.xaml.cs | 10 +- .../OOBE/Views/OobeFancyZones.xaml | 2 +- .../OOBE/Views/OobeFancyZones.xaml.cs | 8 +- .../OOBE/Views/OobeFileExplorer.xaml | 2 +- .../OOBE/Views/OobeFileExplorer.xaml.cs | 8 +- .../OOBE/Views/OobeImageResizer.xaml | 2 +- .../OOBE/Views/OobeImageResizer.xaml.cs | 8 +- .../Settings.UI/OOBE/Views/OobeKBM.xaml | 3 +- .../Settings.UI/OOBE/Views/OobeKBM.xaml.cs | 8 +- .../OOBE/Views/OobeMouseUtils.xaml | 2 +- .../OOBE/Views/OobeMouseUtils.xaml.cs | 9 +- .../OOBE/Views/OobeOverview.xaml.cs | 8 +- .../OOBE/Views/OobePowerRename.xaml | 2 +- .../OOBE/Views/OobePowerRename.xaml.cs | 8 +- .../Settings.UI/OOBE/Views/OobeRun.xaml | 2 +- .../Settings.UI/OOBE/Views/OobeRun.xaml.cs | 10 +- .../Settings.UI/OOBE/Views/OobeShellPage.xaml | 4 +- .../OOBE/Views/OobeShellPage.xaml.cs | 41 +- .../OOBE/Views/OobeShortcutGuide.xaml | 2 +- .../OOBE/Views/OobeShortcutGuide.xaml.cs | 13 +- .../OOBE/Views/OobeVideoConference.xaml | 2 +- .../OOBE/Views/OobeVideoConference.xaml.cs | 8 +- .../Settings.UI/OOBE/Views/OobeWhatsNew.xaml | 2 +- .../OOBE/Views/OobeWhatsNew.xaml.cs | 39 +- src/settings-ui/Settings.UI/OobeWindow.xaml | 15 + .../Settings.UI/OobeWindow.xaml.cs | 64 ++ .../Settings.UI/Package.appxmanifest | 48 -- .../Settings.UI/PowerToys.Settings.csproj | 95 +++ .../Settings.UI/Properties/Default.rd.xml | 31 - .../InstallationPublishProfile.pubxml | 2 +- .../Settings.UI/Services/ActivationService.cs | 6 +- .../Settings.UI/Services/NavigationService.cs | 8 +- .../Settings.UI/Settings.UI.csproj | 558 ------------------ .../Settings.UI/Strings/en-us/Resources.resw | 72 +-- .../Settings.UI/ViewModels/ShellViewModel.cs | 30 +- .../Settings.UI/Views/AlwaysOnTopPage.xaml | 2 +- .../Settings.UI/Views/AlwaysOnTopPage.xaml.cs | 2 +- .../Settings.UI/Views/AwakePage.xaml.cs | 2 +- .../Settings.UI/Views/ColorPickerPage.xaml.cs | 8 +- .../Settings.UI/Views/FancyZonesPage.xaml | 2 +- .../Settings.UI/Views/FancyZonesPage.xaml.cs | 4 +- .../Settings.UI/Views/GeneralPage.xaml | 2 +- .../Settings.UI/Views/GeneralPage.xaml.cs | 13 +- .../Settings.UI/Views/ImageResizerPage.xaml | 2 +- .../Views/ImageResizerPage.xaml.cs | 12 +- .../Views/KeyboardManagerPage.xaml.cs | 12 +- .../Settings.UI/Views/MouseUtilsPage.xaml.cs | 2 +- .../Settings.UI/Views/PowerLauncherPage.xaml | 4 +- .../Views/PowerLauncherPage.xaml.cs | 10 +- .../Settings.UI/Views/PowerPreviewPage.xaml | 2 +- .../Views/PowerPreviewPage.xaml.cs | 3 +- .../Settings.UI/Views/PowerRenamePage.xaml | 3 +- .../Settings.UI/Views/PowerRenamePage.xaml.cs | 3 +- .../Settings.UI/Views/ShellPage.xaml | 3 +- .../Settings.UI/Views/ShellPage.xaml.cs | 19 +- .../Settings.UI/Views/ShortcutGuidePage.xaml | 2 +- .../Views/ShortcutGuidePage.xaml.cs | 5 +- .../Settings.UI/Views/VideoConference.xaml | 2 +- .../Settings.UI/Views/VideoConference.xaml.cs | 5 +- .../Settings.UI/Views/VisibleIfNotEmpty.cs | 4 +- src/settings-ui/Settings.UI/app.manifest | 15 + .../icon.ico | Bin 160 files changed, 1179 insertions(+), 2120 deletions(-) delete mode 100644 doc/devdocs/settingsv2/xaml-island-tweaks.md delete mode 100644 src/settings-ui/PowerToys.Settings/App.xaml delete mode 100644 src/settings-ui/PowerToys.Settings/App.xaml.cs delete mode 100644 src/settings-ui/PowerToys.Settings/Helpers/NativeMethods.cs delete mode 100644 src/settings-ui/PowerToys.Settings/MainWindow.xaml delete mode 100644 src/settings-ui/PowerToys.Settings/MainWindow.xaml.cs delete mode 100644 src/settings-ui/PowerToys.Settings/OobeWindow.xaml delete mode 100644 src/settings-ui/PowerToys.Settings/OobeWindow.xaml.cs delete mode 100644 src/settings-ui/PowerToys.Settings/PowerToys.Settings.csproj delete mode 100644 src/settings-ui/PowerToys.Settings/Program.cs delete mode 100644 src/settings-ui/PowerToys.Settings/Utils.cs delete mode 100644 src/settings-ui/PowerToys.Settings/app.manifest create mode 100644 src/settings-ui/Settings.UI/GlobalSuppressions.cs rename src/settings-ui/{PowerToys.Settings => Settings.UI}/Helpers/POINT.cs (92%) rename src/settings-ui/{PowerToys.Settings => Settings.UI}/Helpers/RECT.cs (94%) rename src/settings-ui/{PowerToys.Settings => Settings.UI}/Helpers/WINDOWPLACEMENT.cs (93%) delete mode 100644 src/settings-ui/Settings.UI/ICoreWindowInterop.cs delete mode 100644 src/settings-ui/Settings.UI/Interop.cs create mode 100644 src/settings-ui/Settings.UI/MainWindow.xaml create mode 100644 src/settings-ui/Settings.UI/MainWindow.xaml.cs rename src/settings-ui/Settings.UI/OOBE/Enums/{PowerToysModulesEnum.cs => PowerToysModules.cs} (93%) create mode 100644 src/settings-ui/Settings.UI/OobeWindow.xaml create mode 100644 src/settings-ui/Settings.UI/OobeWindow.xaml.cs delete mode 100644 src/settings-ui/Settings.UI/Package.appxmanifest create mode 100644 src/settings-ui/Settings.UI/PowerToys.Settings.csproj delete mode 100644 src/settings-ui/Settings.UI/Properties/Default.rd.xml rename src/settings-ui/{PowerToys.Settings => Settings.UI}/Properties/PublishProfiles/InstallationPublishProfile.pubxml (90%) delete mode 100644 src/settings-ui/Settings.UI/Settings.UI.csproj create mode 100644 src/settings-ui/Settings.UI/app.manifest rename src/settings-ui/{PowerToys.Settings => Settings.UI}/icon.ico (100%) diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 46d9c64ce6..39553e3913 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -839,6 +839,7 @@ IIO IItem IJson IKs +Ijwhost IList ILogon IMAGEHLP @@ -1061,6 +1062,7 @@ lhs lhwnd lia LIBID +Lifecycle LIGHTORANGE LIGHTTURQUOISE lindex @@ -1655,6 +1657,7 @@ regkey REGPINTYPES regsvr reimplementing +REINSTALLMODE reloadable Remapper remappings @@ -2243,6 +2246,8 @@ WINDOWPLACEMENT WINDOWPOSCHANGED WINDOWPOSCHANGING Windowsapp +windowsappsdk +windowsappruntimeinstall WINDOWSBUILDNUMBER Windowscodecs windowsdesktop diff --git a/.pipelines/ESRPSigning_core.json b/.pipelines/ESRPSigning_core.json index 37eda37735..576f38511b 100644 --- a/.pipelines/ESRPSigning_core.json +++ b/.pipelines/ESRPSigning_core.json @@ -114,7 +114,6 @@ "modules\\VideoConference\\PowerToys.VideoConferenceProxyFilter_x86.dll", "modules\\VideoConference\\PowerToys.VideoConferenceProxyFilter_x64.dll", - "Settings\\PowerToys.Settings.UI.exe", "Settings\\PowerToys.Settings.dll", "Settings\\PowerToys.Settings.exe" ], @@ -192,6 +191,7 @@ "modules\\launcher\\SQLitePCLRaw.batteries_v2.dll", "modules\\launcher\\SQLitePCLRaw.core.dll", "modules\\launcher\\SQLitePCLRaw.provider.e_sqlite3.dll", + "Settings\\Microsoft.Graphics.Canvas.Interop.dll", "ColorCode.Core.dll", "ColorCode.UWP.dll", "UnitsNet.dll" diff --git a/.pipelines/release.yml b/.pipelines/release.yml index 917e28bc84..2112bfd27a 100644 --- a/.pipelines/release.yml +++ b/.pipelines/release.yml @@ -169,7 +169,7 @@ jobs: - task: VSBuild@1 displayName: Publish Settings for Packaging inputs: - solution: 'src/settings-ui/PowerToys.Settings/PowerToys.Settings.csproj' + solution: 'src/settings-ui/Settings.UI/PowerToys.Settings.csproj' vsVersion: 17.0 msbuildArgs: >- /target:Publish diff --git a/.pipelines/versionAndSignCheck.ps1 b/.pipelines/versionAndSignCheck.ps1 index 1dd784e3e8..4c26b00526 100644 --- a/.pipelines/versionAndSignCheck.ps1 +++ b/.pipelines/versionAndSignCheck.ps1 @@ -28,8 +28,20 @@ if($items.Count -eq 0) $items | ForEach-Object { if($_.VersionInfo.FileVersion -eq "1.0.0.0" ) { - Write-Host "Version not set: " + $_.FullName - $totalFailure++; + # These items are exceptions that actually have the 1.0.0.0 version. + if ((-not $_.Name.EndsWith("Microsoft.Windows.ApplicationModel.DynamicDependency.Projection.dll")) -and + (-not $_.Name.EndsWith("Microsoft.Windows.ApplicationModel.Resources.Projection.dll")) -and + (-not $_.Name.EndsWith("Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection.dll")) -and + (-not $_.Name.EndsWith("Microsoft.Windows.AppLifecycle.Projection.dll")) -and + (-not $_.Name.EndsWith("Microsoft.Windows.System.Power.Projection.dll")) -and + (-not $_.Name.EndsWith("Microsoft.WindowsAppRuntime.Bootstrap.Net.dll")) -and + (-not $_.Name.EndsWith("Microsoft.Xaml.Interactions.dll")) -and + (-not $_.Name.EndsWith("Microsoft.Xaml.Interactivity.dll")) + ) + { + Write-Host "Version not set: " + $_.FullName + $totalFailure++; + } } } diff --git a/PowerToys.sln b/PowerToys.sln index df9e2661e0..fe4fd615a6 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -18,7 +18,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runner", "src\runner\runner {69E1EE8D-143A-4060-9129-4658ACF14AAF} = {69E1EE8D-143A-4060-9129-4658ACF14AAF} {DA425894-6E13-404F-8DCB-78584EC0557A} = {DA425894-6E13-404F-8DCB-78584EC0557A} {2BE46397-4DFA-414C-9BD4-41E4BBF8CB34} = {2BE46397-4DFA-414C-9BD4-41E4BBF8CB34} - {A7D5099E-F0FD-4BF3-8522-5A682759F915} = {A7D5099E-F0FD-4BF3-8522-5A682759F915} {0B43679E-EDFA-4DA0-AD30-F4628B308B1B} = {0B43679E-EDFA-4DA0-AD30-F4628B308B1B} {B25AC7A5-FB9F-4789-B392-D5C85E948670} = {B25AC7A5-FB9F-4789-B392-D5C85E948670} {5E7360A8-D048-4ED3-8F09-0BFD64C5529A} = {5E7360A8-D048-4ED3-8F09-0BFD64C5529A} @@ -171,8 +170,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "powerpreview", "src\modules EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "settings-ui", "settings-ui", "{C3081D9A-1586-441A-B5F4-ED815B3719C1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Settings.UI", "src\settings-ui\Settings.UI\Settings.UI.csproj", "{A7D5099E-F0FD-4BF3-8522-5A682759F915}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4981CCD1-4CD9-4A49-B240-00AA46493FF8}" ProjectSection(SolutionItems) = preProject src\.editorconfig = src\.editorconfig @@ -278,14 +275,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "utils", "utils", "{B39DC643 src\common\utils\modulesRegistry.h = src\common\utils\modulesRegistry.h src\common\utils\MsiUtils.h = src\common\utils\MsiUtils.h src\common\utils\os-detect.h = src\common\utils\os-detect.h - src\common\utils\ProcessWaiter.h = src\common\utils\ProcessWaiter.h src\common\utils\process_path.h = src\common\utils\process_path.h + src\common\utils\ProcessWaiter.h = src\common\utils\ProcessWaiter.h src\common\utils\registry.h = src\common\utils\registry.h src\common\utils\resources.h = src\common\utils\resources.h src\common\utils\string_utils.h = src\common\utils\string_utils.h src\common\utils\timeutil.h = src\common\utils\timeutil.h - src\common\utils\winapi_error.h = src\common\utils\winapi_error.h src\common\utils\UnhandledExceptionHandler.h = src\common\utils\UnhandledExceptionHandler.h + src\common\utils\winapi_error.h = src\common\utils\winapi_error.h src\common\utils\window.h = src\common\utils\window.h EndProjectSection EndProject @@ -306,8 +303,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Run.Plu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Run.Plugin.Registry.UnitTests", "src\modules\launcher\Plugins\Microsoft.PowerToys.Run.Plugin.Registry.UnitTest\Microsoft.PowerToys.Run.Plugin.Registry.UnitTests.csproj", "{0648DF05-5DDA-4BE1-B5F2-584926EBDB65}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerToys.Settings", "src\settings-ui\PowerToys.Settings\PowerToys.Settings.csproj", "{6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeyboardManagerEngine", "src\modules\keyboardmanager\KeyboardManagerEngine\KeyboardManagerEngine.vcxproj", "{BA661F5B-1D5A-4FFC-9BF1-FC39DF280BDD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeyboardManagerEngineLibrary", "src\modules\keyboardmanager\KeyboardManagerEngineLibrary\KeyboardManagerEngineLibrary.vcxproj", "{E496B7FC-1E99-4BAB-849B-0E8367040B02}" @@ -408,6 +403,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Run.Plu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Plugin.WindowWalker.UnitTests", "src\modules\launcher\Plugins\Microsoft.Plugin.WindowWalker.UnitTests\Microsoft.Plugin.WindowWalker.UnitTests.csproj", "{8FE5A5EE-1B59-401C-9FB3-B04ECD3E29C1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerToys.Settings", "src\settings-ui\Settings.UI\PowerToys.Settings.csproj", "{020A7474-3601-4160-A159-D7B70B77B15F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -768,18 +765,6 @@ Global {217DF501-135C-4E38-BFC8-99D4821032EA}.Release|x64.ActiveCfg = Release|x64 {217DF501-135C-4E38-BFC8-99D4821032EA}.Release|x64.Build.0 = Release|x64 {217DF501-135C-4E38-BFC8-99D4821032EA}.Release|x86.ActiveCfg = Release|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|ARM64.ActiveCfg = Debug|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|ARM64.Build.0 = Debug|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|x64.ActiveCfg = Debug|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|x64.Build.0 = Debug|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Debug|x86.ActiveCfg = Debug|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|ARM64.ActiveCfg = Release|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|ARM64.Build.0 = Release|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x64.ActiveCfg = Release|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x64.Build.0 = Release|x64 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x86.ActiveCfg = Release|Win32 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x86.Build.0 = Release|Win32 - {A7D5099E-F0FD-4BF3-8522-5A682759F915}.Release|x86.Deploy.0 = Release|Win32 {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|ARM64.ActiveCfg = Debug|x64 {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|ARM64.Build.0 = Debug|x64 {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|x64.ActiveCfg = Debug|x64 @@ -1140,16 +1125,6 @@ Global {0648DF05-5DDA-4BE1-B5F2-584926EBDB65}.Release|x64.ActiveCfg = Release|x64 {0648DF05-5DDA-4BE1-B5F2-584926EBDB65}.Release|x64.Build.0 = Release|x64 {0648DF05-5DDA-4BE1-B5F2-584926EBDB65}.Release|x86.ActiveCfg = Release|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Debug|ARM64.ActiveCfg = Debug|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Debug|ARM64.Build.0 = Debug|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Debug|x64.ActiveCfg = Debug|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Debug|x64.Build.0 = Debug|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Debug|x86.ActiveCfg = Debug|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Release|ARM64.ActiveCfg = Release|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Release|ARM64.Build.0 = Release|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Release|x64.ActiveCfg = Release|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Release|x64.Build.0 = Release|x64 - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A}.Release|x86.ActiveCfg = Release|x64 {BA661F5B-1D5A-4FFC-9BF1-FC39DF280BDD}.Debug|ARM64.ActiveCfg = Debug|x64 {BA661F5B-1D5A-4FFC-9BF1-FC39DF280BDD}.Debug|ARM64.Build.0 = Debug|x64 {BA661F5B-1D5A-4FFC-9BF1-FC39DF280BDD}.Debug|x64.ActiveCfg = Debug|x64 @@ -1583,6 +1558,18 @@ Global {8FE5A5EE-1B59-401C-9FB3-B04ECD3E29C1}.Release|x64.Build.0 = Release|x64 {8FE5A5EE-1B59-401C-9FB3-B04ECD3E29C1}.Release|x86.ActiveCfg = Release|x64 {8FE5A5EE-1B59-401C-9FB3-B04ECD3E29C1}.Release|x86.Build.0 = Release|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Debug|ARM64.ActiveCfg = Debug|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Debug|ARM64.Build.0 = Debug|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Debug|x64.ActiveCfg = Debug|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Debug|x64.Build.0 = Debug|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Debug|x86.ActiveCfg = Debug|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Debug|x86.Build.0 = Debug|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Release|ARM64.ActiveCfg = Release|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Release|ARM64.Build.0 = Release|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Release|x64.ActiveCfg = Release|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Release|x64.Build.0 = Release|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Release|x86.ActiveCfg = Release|x64 + {020A7474-3601-4160-A159-D7B70B77B15F}.Release|x86.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1628,7 +1615,6 @@ Global {060D75DA-2D1C-48E6-A4A1-6F0718B64661} = {2F305555-C296-497E-AC20-5FA1B237996A} {748417CA-F17E-487F-9411-CAFB6D3F4877} = {2F305555-C296-497E-AC20-5FA1B237996A} {217DF501-135C-4E38-BFC8-99D4821032EA} = {2F305555-C296-497E-AC20-5FA1B237996A} - {A7D5099E-F0FD-4BF3-8522-5A682759F915} = {C3081D9A-1586-441A-B5F4-ED815B3719C1} {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A} = {C3081D9A-1586-441A-B5F4-ED815B3719C1} {F055103B-F80B-4D0C-BF48-057C55620033} = {5A7818A8-109C-4E1C-850D-1A654E234B0E} {787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {4AFC9975-2456-4C70-94A4-84073C1CED93} @@ -1671,7 +1657,6 @@ Global {ECC20689-002A-4354-95A6-B58DF089C6FF} = {2F305555-C296-497E-AC20-5FA1B237996A} {4BABF3FE-3451-42FD-873F-3C332E18DCEF} = {4AFC9975-2456-4C70-94A4-84073C1CED93} {0648DF05-5DDA-4BE1-B5F2-584926EBDB65} = {4AFC9975-2456-4C70-94A4-84073C1CED93} - {6ED2F4FC-E122-4CEE-90F1-97E4CCC8BC7A} = {C3081D9A-1586-441A-B5F4-ED815B3719C1} {BA661F5B-1D5A-4FFC-9BF1-FC39DF280BDD} = {38BDB927-829B-4C65-9CD9-93FB05D66D65} {E496B7FC-1E99-4BAB-849B-0E8367040B02} = {38BDB927-829B-4C65-9CD9-93FB05D66D65} {7F4B3A60-BC27-45A7-8000-68B0B6EA7466} = {38BDB927-829B-4C65-9CD9-93FB05D66D65} @@ -1718,6 +1703,7 @@ Global {5BDBD6C9-A31F-4CEB-871A-5E9E709197EF} = {4AFC9975-2456-4C70-94A4-84073C1CED93} {FD464B4C-2F68-4D06-91E7-4208146C41F5} = {4AFC9975-2456-4C70-94A4-84073C1CED93} {8FE5A5EE-1B59-401C-9FB3-B04ECD3E29C1} = {4AFC9975-2456-4C70-94A4-84073C1CED93} + {020A7474-3601-4160-A159-D7B70B77B15F} = {C3081D9A-1586-441A-B5F4-ED815B3719C1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0} diff --git a/README.md b/README.md index dc0476917a..d3a1567bc4 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Microsoft PowerToys is a set of utilities for power users to tune and streamline - [.NET Core 3.1.23 Desktop Runtime](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-3.1.23-windows-x64-installer) or a newer 3.1.x runtime. This is needed currently for the Settings application. - [.NET 6.0.3 Desktop Runtime](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-6.0.3-windows-x64-installer) or a newer 6.0.x runtime. - [Microsoft Edge WebView2 Runtime](https://go.microsoft.com/fwlink/p/?LinkId=2124703) bootstrapper. This will install the latest version. + - [Windows App SDK Runtime 1.0.1](https://docs.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads). This will install version 1.0.1 if this or newer version is not installed already. ### Via GitHub with EXE [Recommended] diff --git a/doc/devdocs/readme.md b/doc/devdocs/readme.md index be7d7f572d..c8f001d86b 100644 --- a/doc/devdocs/readme.md +++ b/doc/devdocs/readme.md @@ -39,7 +39,8 @@ Once you've discussed your proposed feature/fix/etc. with a team member, and you 1. Windows 10 April 2018 Update (version 1803) or newer 2. Visual Studio Community/Professional/Enterprise 2022 -3. Once you've cloned and started the `PowerToys.sln`, in the solution explorer, if you see a dialog that says `install extra components`, click `install` +3. Install the [Windows App SDK 1.0.1 C# Visual Studio 2022 extension](https://docs.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads) +4. Once you've cloned and started the `PowerToys.sln`, in the solution explorer, if you see a dialog that says `install extra components`, click `install` ### Get Submodules to compile We have submodules that need to be initialized before you can compile most parts of PowerToys. This should be a one time step. diff --git a/doc/devdocs/settingsv2/project-overview.md b/doc/devdocs/settingsv2/project-overview.md index c978c2029e..d01f820717 100644 --- a/doc/devdocs/settingsv2/project-overview.md +++ b/doc/devdocs/settingsv2/project-overview.md @@ -1,17 +1,17 @@ # Overview -`Settingsv2` is WPF .net core desktop application. It uses the `WindowsXamlHost` control from the Windows Community Toolkit to host UWP controls from `WinUI3` library. More details about WinUI can be found [here](https://microsoft.github.io/microsoft-ui-xaml/about.html#what-is-it). +`Settings` is Windows App Sdk WinUI3 .Net Unpackaged desktop application. More details about Windows App Sdk can be found [here](https://github.com/microsoft/WindowsAppSDK#windows-app-sdk---calling-all-windows-developers). More details about WinUI can be found [here](https://microsoft.github.io/microsoft-ui-xaml/about.html#what-is-it). ## Settings V2 Project structure -The Settings project is a XAML island based project which +The Settings project .Net WinUI3 based project which follows the [MVVM architectural pattern][MVVM] where the graphical user interface is separated from the view models. -#### [UI Components:](/src/settings-ui/Settings.UI) -The Settings.UI project contains the xaml files for each of the UI components. It also contains the Hotkey logic for the settings control. +#### [UI Components:](/src/settings-ui/Settings.UI/) +The UI Components are part of PowerToys.Settings project. It contains the xaml files for each of the UI components. It also contains the Hotkey logic for the settings control. #### [Viewmodels:](/src/settings-ui/Settings.UI.Library) The Settings.UI.Library project contains the data that is to be rendered by the UI components. -#### [Settings Runner:](/src/settings-ui/PowerToys.Settings) +#### [Settings Runner:](/src/settings-ui/Settings.UI) The function of the settings runner project is to communicate all changes that the user makes in the user interface, to the runner so that it can be dispatched and reflected in all the modules. [MVVM]: https://docs.microsoft.com/en-us/windows/uwp/data-binding/data-binding-and-mvvm \ No newline at end of file diff --git a/doc/devdocs/settingsv2/runner-ipc.md b/doc/devdocs/settingsv2/runner-ipc.md index 21ae6db1ec..7b5d759c7b 100644 --- a/doc/devdocs/settingsv2/runner-ipc.md +++ b/doc/devdocs/settingsv2/runner-ipc.md @@ -4,7 +4,7 @@ The Settings v2 process uses two way IPC to communicate with the runner process. ## Initialization - On the settings' side, the two way IPC delegates are contained with the [`ShellPage.xaml.cs`](/src/settings-ui/Settings.UI/Views/ShellPage.xaml.cs) file. The delegates are static and the views for all the powerToys send the ipc information to the viewmodels as `ShellPage.DefaultSndMSGCallBack`. -- These delegates are initialized within the [`Mainwindow.xaml.cs`](/src/settings-ui/PowerToys.Settings/MainWindow.xaml.cs) file in the `Settings.Runner` project. +- These delegates are initialized within the [`Mainwindow.xaml.cs`](/src/settings-ui/Settings.UI/MainWindow.xaml.cs) file in the `Settings.Runner` project. ## Types of IPC delegates diff --git a/doc/devdocs/settingsv2/ui-architecture.md b/doc/devdocs/settingsv2/ui-architecture.md index a6d8ce927a..929f81386e 100644 --- a/doc/devdocs/settingsv2/ui-architecture.md +++ b/doc/devdocs/settingsv2/ui-architecture.md @@ -1,9 +1,7 @@ # UI Architecture - The UI code is distributed between two projects: [`PowerToys.Settings`](/src/settings-ui/PowerToys.Settings) and [`Settings.UI`](/src/settings-ui/Settings.UI.Library). [`PowerToys.Settings`](/src/settings-ui/PowerToys.Settings) is a WPF .net core application. It contains the parent display window and corresponding code is present in [`MainWindow.xaml.`](/src/settings-ui/PowerToys.Settings/MainWindow.xaml) [`Settings.UI`](/src/settings-ui/Settings.UI.Library) is UWP applications and contains views for base navigation and modules. Fig 1 provides a description of the UI controls hierarchy and each of the controls have been summarized below : -- [`MainWindow.xaml`](/src/settings-ui/PowerToys.Settings/MainWindow.xaml) is the parent WPF control. -- `WindowsXamlHost` control is used to host UWP control to [`MainWindow.xaml`](/src/settings-ui/PowerToys.Settings/MainWindow.xaml) parent control. -- [`ShellPage.xaml`](/src/settings-ui/Settings.UI/Views/ShellPage.xaml) is a UWP control, consisting of a side navigation panel with an icon for each module. Clicking on a module icon loads the corresponding `setting.json` file and displays the data in the UI. + The UI code is distributed between two projects: [`PowerToys.Settings`](/src/settings-ui/Settings.UI) and [`Settings.UI`](/src/settings-ui/Settings.UI.Library). [`PowerToys.Settings`](/src/settings-ui/Settings.UI) is a Windows App Sdk .net Unpackaged application. It contains the views for base navigation and modules. Parent display window and corresponding code is present in [`MainWindow.xaml.`](/src/settings-ui/Settings.UI/MainWindow.xaml). Fig 1 provides a description of the UI controls hierarchy and each of the controls have been summarized below : +- [`ShellPage.xaml`](/src/settings-ui/Settings.UI/Views/ShellPage.xaml) is a WinUI control, consisting of a side navigation panel with an icon for each module. Clicking on a module icon loads the corresponding `setting.json` file and displays the data in the UI. ![Settings UI architecture](/doc/images/settingsv2/ui-architecture.png) **Fig 1: UI Architecture for settingsv2** diff --git a/doc/devdocs/settingsv2/xaml-island-tweaks.md b/doc/devdocs/settingsv2/xaml-island-tweaks.md deleted file mode 100644 index e63c879302..0000000000 --- a/doc/devdocs/settingsv2/xaml-island-tweaks.md +++ /dev/null @@ -1,30 +0,0 @@ -# XAML Island Tweaks -Few tweaks were made to fix issues with Xaml Islands. These tweaks should be removed after migrating to WINUI3. The tweaks are listed below: -1. Workaround to ensure XAML Island application terminates if attempted to close from taskbar while minimized: -``` -private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) -{ - isOpen = false; - - // XAML Islands: If the window is closed while minimized, exit the process. Required to avoid process not terminating issue - https://github.com/microsoft/PowerToys/issues/4430 - if (WindowState == WindowState.Minimized) - { - // Run Environment.Exit on a separate task to avoid performance impact - System.Threading.Tasks.Task.Run(() => { Environment.Exit(0); }); - } -} -``` -2. Workaround to hide the XAML Island blank icon in the taskbar when the XAML Island application is loading: -``` -var coreWindow = Windows.UI.Core.CoreWindow.GetForCurrentThread(); -var coreWindowInterop = Interop.GetInterop(coreWindow); -Interop.ShowWindow(coreWindowInterop.WindowHandle, Interop.SW_HIDE); -``` -3. Workaround to prevent XAML Island failing to render on Nvidia workstation graphics cards: -``` - // XAML Islands: If the window is open, explicitly force it to be shown to solve the blank dialog issue https://github.com/microsoft/PowerToys/issues/3384 - if (isOpen) - { - Show(); - } - ``` diff --git a/installer/PowerToysSetup/PowerToys.wxs b/installer/PowerToysSetup/PowerToys.wxs index 40daa1ace2..11c48956d3 100644 --- a/installer/PowerToysSetup/PowerToys.wxs +++ b/installer/PowerToysSetup/PowerToys.wxs @@ -92,6 +92,21 @@ PerMachine="yes" UninstallCommand="/silent /uninstall"> + + + + - + - + - + - + + + @@ -48,13 +50,11 @@ - - - + @@ -66,7 +66,7 @@ - + @@ -123,6 +123,7 @@ + @@ -505,18 +506,16 @@ - - - - - - + + + + @@ -833,7 +832,7 @@ - + @@ -853,7 +852,7 @@ - + @@ -898,17 +897,10 @@ - + - - - - - - - @@ -957,42 +949,13 @@ - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - @@ -1068,8 +1031,11 @@ - + + + + @@ -1078,7 +1044,6 @@ - @@ -1088,13 +1053,6 @@ - - - - - - - @@ -1408,7 +1366,7 @@ - + diff --git a/installer/PowerToysSetup/publish.cmd b/installer/PowerToysSetup/publish.cmd index 43eab51a3c..586bd66771 100644 --- a/installer/PowerToysSetup/publish.cmd +++ b/installer/PowerToysSetup/publish.cmd @@ -3,7 +3,7 @@ setlocal enableDelayedExpansion IF NOT DEFINED PTRoot (SET PTRoot=..\..) rem In case of Release we should not use Debug CRT in VCRT forwarders -msbuild !PTRoot!\src\settings-ui\PowerToys.Settings\PowerToys.Settings.csproj -t:Publish -p:Configuration="Release" -p:Platform="x64" -p:PowerToysRoot=!PTRoot! -p:AppxBundle=Never -p:VCRTForwarders-IncludeDebugCRT=false -p:PublishProfile=InstallationPublishProfile.pubxml +msbuild !PTRoot!\src\settings-ui\Settings.UI\PowerToys.Settings.csproj -t:Publish -p:Configuration="Release" -p:Platform="x64" -p:PowerToysRoot=!PTRoot! -p:AppxBundle=Never -p:VCRTForwarders-IncludeDebugCRT=false -p:PublishProfile=InstallationPublishProfile.pubxml rem In case of Release we should not use Debug CRT in VCRT forwarders msbuild !PTRoot!\src\modules\launcher\PowerLauncher\PowerLauncher.csproj -t:Publish -p:Configuration="Release" -p:Platform="x64" -p:AppxBundle=Never -p:PowerToysRoot=!PTRoot! -p:VCRTForwarders-IncludeDebugCRT=false -p:PublishProfile=InstallationPublishProfile.pubxml diff --git a/installer/PowerToysSetupCustomActions/CustomAction.cpp b/installer/PowerToysSetupCustomActions/CustomAction.cpp index c4362e3bb5..8a942d3348 100644 --- a/installer/PowerToysSetupCustomActions/CustomAction.cpp +++ b/installer/PowerToysSetupCustomActions/CustomAction.cpp @@ -942,7 +942,6 @@ UINT __stdcall TerminateProcessesCA(MSIHANDLE hInstall) L"PowerToys.Settings.exe", L"PowerToys.Awake.exe", L"PowerToys.FancyZones.exe", - L"PowerToys.Settings.UI.exe", L"PowerToys.FancyZonesEditor.exe", L"PowerToys.ColorPickerUI.exe", L"PowerToys.AlwaysOnTop.exe", diff --git a/src/ActionRunner/actionRunner.vcxproj b/src/ActionRunner/actionRunner.vcxproj index eedd9d223f..5d252ba64b 100644 --- a/src/ActionRunner/actionRunner.vcxproj +++ b/src/ActionRunner/actionRunner.vcxproj @@ -65,6 +65,7 @@ + @@ -72,5 +73,6 @@ + \ No newline at end of file diff --git a/src/ActionRunner/packages.config b/src/ActionRunner/packages.config index 81f107b8bc..d758b61ef1 100644 --- a/src/ActionRunner/packages.config +++ b/src/ActionRunner/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/src/Update/PowerToys.Update.vcxproj b/src/Update/PowerToys.Update.vcxproj index c8c554d3f9..d945960542 100644 --- a/src/Update/PowerToys.Update.vcxproj +++ b/src/Update/PowerToys.Update.vcxproj @@ -71,6 +71,7 @@ + @@ -78,5 +79,6 @@ + \ No newline at end of file diff --git a/src/Update/packages.config b/src/Update/packages.config index 81f107b8bc..d758b61ef1 100644 --- a/src/Update/packages.config +++ b/src/Update/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/src/common/ManagedCommon/ManagedCommon.csproj b/src/common/ManagedCommon/ManagedCommon.csproj index 14159b692f..5176b4afcb 100644 --- a/src/common/ManagedCommon/ManagedCommon.csproj +++ b/src/common/ManagedCommon/ManagedCommon.csproj @@ -3,7 +3,7 @@ - netstandard2.0 + net6.0-windows x64 x64 $(Version).0 diff --git a/src/common/ManagedTelemetry/Telemetry/ManagedTelemetry.csproj b/src/common/ManagedTelemetry/Telemetry/ManagedTelemetry.csproj index 48817408b0..17e44a11fb 100644 --- a/src/common/ManagedTelemetry/Telemetry/ManagedTelemetry.csproj +++ b/src/common/ManagedTelemetry/Telemetry/ManagedTelemetry.csproj @@ -2,7 +2,7 @@ - netstandard2.0 + net6.0-windows x64 x64 $(Version).0 diff --git a/src/common/interop/PowerToys.Interop.vcxproj b/src/common/interop/PowerToys.Interop.vcxproj index 30dfc6715a..23dff3dc93 100644 --- a/src/common/interop/PowerToys.Interop.vcxproj +++ b/src/common/interop/PowerToys.Interop.vcxproj @@ -9,7 +9,7 @@ 16.0 {F055103B-F80B-4D0C-BF48-057C55620033} - v4.7.2 + net6.0-windows ManagedCProj PowerToysInterop PowerToys.Interop @@ -17,7 +17,7 @@ DynamicLibrary - true + NetCore v143 @@ -119,11 +119,6 @@ - - - - - diff --git a/src/common/utils/elevation.h b/src/common/utils/elevation.h index ffcc42355b..e9dcfe8f8c 100644 --- a/src/common/utils/elevation.h +++ b/src/common/utils/elevation.h @@ -15,15 +15,19 @@ #include #include +#include + #include #include +#include +#include -namespace +namespace { inline std::wstring GetErrorString(HRESULT handle) { - _com_error err(handle); - return err.ErrorMessage(); + _com_error err(handle); + return err.ErrorMessage(); } inline bool FindDesktopFolderView(REFIID riid, void** ppv) @@ -51,7 +55,7 @@ namespace CComPtr spBrowser; result = CComQIPtr(spdisp)->QueryService(SID_STopLevelBrowser, - IID_PPV_ARGS(&spBrowser)); + IID_PPV_ARGS(&spBrowser)); if (result != S_OK) { Logger::warn(L"Failed to query service. {}", GetErrorString(result)); @@ -104,7 +108,8 @@ namespace inline bool ShellExecuteFromExplorer( PCWSTR pszFile, - PCWSTR pszParameters = nullptr) + PCWSTR pszParameters = nullptr, + PCWSTR workingDir = L"") { CComPtr spFolderView; if (!GetDesktopAutomationObject(IID_PPV_ARGS(&spFolderView))) @@ -121,11 +126,11 @@ namespace } CComQIPtr(spdispShell) - ->ShellExecute(CComBSTR(pszFile), - CComVariant(pszParameters ? pszParameters : L""), - CComVariant(L""), - CComVariant(L""), - CComVariant(SW_SHOWNORMAL)); + ->ShellExecuteW(CComBSTR(pszFile), + CComVariant(pszParameters ? pszParameters : L""), + CComVariant(workingDir), + CComVariant(L""), + CComVariant(SW_SHOWNORMAL)); return true; } @@ -205,7 +210,7 @@ inline HANDLE run_elevated(const std::wstring& file, const std::wstring& params) } // Run command as non-elevated user, returns true if succeeded, puts the process id into returnPid if returnPid != NULL -inline bool run_non_elevated(const std::wstring& file, const std::wstring& params, DWORD* returnPid) +inline bool run_non_elevated(const std::wstring& file, const std::wstring& params, DWORD* returnPid, const wchar_t* workingDir = nullptr) { Logger::info(L"run_non_elevated with params={}", params); auto executable_args = L"\"" + file + L"\""; @@ -225,7 +230,7 @@ inline bool run_non_elevated(const std::wstring& file, const std::wstring& param { Logger::error(L"GetShellWindow() failed. {}", get_last_error_or_default(GetLastError())); } - + return false; } DWORD pid; @@ -280,7 +285,7 @@ inline bool run_non_elevated(const std::wstring& file, const std::wstring& param FALSE, EXTENDED_STARTUPINFO_PRESENT, nullptr, - nullptr, + workingDir, &siex.StartupInfo, &pi); if (succeeded) @@ -307,17 +312,17 @@ inline bool run_non_elevated(const std::wstring& file, const std::wstring& param return succeeded; } -inline bool RunNonElevatedEx(const std::wstring& file, const std::wstring& params) +inline bool RunNonElevatedEx(const std::wstring& file, const std::wstring& params, const std::wstring& working_dir) { try { CoInitialize(nullptr); - if (!ShellExecuteFromExplorer(file.c_str(), params.c_str())) + if (!ShellExecuteFromExplorer(file.c_str(), params.c_str(), working_dir.c_str())) { return false; } } - catch(...) + catch (...) { return false; } @@ -325,6 +330,44 @@ inline bool RunNonElevatedEx(const std::wstring& file, const std::wstring& param return true; } +struct ProcessInfo +{ + wil::unique_process_handle processHandle; + DWORD processID = {}; +}; + +inline std::optional RunNonElevatedFailsafe(const std::wstring& file, const std::wstring& params, const std::wstring& working_dir) +{ + bool launched = RunNonElevatedEx(file, params, working_dir); + if (!launched) + { + Logger::warn(L"RunNonElevatedEx() failed. Trying fallback"); + std::wstring action_runner_path = get_module_folderpath() + L"\\PowerToys.ActionRunner.exe"; + std::wstring newParams = fmt::format(L"-run-non-elevated -target \"{}\" {}", file, params); + launched = run_non_elevated(action_runner_path, newParams, nullptr, working_dir.c_str()); + if (launched) + { + Logger::trace(L"Started {}", file); + } + else + { + Logger::warn(L"Failed to start {}", file); + return std::nullopt; + } + } + + auto handles = getProcessHandlesByName(std::filesystem::path{ file }.filename().wstring(), PROCESS_QUERY_INFORMATION | SYNCHRONIZE); + + if (handles.empty()) + return std::nullopt; + + ProcessInfo result; + result.processID = GetProcessId(handles[0].get()); + result.processHandle = std::move(handles[0]); + + return result; +} + // Run command with the same elevation, returns true if succeeded inline bool run_same_elevation(const std::wstring& file, const std::wstring& params, DWORD* returnPid) { diff --git a/src/modules/awake/AwakeModuleInterface/AwakeModuleInterface.vcxproj b/src/modules/awake/AwakeModuleInterface/AwakeModuleInterface.vcxproj index 7701d32e14..b98a7a7b65 100644 --- a/src/modules/awake/AwakeModuleInterface/AwakeModuleInterface.vcxproj +++ b/src/modules/awake/AwakeModuleInterface/AwakeModuleInterface.vcxproj @@ -93,6 +93,7 @@ + @@ -100,5 +101,6 @@ + \ No newline at end of file diff --git a/src/modules/awake/AwakeModuleInterface/packages.config b/src/modules/awake/AwakeModuleInterface/packages.config index 6a0a5a1e09..f29ad9ef3e 100644 --- a/src/modules/awake/AwakeModuleInterface/packages.config +++ b/src/modules/awake/AwakeModuleInterface/packages.config @@ -1,4 +1,5 @@ + \ No newline at end of file diff --git a/src/modules/launcher/Microsoft.Launcher/Microsoft.Launcher.vcxproj b/src/modules/launcher/Microsoft.Launcher/Microsoft.Launcher.vcxproj index 8458c5cc4b..4732b3c01a 100644 --- a/src/modules/launcher/Microsoft.Launcher/Microsoft.Launcher.vcxproj +++ b/src/modules/launcher/Microsoft.Launcher/Microsoft.Launcher.vcxproj @@ -87,6 +87,7 @@ + @@ -94,5 +95,6 @@ + \ No newline at end of file diff --git a/src/modules/launcher/Microsoft.Launcher/dllmain.cpp b/src/modules/launcher/Microsoft.Launcher/dllmain.cpp index c66c8818cb..8071c1c929 100644 --- a/src/modules/launcher/Microsoft.Launcher/dllmain.cpp +++ b/src/modules/launcher/Microsoft.Launcher/dllmain.cpp @@ -231,7 +231,18 @@ public: unsigned long powertoys_pid = GetCurrentProcessId(); TerminateRunningInstance(); - if (!is_process_elevated(false)) + if (is_process_elevated(false)) + { + Logger::trace("Starting PowerToys Run from elevated process"); + const auto modulePath = get_module_folderpath(); + std::wstring runExecutablePath = modulePath; + std::wstring params; + params += L" -powerToysPid " + std::to_wstring(powertoys_pid) + L" "; + params += L"--started-from-runner "; + runExecutablePath += L"\\modules\\launcher\\PowerToys.PowerLauncher.exe"; + processStarted = RunNonElevatedFailsafe(runExecutablePath, params, modulePath).has_value(); + } + else { Logger::trace("Starting PowerToys Run from not elevated process"); std::wstring executable_args; @@ -255,35 +266,6 @@ public: Logger::error("Launcher failed to start"); } } - else - { - Logger::trace("Starting PowerToys Run from elevated process"); - std::wstring runExecutablePath = get_module_folderpath(); - std::wstring params; - params += L" -powerToysPid " + std::to_wstring(powertoys_pid) + L" "; - params += L"--started-from-runner "; - runExecutablePath += L"\\modules\\launcher\\PowerToys.PowerLauncher.exe"; - if (RunNonElevatedEx(runExecutablePath, params)) - { - processStarted = true; - Logger::trace(L"The process started successfully"); - } - else - { - Logger::warn(L"RunNonElevatedEx() failed. Trying fallback"); - std::wstring action_runner_path = get_module_folderpath() + L"\\PowerToys.ActionRunner.exe"; - std::wstring newParams = L"-run-non-elevated -target modules\\launcher\\PowerToys.PowerLauncher.exe " + params; - if (run_non_elevated(action_runner_path, newParams, nullptr)) - { - processStarted = true; - Logger::trace("Started PowerToys Run Process"); - } - else - { - Logger::warn("Failed to start PowerToys Run"); - } - } - } processStarting = false; m_enabled = true; Logger::info("Microsoft_Launcher::enable() end"); @@ -343,7 +325,8 @@ public: /* Now, PowerToys Run uses a global hotkey so that it can get focus. * Activate it with the centralized keyboard hook only if the setting is on.*/ - if (m_use_centralized_keyboard_hook) { + if (m_use_centralized_keyboard_hook) + { Logger::trace("Set POWER_LAUNCHER_SHARED_EVENT"); SetEvent(m_hCentralizedKeyboardHookEvent); return true; @@ -404,7 +387,7 @@ void Microsoft_Launcher::parse_hotkey(PowerToysSettings::PowerToyValues& setting m_hotkey.ctrl = jsonHotkeyObject.GetNamedBoolean(JSON_KEY_CTRL); m_hotkey.key = static_cast(jsonHotkeyObject.GetNamedNumber(JSON_KEY_CODE)); } - catch(...) + catch (...) { Logger::error("Failed to initialize PT Run start shortcut"); } diff --git a/src/modules/launcher/Microsoft.Launcher/packages.config b/src/modules/launcher/Microsoft.Launcher/packages.config index 81f107b8bc..d758b61ef1 100644 --- a/src/modules/launcher/Microsoft.Launcher/packages.config +++ b/src/modules/launcher/Microsoft.Launcher/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj b/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj index 8925fb4718..87f712ca7c 100644 --- a/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj +++ b/src/modules/launcher/PowerLauncher.Telemetry/PowerLauncher.Telemetry.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net6.0-windows x64 x64 $(Version).0 diff --git a/src/modules/previewpane/powerpreview/packages.config b/src/modules/previewpane/powerpreview/packages.config index 81f107b8bc..d758b61ef1 100644 --- a/src/modules/previewpane/powerpreview/packages.config +++ b/src/modules/previewpane/powerpreview/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/src/modules/previewpane/powerpreview/powerpreview.vcxproj b/src/modules/previewpane/powerpreview/powerpreview.vcxproj index 9ffc9dfc34..c43c21f646 100644 --- a/src/modules/previewpane/powerpreview/powerpreview.vcxproj +++ b/src/modules/previewpane/powerpreview/powerpreview.vcxproj @@ -1,6 +1,7 @@ + @@ -108,5 +109,6 @@ + \ No newline at end of file diff --git a/src/runner/settings_window.cpp b/src/runner/settings_window.cpp index dcce81b874..5d84d6847d 100644 --- a/src/runner/settings_window.cpp +++ b/src/runner/settings_window.cpp @@ -334,24 +334,16 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op // 1. Run on start up. PTSettingsHelper::save_general_settings(save_settings.to_json()); - std::wstring executable_args = L"\""; - executable_args.append(executable_path); - executable_args.append(L"\" "); - executable_args.append(powertoys_pipe_name); - executable_args.append(L" "); - executable_args.append(settings_pipe_name); - executable_args.append(L" "); - executable_args.append(std::to_wstring(powertoys_pid)); - executable_args.append(L" "); - executable_args.append(settings_theme); - executable_args.append(L" "); - executable_args.append(settings_elevatedStatus); - executable_args.append(L" "); - executable_args.append(settings_isUserAnAdmin); - executable_args.append(L" "); - executable_args.append(settings_showOobe); - executable_args.append(L" "); - executable_args.append(settings_showScoobe); + std::wstring executable_args = fmt::format(L"\"{}\" {} {} {} {} {} {} {} {}", + executable_path, + powertoys_pipe_name, + settings_pipe_name, + std::to_wstring(powertoys_pid), + settings_theme, + settings_elevatedStatus, + settings_isUserAnAdmin, + settings_showOobe, + settings_showScoobe); if (settings_window.has_value()) { @@ -363,10 +355,14 @@ void run_settings_window(bool show_oobe_window, bool show_scoobe_window, std::op if (is_process_elevated()) { - // TODO: Revisit this after switching to .NET 5 - // Due to a bug in .NET, running the Settings process as non-elevated - // from an elevated process sometimes results in a crash. - // process_created = run_settings_non_elevated(executable_path.c_str(), executable_args.data(), &process_info); + auto res = RunNonElevatedFailsafe(executable_path, executable_args, get_module_folderpath()); + process_created = res.has_value(); + if (process_created) + { + process_info.dwProcessId = res->processID; + process_info.hProcess = res->processHandle.release(); + g_isLaunchInProgress = false; + } } if (FALSE == process_created) diff --git a/src/runner/tray_icon.cpp b/src/runner/tray_icon.cpp index 01b45f42e1..6fe32df61f 100644 --- a/src/runner/tray_icon.cpp +++ b/src/runner/tray_icon.cpp @@ -109,7 +109,7 @@ void handle_tray_command(HWND window, const WPARAM command_id, LPARAM lparam) case ID_DOCUMENTATION_MENU_COMMAND: { - RunNonElevatedEx(L"https://aka.ms/PowerToysOverview", L""); + RunNonElevatedEx(L"https://aka.ms/PowerToysOverview", L"", L""); break; } diff --git a/src/settings-ui/PowerToys.Settings/App.xaml b/src/settings-ui/PowerToys.Settings/App.xaml deleted file mode 100644 index deedff2ed9..0000000000 --- a/src/settings-ui/PowerToys.Settings/App.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/src/settings-ui/PowerToys.Settings/App.xaml.cs b/src/settings-ui/PowerToys.Settings/App.xaml.cs deleted file mode 100644 index 50d0f989b5..0000000000 --- a/src/settings-ui/PowerToys.Settings/App.xaml.cs +++ /dev/null @@ -1,77 +0,0 @@ -// 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; -using System.Windows; -using Microsoft.PowerToys.Settings.UI.Library.Telemetry.Events; -using Microsoft.PowerToys.Telemetry; - -namespace PowerToys.Settings -{ - /// - /// Interaction logic for App.xaml. - /// - public partial class App : Application - { - private MainWindow settingsWindow; - - public bool ShowOobe { get; set; } - - public bool ShowScoobe { get; set; } - - public Type StartupPage { get; set; } = typeof(Microsoft.PowerToys.Settings.UI.Views.GeneralPage); - - public void OpenSettingsWindow(Type type) - { - if (settingsWindow == null) - { - settingsWindow = new MainWindow(); - } - else if (settingsWindow.WindowState == WindowState.Minimized) - { - settingsWindow.WindowState = WindowState.Normal; - } - - settingsWindow.Show(); - settingsWindow.NavigateToSection(type); - } - - private void InitHiddenSettingsWindow() - { - settingsWindow = new MainWindow(); - - Utils.ShowHide(settingsWindow); - Utils.CenterToScreen(settingsWindow); - } - - private void Application_Startup(object sender, StartupEventArgs e) - { - if (!ShowOobe && !ShowScoobe) - { - settingsWindow = new MainWindow(); - settingsWindow.Show(); - settingsWindow.NavigateToSection(StartupPage); - } - else - { - // Create the Settings window so that it's fully initialized and - // it will be ready to receive the notification if the user opens - // the Settings from the tray icon. - InitHiddenSettingsWindow(); - if (ShowOobe) - { - PowerToysTelemetry.Log.WriteEvent(new OobeStartedEvent()); - OobeWindow oobeWindow = new OobeWindow(Microsoft.PowerToys.Settings.UI.OOBE.Enums.PowerToysModulesEnum.Overview); - oobeWindow.Show(); - } - else if (ShowScoobe) - { - PowerToysTelemetry.Log.WriteEvent(new ScoobeStartedEvent()); - OobeWindow scoobeWindow = new OobeWindow(Microsoft.PowerToys.Settings.UI.OOBE.Enums.PowerToysModulesEnum.WhatsNew); - scoobeWindow.Show(); - } - } - } - } -} diff --git a/src/settings-ui/PowerToys.Settings/Helpers/NativeMethods.cs b/src/settings-ui/PowerToys.Settings/Helpers/NativeMethods.cs deleted file mode 100644 index ab7942fbe1..0000000000 --- a/src/settings-ui/PowerToys.Settings/Helpers/NativeMethods.cs +++ /dev/null @@ -1,21 +0,0 @@ -// 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; -using System.Runtime.InteropServices; - -namespace PowerToys.Settings.Helpers -{ - public static class NativeMethods - { - internal const int SW_SHOWNORMAL = 1; - internal const int SW_SHOWMAXIMIZED = 3; - - [DllImport("user32.dll")] - internal static extern bool SetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl); - - [DllImport("user32.dll")] - internal static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl); - } -} diff --git a/src/settings-ui/PowerToys.Settings/MainWindow.xaml b/src/settings-ui/PowerToys.Settings/MainWindow.xaml deleted file mode 100644 index 814dcda9c5..0000000000 --- a/src/settings-ui/PowerToys.Settings/MainWindow.xaml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - diff --git a/src/settings-ui/PowerToys.Settings/MainWindow.xaml.cs b/src/settings-ui/PowerToys.Settings/MainWindow.xaml.cs deleted file mode 100644 index eedcb8c289..0000000000 --- a/src/settings-ui/PowerToys.Settings/MainWindow.xaml.cs +++ /dev/null @@ -1,203 +0,0 @@ -// 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; -using System.ComponentModel; -using System.Drawing; -using System.Windows; -using System.Windows.Interop; -using Microsoft.PowerLauncher.Telemetry; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; -using Microsoft.PowerToys.Settings.UI.Views; -using Microsoft.PowerToys.Telemetry; -using Microsoft.Toolkit.Wpf.UI.XamlHost; -using PowerToys.Settings.Helpers; -using Windows.ApplicationModel.Resources; -using Windows.Data.Json; - -namespace PowerToys.Settings -{ - // Interaction logic for MainWindow.xaml. - public partial class MainWindow : Window - { - private static Window inst; - - private bool isOpen = true; - - public MainWindow() - { - var bootTime = new System.Diagnostics.Stopwatch(); - bootTime.Start(); - - this.InitializeComponent(); - - Utils.FitToScreen(this); - - ResourceLoader loader = ResourceLoader.GetForViewIndependentUse(); - Title = loader.GetString("SettingsWindow_Title"); - - bootTime.Stop(); - - PowerToysTelemetry.Log.WriteEvent(new SettingsBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds }); - } - - public static void CloseHiddenWindow() - { - if (inst != null && inst.Visibility == Visibility.Hidden) - { - inst.Close(); - } - } - - public void NavigateToSection(Type type) - { - if (inst != null) - { - Activate(); - ShellPage.Navigate(type); - } - } - - protected override void OnSourceInitialized(EventArgs e) - { - base.OnSourceInitialized(e); - - var handle = new WindowInteropHelper(this).Handle; - NativeMethods.GetWindowPlacement(handle, out var startupPlacement); - var placement = Utils.DeserializePlacementOrDefault(handle); - NativeMethods.SetWindowPlacement(handle, ref placement); - - var windowRect = new Rectangle((int)Left, (int)Top, (int)Width, (int)Height); - var screenRect = new Rectangle((int)SystemParameters.VirtualScreenLeft, (int)SystemParameters.VirtualScreenTop, (int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight); - var intersection = Rectangle.Intersect(windowRect, screenRect); - - // Restore default position if 5% of width or height of the window is offscreen - if (intersection.Width < (Width * 0.95) || intersection.Height < (Height * 0.95)) - { - NativeMethods.SetWindowPlacement(handle, ref startupPlacement); - } - } - - protected override void OnClosing(CancelEventArgs e) - { - base.OnClosing(e); - var handle = new WindowInteropHelper(this).Handle; - - Utils.SerializePlacement(handle); - } - - private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) - { - // If sender is null, it could lead to a NullReferenceException. This might occur on restarting as admin (check https://github.com/microsoft/PowerToys/issues/7393 for details) - if (sender == null) - { - return; - } - - // Hook up x:Bind source. - WindowsXamlHost windowsXamlHost = sender as WindowsXamlHost; - ShellPage shellPage = windowsXamlHost.GetUwpInternalObject() as ShellPage; - - if (shellPage != null) - { - // send IPC Message - ShellPage.SetDefaultSndMessageCallback(msg => - { - // IPC Manager is null when launching runner directly - Program.GetTwoWayIPCManager()?.Send(msg); - }); - - // send IPC Message - ShellPage.SetRestartAdminSndMessageCallback(msg => - { - Program.GetTwoWayIPCManager()?.Send(msg); - isOpen = false; - System.Windows.Application.Current.Shutdown(); // close application - }); - - // send IPC Message - ShellPage.SetCheckForUpdatesMessageCallback(msg => - { - Program.GetTwoWayIPCManager()?.Send(msg); - }); - - // open oobe - ShellPage.SetOpenOobeCallback(() => - { - var oobe = new OobeWindow(Microsoft.PowerToys.Settings.UI.OOBE.Enums.PowerToysModulesEnum.Overview); - oobe.Show(); - }); - - // receive IPC Message - Program.IPCMessageReceivedCallback = (string msg) => - { - if (ShellPage.ShellHandler.IPCResponseHandleList != null) - { - var success = JsonObject.TryParse(msg, out JsonObject json); - if (success) - { - foreach (Action handle in ShellPage.ShellHandler.IPCResponseHandleList) - { - handle(json); - } - } - else - { - Logger.LogError("Failed to parse JSON from IPC message."); - } - } - }; - - ShellPage.SetElevationStatus(Program.IsElevated); - ShellPage.SetIsUserAnAdmin(Program.IsUserAnAdmin); - shellPage.Refresh(); - } - - // XAML Islands: If the window is open, explicitly force it to be shown to solve the blank dialog issue https://github.com/microsoft/PowerToys/issues/3384 - if (isOpen) - { - try - { - Show(); - } - catch (InvalidOperationException) - { - } - } - } - - private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) - { - if (OobeWindow.IsOpened) - { - e.Cancel = true; - ((Window)sender).Hide(); - } - else - { - isOpen = false; - } - - // XAML Islands: If the window is closed while minimized, exit the process. Required to avoid process not terminating issue - https://github.com/microsoft/PowerToys/issues/4430 - if (WindowState == WindowState.Minimized) - { - // Run Environment.Exit on a separate task to avoid performance impact - System.Threading.Tasks.Task.Run(() => { Environment.Exit(0); }); - } - } - - private void MainWindow_Loaded(object sender, RoutedEventArgs e) - { - inst = (Window)sender; - } - - private void MainWindow_Activated(object sender, EventArgs e) - { - if (((Window)sender).Visibility == Visibility.Hidden) - { - ((Window)sender).Visibility = Visibility.Visible; - } - } - } -} diff --git a/src/settings-ui/PowerToys.Settings/OobeWindow.xaml b/src/settings-ui/PowerToys.Settings/OobeWindow.xaml deleted file mode 100644 index bb8332631e..0000000000 --- a/src/settings-ui/PowerToys.Settings/OobeWindow.xaml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - diff --git a/src/settings-ui/PowerToys.Settings/OobeWindow.xaml.cs b/src/settings-ui/PowerToys.Settings/OobeWindow.xaml.cs deleted file mode 100644 index fe21a6cf48..0000000000 --- a/src/settings-ui/PowerToys.Settings/OobeWindow.xaml.cs +++ /dev/null @@ -1,103 +0,0 @@ -// 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; -using System.Windows; -using System.Windows.Interop; -using interop; -using Microsoft.PowerToys.Settings.UI.Helpers; -using Microsoft.PowerToys.Settings.UI.OOBE.Enums; -using Microsoft.PowerToys.Settings.UI.OOBE.Views; -using Microsoft.Toolkit.Wpf.UI.XamlHost; -using Windows.ApplicationModel.Resources; - -namespace PowerToys.Settings -{ - /// - /// Interaction logic for OobeWindow.xaml - /// - public partial class OobeWindow : Window - { - private static Window inst; - private OobeShellPage shellPage; - private PowerToysModulesEnum initialModule; - - public static bool IsOpened - { - get - { - return inst != null; - } - } - - public OobeWindow(PowerToysModulesEnum initialModule) - { - InitializeComponent(); - Utils.FitToScreen(this); - this.initialModule = initialModule; - - ResourceLoader loader = ResourceLoader.GetForViewIndependentUse(); - Title = loader.GetString("OobeWindow_Title"); - } - - private void Window_Closed(object sender, EventArgs e) - { - if (shellPage != null) - { - shellPage.OnClosing(); - } - - inst = null; - MainWindow.CloseHiddenWindow(); - } - - private void Window_Loaded(object sender, RoutedEventArgs e) - { - if (inst != null) - { - inst.Close(); - } - - inst = this; - } - - private void WindowsXamlHost_ChildChanged(object sender, EventArgs e) - { - if (sender == null) - { - return; - } - - WindowsXamlHost windowsXamlHost = sender as WindowsXamlHost; - shellPage = windowsXamlHost.GetUwpInternalObject() as OobeShellPage; - - if (shellPage != null) - { - shellPage.NavigateToModule(initialModule); - } - - OobeShellPage.SetRunSharedEventCallback(() => - { - return Constants.PowerLauncherSharedEvent(); - }); - - OobeShellPage.SetColorPickerSharedEventCallback(() => - { - return Constants.ShowColorPickerSharedEvent(); - }); - - OobeShellPage.SetOpenMainWindowCallback((Type type) => - { - ((App)Application.Current).OpenSettingsWindow(type); - }); - } - - protected override void OnSourceInitialized(EventArgs e) - { - base.OnSourceInitialized(e); - var hwnd = new WindowInteropHelper(this).Handle; - NativeMethods.SetPopupStyle(hwnd); - } - } -} diff --git a/src/settings-ui/PowerToys.Settings/PowerToys.Settings.csproj b/src/settings-ui/PowerToys.Settings/PowerToys.Settings.csproj deleted file mode 100644 index 375f01bea1..0000000000 --- a/src/settings-ui/PowerToys.Settings/PowerToys.Settings.csproj +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - WinExe - netcoreapp3.1 - true - PowerToys.Settings.Program - Microsoft Corporation - PowerToys - PowerToys Settings UI Runner - logo.png - $(Version).0 - x64 - icon.ico - win-x64 - false - false - - - uap10.0.18362 - - - - ..\..\..\$(Platform)\$(Configuration)\Settings - false - full - true - DEBUG;TRACE - - - - ..\..\..\$(Platform)\$(Configuration)\Settings - true - - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - diff --git a/src/settings-ui/PowerToys.Settings/Program.cs b/src/settings-ui/PowerToys.Settings/Program.cs deleted file mode 100644 index 8a3c72f051..0000000000 --- a/src/settings-ui/PowerToys.Settings/Program.cs +++ /dev/null @@ -1,117 +0,0 @@ -// 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; -using System.Diagnostics; -using System.Windows; -using interop; -using ManagedCommon; - -namespace PowerToys.Settings -{ - public static class Program - { - private enum Arguments - { - PTPipeName = 0, - SettingsPipeName, - PTPid, - Theme, // used in the old settings - ElevatedStatus, - IsUserAdmin, - ShowOobeWindow, - ShowScoobeWindow, - SettingsWindow, - } - - // Quantity of arguments - private const int RequiredArgumentsQty = 8; - private const int RequiredAndOptionalArgumentsQty = 9; - - // Create an instance of the IPC wrapper. - private static TwoWayPipeMessageIPCManaged ipcmanager; - - public static bool IsElevated { get; set; } - - public static bool IsUserAnAdmin { get; set; } - - public static int PowerToysPID { get; set; } - - public static Action IPCMessageReceivedCallback { get; set; } - - [STAThread] - public static void Main(string[] args) - { - using (new Microsoft.PowerToys.Settings.UI.App()) - { - App app = new App(); - app.InitializeComponent(); - - if (args != null && args.Length >= RequiredArgumentsQty) - { - _ = int.TryParse(args[(int)Arguments.PTPid], out int powerToysPID); - PowerToysPID = powerToysPID; - - IsElevated = args[(int)Arguments.ElevatedStatus] == "true"; - IsUserAnAdmin = args[(int)Arguments.IsUserAdmin] == "true"; - app.ShowOobe = args[(int)Arguments.ShowOobeWindow] == "true"; - app.ShowScoobe = args[(int)Arguments.ShowScoobeWindow] == "true"; - - if (args.Length == RequiredAndOptionalArgumentsQty) - { - // open specific window - switch (args[(int)Arguments.SettingsWindow]) - { - case "Overview": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.GeneralPage); break; - case "AlwaysOnTop": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.AlwaysOnTopPage); break; - case "Awake": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.AwakePage); break; - case "ColorPicker": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.ColorPickerPage); break; - case "FancyZones": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.FancyZonesPage); break; - case "Run": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.PowerLauncherPage); break; - case "ImageResizer": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.ImageResizerPage); break; - case "KBM": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.KeyboardManagerPage); break; - case "MouseUtils": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.MouseUtilsPage); break; - case "PowerRename": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.PowerRenamePage); break; - case "FileExplorer": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.PowerPreviewPage); break; - case "ShortcutGuide": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.ShortcutGuidePage); break; - case "VideoConference": app.StartupPage = typeof(Microsoft.PowerToys.Settings.UI.Views.VideoConferencePage); break; - default: Debug.Assert(false, "Unexpected SettingsWindow argument value"); break; - } - } - - RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () => - { - Environment.Exit(0); - }); - - ipcmanager = new TwoWayPipeMessageIPCManaged(args[(int)Arguments.SettingsPipeName], args[(int)Arguments.PTPipeName], (string message) => - { - if (IPCMessageReceivedCallback != null && message.Length > 0) - { - Application.Current.Dispatcher.BeginInvoke(new System.Action(() => - { - IPCMessageReceivedCallback(message); - })); - } - }); - ipcmanager.Start(); - app.Run(); - } - else - { - MessageBox.Show( - "The application cannot be run as a standalone process. Please start the application through the runner.", - "Forbidden", - MessageBoxButton.OK); - app.Shutdown(); - } - } - } - - public static TwoWayPipeMessageIPCManaged GetTwoWayIPCManager() - { - return ipcmanager; - } - } -} diff --git a/src/settings-ui/PowerToys.Settings/Utils.cs b/src/settings-ui/PowerToys.Settings/Utils.cs deleted file mode 100644 index af7ae29777..0000000000 --- a/src/settings-ui/PowerToys.Settings/Utils.cs +++ /dev/null @@ -1,117 +0,0 @@ -// 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; -using System.IO; -using System.Runtime.InteropServices; -using System.Text.Json; -using System.Windows; -using PowerToys.Settings.Helpers; - -namespace PowerToys.Settings -{ - internal class Utils - { - private static string _placementPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\PowerToys\settings-placement.json"); - - public static void FitToScreen(Window window) - { - if (SystemParameters.WorkArea.Width < window.Width) - { - window.Width = SystemParameters.WorkArea.Width; - } - - if (SystemParameters.WorkArea.Height < window.Height) - { - window.Height = SystemParameters.WorkArea.Height; - } - } - - public static void CenterToScreen(Window window) - { - if (SystemParameters.WorkArea.Height <= window.Height) - { - window.Top = 0; - } - else - { - window.Top = (SystemParameters.WorkArea.Height - window.Height) / 2; - } - - if (SystemParameters.WorkArea.Width <= window.Width) - { - window.Left = 0; - } - else - { - window.Left = (SystemParameters.WorkArea.Width - window.Width) / 2; - } - } - - public static void ShowHide(Window window) - { - // To limit the visual flickering, show the window with a size of 0,0 - // and don't show it in the taskbar - var originalHeight = window.Height; - var originalWidth = window.Width; - var originalMinHeight = window.MinHeight; - var originalMinWidth = window.MinWidth; - - window.MinHeight = 0; - window.MinWidth = 0; - window.Height = 0; - window.Width = 0; - window.ShowInTaskbar = false; - - window.Show(); - window.Hide(); - - window.Height = originalHeight; - window.Width = originalWidth; - window.MinHeight = originalMinHeight; - window.MinWidth = originalMinWidth; - window.ShowInTaskbar = true; - } - - public static WINDOWPLACEMENT DeserializePlacementOrDefault(IntPtr handle) - { - if (File.Exists(_placementPath)) - { - try - { - var json = File.ReadAllText(_placementPath); - var placement = JsonSerializer.Deserialize(json); - - placement.Length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)); - placement.Flags = 0; - placement.ShowCmd = placement.ShowCmd == NativeMethods.SW_SHOWMAXIMIZED ? NativeMethods.SW_SHOWMAXIMIZED : NativeMethods.SW_SHOWNORMAL; - return placement; - } -#pragma warning disable CA1031 // Do not catch general exception types - catch (Exception) -#pragma warning restore CA1031 // Do not catch general exception types - { - } - } - - _ = NativeMethods.GetWindowPlacement(handle, out var defaultPlacement); - return defaultPlacement; - } - - public static void SerializePlacement(IntPtr handle) - { - _ = NativeMethods.GetWindowPlacement(handle, out var placement); - try - { - var json = JsonSerializer.Serialize(placement); - File.WriteAllText(_placementPath, json); - } -#pragma warning disable CA1031 // Do not catch general exception types - catch (Exception) -#pragma warning restore CA1031 // Do not catch general exception types - { - } - } - } -} diff --git a/src/settings-ui/PowerToys.Settings/app.manifest b/src/settings-ui/PowerToys.Settings/app.manifest deleted file mode 100644 index 256260e61b..0000000000 --- a/src/settings-ui/PowerToys.Settings/app.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/settings-ui/Settings.UI.Library/Settings.UI.Library.csproj b/src/settings-ui/Settings.UI.Library/Settings.UI.Library.csproj index 7b51779199..94be3205fa 100644 --- a/src/settings-ui/Settings.UI.Library/Settings.UI.Library.csproj +++ b/src/settings-ui/Settings.UI.Library/Settings.UI.Library.csproj @@ -3,7 +3,7 @@ - netstandard2.0 + net6.0-windows x64 $(Version).0 Microsoft Corporation diff --git a/src/settings-ui/Settings.UI.Library/ViewModels/ImageResizerViewModel.cs b/src/settings-ui/Settings.UI.Library/ViewModels/ImageResizerViewModel.cs index b1dbb86b63..533245e942 100644 --- a/src/settings-ui/Settings.UI.Library/ViewModels/ImageResizerViewModel.cs +++ b/src/settings-ui/Settings.UI.Library/ViewModels/ImageResizerViewModel.cs @@ -389,7 +389,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels if (name.StartsWith(namePrefix, StringComparison.InvariantCulture)) { - if (int.TryParse(name.Substring(namePrefix.Length), out int number)) + if (int.TryParse(name.AsSpan(namePrefix.Length), out int number)) { if (newSizeCounter < number) { diff --git a/src/settings-ui/Settings.UI.Library/ViewModels/KeyboardManagerViewModel.cs b/src/settings-ui/Settings.UI.Library/ViewModels/KeyboardManagerViewModel.cs index 1964cfb2ec..635d35ad3b 100644 --- a/src/settings-ui/Settings.UI.Library/ViewModels/KeyboardManagerViewModel.cs +++ b/src/settings-ui/Settings.UI.Library/ViewModels/KeyboardManagerViewModel.cs @@ -222,7 +222,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels Logger.LogInfo($"Starting {PowerToyName} editor from {path}"); // InvariantCulture: type represents the KeyboardManagerEditorType enum value - editor = Process.Start(path, $"{type.ToString(CultureInfo.InvariantCulture)} {Process.GetCurrentProcess().Id}"); + editor = Process.Start(path, $"{type.ToString(CultureInfo.InvariantCulture)} {Environment.ProcessId}"); } catch (Exception e) { diff --git a/src/settings-ui/Settings.UI.UnitTests/Settings.UI.UnitTests.csproj b/src/settings-ui/Settings.UI.UnitTests/Settings.UI.UnitTests.csproj index b212fac928..fbeae3b97b 100644 --- a/src/settings-ui/Settings.UI.UnitTests/Settings.UI.UnitTests.csproj +++ b/src/settings-ui/Settings.UI.UnitTests/Settings.UI.UnitTests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0-windows false x64 $(Version).0 diff --git a/src/settings-ui/Settings.UI/App.xaml b/src/settings-ui/Settings.UI/App.xaml index ad9869e4bf..0ec73f08c0 100644 --- a/src/settings-ui/Settings.UI/App.xaml +++ b/src/settings-ui/Settings.UI/App.xaml @@ -1,19 +1,20 @@ - + xmlns:local="using:Microsoft.PowerToys.Settings.UI" + xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"> - + + 6,16,16,16 @@ -28,6 +29,7 @@