Skip to content

Commit cf137cc

Browse files
committed
Merge branch 'main' into stable
2 parents 2cc051e + 74c53c1 commit cf137cc

File tree

6 files changed

+71
-14
lines changed

6 files changed

+71
-14
lines changed

Directory.Packages.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
<!-- 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. -->
4141
<PackageVersion Include="MessagePack" Version="3.1.3" />
4242
<PackageVersion Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0" />
43-
<PackageVersion Include="Microsoft.CommandPalette.Extensions" Version="0.9.260303001" />
4443
<PackageVersion Include="Microsoft.Data.Sqlite" Version="9.0.10" />
4544
<!-- Including Microsoft.Bcl.AsyncInterfaces to force version, since it's used by Microsoft.SemanticKernel. -->
4645
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.10" />

installer/PowerToysSetupVNext/KeyboardManager.wxs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,28 @@
33
<?include $(sys.CURRENTDIR)\Common.wxi?>
44

55
<?define KeyboardManagerAssetsFiles=?>
6+
<?define KeyboardManagerAssetsWinUI3Files=?>
67
<?define KeyboardManagerAssetsFilesPath=$(var.BinDir)\Assets\KeyboardManager\?>
8+
<?define KeyboardManagerAssetsWinUI3FilesPath=$(var.BinDir)\WinUI3Apps\Assets\KeyboardManagerEditor\?>
79

810
<Fragment>
911
<DirectoryRef Id="BaseApplicationsAssetsFolder">
1012
<Directory Id="KeyboardManagerAssetsInstallFolder" Name="KeyboardManager" />
1113
</DirectoryRef>
14+
<DirectoryRef Id="WinUI3AppsAssetsFolder">
15+
<Directory Id="KeyboardManagerAssetsWinUI3InstallFolder" Name="KeyboardManagerEditor" />
16+
</DirectoryRef>
1217

1318
<DirectoryRef Id="KeyboardManagerAssetsInstallFolder" FileSource="$(var.KeyboardManagerAssetsFilesPath)">
1419
<!-- Generated by generateFileComponents.ps1 -->
1520
<!--KeyboardManagerAssetsFiles_Component_Def-->
1621
</DirectoryRef>
1722

23+
<DirectoryRef Id="KeyboardManagerAssetsWinUI3InstallFolder" FileSource="$(var.KeyboardManagerAssetsWinUI3FilesPath)">
24+
<!-- Generated by generateFileComponents.ps1 -->
25+
<!--KeyboardManagerAssetsWinUI3Files_Component_Def-->
26+
</DirectoryRef>
27+
1828
<DirectoryRef Id="INSTALLFOLDER">
1929
<Directory Id="KeyboardManagerEditorInstallFolder" Name="KeyboardManagerEditor" />
2030
<Directory Id="KeyboardManagerEngineInstallFolder" Name="KeyboardManagerEngine" />
@@ -57,6 +67,7 @@
5767
<RegistryValue Type="string" Name="RemoveKeyboardManagerFolder" Value="" KeyPath="yes" />
5868
</RegistryKey>
5969
<RemoveFolder Id="RemoveFolderKeyboardManagerAssetsInstallFolder" Directory="KeyboardManagerAssetsInstallFolder" On="uninstall" />
70+
<RemoveFolder Id="RemoveFolderKeyboardManagerAssetsWinUI3InstallFolder" Directory="KeyboardManagerAssetsWinUI3InstallFolder" On="uninstall" />
6071
<RemoveFolder Id="RemoveFolderKeyboardManagerEditorFolder" Directory="KeyboardManagerEditorInstallFolder" On="uninstall" />
6172
<RemoveFolder Id="RemoveFolderKeyboardManagerEngineFolder" Directory="KeyboardManagerEngineInstallFolder" On="uninstall" />
6273
</Component>

installer/PowerToysSetupVNext/generateAllFileComponents.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ Generate-FileComponents -fileListName "ImageResizerAssetsFiles" -wxsFilePath $PS
174174

175175
#KeyboardManager
176176
Generate-FileList -fileDepsJson "" -fileListName KeyboardManagerAssetsFiles -wxsFilePath $PSScriptRoot\KeyboardManager.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\Assets\KeyboardManager"
177+
Generate-FileList -fileDepsJson "" -fileListName KeyboardManagerAssetsWinUI3Files -wxsFilePath $PSScriptRoot\KeyboardManager.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\WinUI3Apps\Assets\KeyboardManagerEditor"
177178
Generate-FileComponents -fileListName "KeyboardManagerAssetsFiles" -wxsFilePath $PSScriptRoot\KeyboardManager.wxs
179+
Generate-FileComponents -fileListName "KeyboardManagerAssetsWinUI3Files" -wxsFilePath $PSScriptRoot\KeyboardManager.wxs
178180

179181
# Light Switch Service
180182
Generate-FileList -fileDepsJson "" -fileListName LightSwitchFiles -wxsFilePath $PSScriptRoot\LightSwitch.wxs -depsPath "$PSScriptRoot..\..\..\$platform\Release\LightSwitchService"

src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml.cs

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public sealed partial class MainWindow : WindowEx,
9494
private WindowPosition _currentWindowPosition = new();
9595

9696
private bool _preventHideWhenDeactivated;
97+
private bool _isLoadedFromDock;
9798

9899
private DevRibbon? _devRibbon;
99100

@@ -142,7 +143,7 @@ public MainWindow()
142143

143144
this.SetIcon();
144145
AppWindow.Title = RS_.GetString("AppName");
145-
RestoreWindowPosition();
146+
RestoreWindowPositionFromSavedSettings();
146147
UpdateWindowPositionInMemory();
147148

148149
WeakReferenceMessenger.Default.Register<DismissMessage>(this);
@@ -245,21 +246,36 @@ private void PositionCentered()
245246

246247
private void PositionCentered(DisplayArea displayArea)
247248
{
249+
// Use the saved window size when available so that a dock-resized HWND
250+
// (hidden but not destroyed) doesn't dictate the size on normal reopen.
251+
SizeInt32 windowSize;
252+
int windowDpi;
253+
254+
if (_currentWindowPosition.IsSizeValid)
255+
{
256+
windowSize = new SizeInt32(_currentWindowPosition.Width, _currentWindowPosition.Height);
257+
windowDpi = _currentWindowPosition.Dpi;
258+
}
259+
else
260+
{
261+
windowSize = AppWindow.Size;
262+
windowDpi = (int)this.GetDpiForWindow();
263+
}
264+
248265
var rect = WindowPositionHelper.CenterOnDisplay(
249-
displayArea,
250-
AppWindow.Size,
251-
(int)this.GetDpiForWindow());
266+
displayArea,
267+
windowSize,
268+
windowDpi);
252269

253270
if (rect is not null)
254271
{
255272
MoveAndResizeDpiAware(rect.Value);
256273
}
257274
}
258275

259-
private void RestoreWindowPosition()
276+
private void RestoreWindowPosition(WindowPosition? savedPosition)
260277
{
261-
var settings = App.Current.Services.GetService<SettingsModel>();
262-
if (settings?.LastWindowPosition is not { Width: > 0, Height: > 0 } savedPosition)
278+
if (savedPosition?.IsSizeValid != true)
263279
{
264280
// don't try to restore if the saved position is invalid, just recenter
265281
PositionCentered();
@@ -274,6 +290,17 @@ private void RestoreWindowPosition()
274290
MoveAndResizeDpiAware(newRect);
275291
}
276292

293+
private void RestoreWindowPositionFromSavedSettings()
294+
{
295+
var settings = App.Current.Services.GetService<SettingsModel>();
296+
RestoreWindowPosition(settings?.LastWindowPosition);
297+
}
298+
299+
private void RestoreWindowPositionFromMemory()
300+
{
301+
RestoreWindowPosition(_currentWindowPosition);
302+
}
303+
277304
/// <summary>
278305
/// Moves and resizes the window while suppressing WM_DPICHANGED.
279306
/// The caller is expected to provide a rect already scaled for the target display's DPI.
@@ -678,6 +705,8 @@ private static DisplayArea GetScreen(HWND currentHwnd, MonitorBehavior target)
678705

679706
public void Receive(ShowWindowMessage message)
680707
{
708+
_isLoadedFromDock = false;
709+
681710
var settings = App.Current.Services.GetService<SettingsModel>()!;
682711

683712
// Start session tracking
@@ -690,6 +719,13 @@ public void Receive(ShowWindowMessage message)
690719

691720
internal void Receive(ShowPaletteAtMessage message)
692721
{
722+
_isLoadedFromDock = true;
723+
724+
// Reset the size in case users have resized a dock window.
725+
// Ideally in the future, we'll have defined sizes that opening
726+
// a dock window will adhere to, but alas, that's the future.
727+
RestoreWindowPositionFromMemory();
728+
693729
ShowHwnd(HWND.Null, message.PosPixels, message.Anchor);
694730
}
695731

@@ -860,12 +896,17 @@ private void Uncloak()
860896
internal void MainWindow_Closed(object sender, WindowEventArgs args)
861897
{
862898
var serviceProvider = App.Current.Services;
863-
UpdateWindowPositionInMemory();
899+
900+
if (!_isLoadedFromDock)
901+
{
902+
UpdateWindowPositionInMemory();
903+
}
864904

865905
var settings = serviceProvider.GetService<SettingsModel>();
866906
if (settings is not null)
867907
{
868-
// a quick sanity check, so we don't overwrite correct values
908+
// If we were last shown from the dock, _currentWindowPosition still holds
909+
// the last non-dock placement because dock sessions intentionally skip updates.
869910
if (_currentWindowPosition.IsSizeValid)
870911
{
871912
settings.LastWindowPosition = _currentWindowPosition;
@@ -960,7 +1001,11 @@ internal void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
9601001
if (args.WindowActivationState == WindowActivationState.Deactivated)
9611002
{
9621003
// Save the current window position before hiding the window
963-
UpdateWindowPositionInMemory();
1004+
// but not when opened from dock — preserve the pre-dock size.
1005+
if (!_isLoadedFromDock)
1006+
{
1007+
UpdateWindowPositionInMemory();
1008+
}
9641009

9651010
// If there's a debugger attached...
9661011
if (System.Diagnostics.Debugger.IsAttached)

src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.PowerToys/Microsoft.CmdPal.Ext.PowerToys.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
<ItemGroup>
4040
<PackageReference Include="Microsoft.WindowsAppSDK" />
41-
<PackageReference Include="Microsoft.CommandPalette.Extensions" />
4241
<PackageReference Include="Microsoft.Windows.CsWin32">
4342
<PrivateAssets>all</PrivateAssets>
4443
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
@@ -56,6 +55,7 @@
5655
</PropertyGroup>
5756

5857
<ItemGroup>
58+
<ProjectReference Include="..\..\extensionsdk\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj" />
5959
<ProjectReference Include="..\..\..\..\common\ManagedCommon\ManagedCommon.csproj" />
6060
<ProjectReference Include="..\..\..\..\common\Common.Search\Common.Search.csproj" />
6161
<ProjectReference Include="..\..\..\..\common\Common.UI\Common.UI.csproj" />

src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
</tkcontrols:SettingsCard>
215215
</tkcontrols:SettingsExpander.Items>
216216
</tkcontrols:SettingsExpander>
217-
<InfoBar
217+
<!-- <InfoBar
218218
x:Name="PowerDisplayDisabledWarningBar"
219219
x:Uid="LightSwitch_PowerDisplayDisabledWarningBar"
220220
Background="Transparent"
@@ -265,7 +265,7 @@
265265
SelectedItem="{x:Bind ViewModel.SelectedLightModeProfile, Mode=TwoWay}" />
266266
</tkcontrols:SettingsCard>
267267
</tkcontrols:SettingsExpander.Items>
268-
</tkcontrols:SettingsExpander>
268+
</tkcontrols:SettingsExpander>-->
269269
</controls:SettingsGroup>
270270
<!-- Force mode buttons -->
271271
<!--<tkcontrols:SettingsCard

0 commit comments

Comments
 (0)