mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 21:30:37 +08:00
fix: schedule DWM frame extension to next render frame on Windows 10 (#1087)
The DwmExtendFrameIntoClientArea call needs to be posted to the next render frame to ensure the window handle is fully initialized and avoid potential race conditions.
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Text;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace SourceGit.Native
|
||||
{
|
||||
@@ -214,12 +215,17 @@ namespace SourceGit.Native
|
||||
|
||||
private void FixWindowFrameOnWin10(Window w)
|
||||
{
|
||||
var platformHandle = w.TryGetPlatformHandle();
|
||||
if (platformHandle == null)
|
||||
return;
|
||||
// Schedule the DWM frame extension to run in the next render frame
|
||||
// to ensure proper timing with the window initialization sequence
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
var platformHandle = w.TryGetPlatformHandle();
|
||||
if (platformHandle == null)
|
||||
return;
|
||||
|
||||
var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 };
|
||||
DwmExtendFrameIntoClientArea(platformHandle.Handle, ref margins);
|
||||
var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 };
|
||||
DwmExtendFrameIntoClientArea(platformHandle.Handle, ref margins);
|
||||
}, DispatcherPriority.Render);
|
||||
}
|
||||
|
||||
#region EXTERNAL_EDITOR_FINDER
|
||||
|
||||
Reference in New Issue
Block a user