mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
[Settings]Remember maximized state (#31424)
* restore settings in maximized state * fix using
This commit is contained in:
committed by
GitHub
parent
0afec7293b
commit
e607b26df6
@@ -82,7 +82,7 @@ namespace Microsoft.PowerToys.Settings.UI
|
|||||||
{
|
{
|
||||||
if (settingsWindow == null)
|
if (settingsWindow == null)
|
||||||
{
|
{
|
||||||
settingsWindow = new MainWindow(IsDarkTheme());
|
settingsWindow = new MainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsWindow.Activate();
|
settingsWindow.Activate();
|
||||||
@@ -92,7 +92,7 @@ namespace Microsoft.PowerToys.Settings.UI
|
|||||||
settingsWindow.NavigateToSection(type);
|
settingsWindow.NavigateToSection(type);
|
||||||
|
|
||||||
WindowHelpers.BringToForeground(settingsWindow.GetWindowHandle());
|
WindowHelpers.BringToForeground(settingsWindow.GetWindowHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ensurePageIsSelected)
|
if (ensurePageIsSelected)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using ManagedCommon;
|
|||||||
using Microsoft.PowerLauncher.Telemetry;
|
using Microsoft.PowerLauncher.Telemetry;
|
||||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||||
using Microsoft.PowerToys.Settings.UI.Library;
|
using Microsoft.PowerToys.Settings.UI.Library;
|
||||||
using Microsoft.PowerToys.Settings.UI.OOBE.Views;
|
|
||||||
using Microsoft.PowerToys.Settings.UI.Views;
|
using Microsoft.PowerToys.Settings.UI.Views;
|
||||||
using Microsoft.PowerToys.Telemetry;
|
using Microsoft.PowerToys.Telemetry;
|
||||||
using Microsoft.UI;
|
using Microsoft.UI;
|
||||||
@@ -41,6 +40,9 @@ namespace Microsoft.PowerToys.Settings.UI
|
|||||||
if (createHidden)
|
if (createHidden)
|
||||||
{
|
{
|
||||||
placement.ShowCmd = NativeMethods.SW_HIDE;
|
placement.ShowCmd = NativeMethods.SW_HIDE;
|
||||||
|
|
||||||
|
// Restore the last known placement on the first activation
|
||||||
|
this.Activated += Window_Activated;
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeMethods.SetWindowPlacement(hWnd, ref placement);
|
NativeMethods.SetWindowPlacement(hWnd, ref placement);
|
||||||
@@ -213,6 +215,17 @@ namespace Microsoft.PowerToys.Settings.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_Activated(object sender, WindowActivatedEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.WindowActivationState != WindowActivationState.Deactivated)
|
||||||
|
{
|
||||||
|
this.Activated -= Window_Activated;
|
||||||
|
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
|
||||||
|
var placement = Utils.DeserializePlacementOrDefault(hWnd);
|
||||||
|
NativeMethods.SetWindowPlacement(hWnd, ref placement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void EnsurePageIsSelected()
|
internal void EnsurePageIsSelected()
|
||||||
{
|
{
|
||||||
ShellPage.EnsurePageIsSelected();
|
ShellPage.EnsurePageIsSelected();
|
||||||
|
|||||||
Reference in New Issue
Block a user