mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-03 10:56:36 +01:00
Compare commits
2 Commits
v0.91.0
...
dev/crutka
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43bcab429b | ||
|
|
469ffd93ea |
1
.github/actions/spell-check/allow/code.txt
vendored
1
.github/actions/spell-check/allow/code.txt
vendored
@@ -271,6 +271,7 @@ mengyuanchen
|
||||
|
||||
# DllName
|
||||
testhost
|
||||
Testably
|
||||
|
||||
#Tools
|
||||
OIP
|
||||
@@ -112,5 +112,31 @@ namespace ManagedCommon
|
||||
public int cyTopHeight;
|
||||
public int cyBottomHeight;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Safely calls DwmExtendFrameIntoClientArea to handle potential COMExceptions
|
||||
/// that can occur after resuming from sleep state.
|
||||
/// </summary>
|
||||
/// <param name="hWnd">Window handle</param>
|
||||
/// <param name="pMarInset">Margins</param>
|
||||
/// <returns>IntPtr.Zero on success, error code otherwise</returns>
|
||||
internal static IntPtr SafeDwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset)
|
||||
{
|
||||
try
|
||||
{
|
||||
return DwmExtendFrameIntoClientArea(hWnd, ref pMarInset);
|
||||
}
|
||||
catch (COMException ex) when (ex.HResult == unchecked((int)0xD0000701))
|
||||
{
|
||||
// Return a default value when this specific DWM error occurs (typically after sleep/resume)
|
||||
// This is a non-critical styling error and can be safely ignored
|
||||
return new IntPtr(-1); // Indicator for this specific error
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// For other exceptions, rethrow to be handled by caller
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,9 @@ namespace ManagedCommon
|
||||
if (OSVersionHelper.IsWindows10())
|
||||
{
|
||||
var margins = new NativeMethods.MARGINS { cxLeftWidth = 0, cxRightWidth = 0, cyBottomHeight = 0, cyTopHeight = 2 };
|
||||
NativeMethods.DwmExtendFrameIntoClientArea(handle, ref margins);
|
||||
|
||||
// Use the safe version of DwmExtendFrameIntoClientArea that handles resume-from-sleep issues
|
||||
NativeMethods.SafeDwmExtendFrameIntoClientArea(handle, ref margins);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,19 +158,19 @@
|
||||
// the DLL and PDB files
|
||||
// you will need to add any other files required
|
||||
// (globs are supported)
|
||||
"Castle.Core.dll",
|
||||
"CommunityToolkit.Mvvm.dll",
|
||||
"Hosts.FuzzTests.dll",
|
||||
"Hosts.FuzzTests.pdb",
|
||||
"Microsoft.Windows.SDK.NET.dll",
|
||||
"WinRT.Runtime.dll",
|
||||
"Moq.dll",
|
||||
"testhost.dll",
|
||||
"Castle.Core.dll",
|
||||
"System.IO.Abstractions.dll",
|
||||
"CommunityToolkit.Mvvm.dll",
|
||||
"System.IO.Abstractions.TestingHelpers.dll",
|
||||
"TestableIO.System.IO.Abstractions.dll",
|
||||
"TestableIO.System.IO.Abstractions.TestingHelpers.dll",
|
||||
"TestableIO.System.IO.Abstractions.Wrappers.dll"
|
||||
"TestableIO.System.IO.Abstractions.Wrappers.dll",
|
||||
"Testably.Abstractions.FileSystem.Interface.dll",
|
||||
"WinRT.Runtime.dll"
|
||||
],
|
||||
"SdlWorkItemId": 49911822
|
||||
}
|
||||
|
||||
@@ -195,17 +195,37 @@ namespace PowerLauncher
|
||||
_viewModel.RegisterHotkey(_hwndSource.Handle);
|
||||
if (OSVersionHelper.IsGreaterThanWindows11_21H2())
|
||||
{
|
||||
// ResizeMode="NoResize" removes rounded corners. So force them to rounded.
|
||||
IntPtr hWnd = new WindowInteropHelper(GetWindow(this)).EnsureHandle();
|
||||
DWMWINDOWATTRIBUTE attribute = DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE;
|
||||
DWM_WINDOW_CORNER_PREFERENCE preference = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND;
|
||||
DwmSetWindowAttribute(hWnd, attribute, ref preference, sizeof(uint));
|
||||
try
|
||||
{
|
||||
// ResizeMode="NoResize" removes rounded corners. So force them to rounded.
|
||||
IntPtr hWnd = new WindowInteropHelper(GetWindow(this)).EnsureHandle();
|
||||
DWMWINDOWATTRIBUTE attribute = DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE;
|
||||
DWM_WINDOW_CORNER_PREFERENCE preference = DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_ROUND;
|
||||
DwmSetWindowAttribute(hWnd, attribute, ref preference, sizeof(uint));
|
||||
}
|
||||
catch (COMException ex) when (ex.HResult == unchecked((int)0xD0000701))
|
||||
{
|
||||
// Ignore this specific DWM error which can occur after resuming from sleep
|
||||
// This error is related to window styling and doesn't affect functionality
|
||||
Log.Exception("DWM styling error occurred (typically after sleep resume). This is non-critical.", ex, GetType());
|
||||
|
||||
// Fallback to non-rounded corners
|
||||
MainBorder.BorderThickness = new Thickness(0.5);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log other errors but continue execution
|
||||
Log.Exception("Error setting DWM window attributes", ex, GetType());
|
||||
|
||||
// Fallback to non-rounded corners
|
||||
MainBorder.BorderThickness = new Thickness(0.5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// On Windows10 ResizeMode="NoResize" removes the border so we add a new one.
|
||||
// Also on 22000 it crashes due to DWMWA_WINDOW_CORNER_PREFERENCE https://github.com/microsoft/PowerToys/issues/36558
|
||||
MainBorder.BorderThickness = new System.Windows.Thickness(0.5);
|
||||
MainBorder.BorderThickness = new Thickness(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user