From df422b22196ebf054d1c95aa8a60789c0e23c821 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 8 Jan 2025 09:40:23 +0800 Subject: [PATCH] fix: missing popup window shadows on Windows 10 (#879) --- src/Native/Windows.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index 48fbb287..10f2970a 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -26,9 +26,21 @@ namespace SourceGit.Native internal string szCSDVersion; } - [DllImport("ntdll")] + [StructLayout(LayoutKind.Sequential)] + internal struct MARGINS + { + public int cxLeftWidth; + public int cxRightWidth; + public int cyTopHeight; + public int cyBottomHeight; + } + + [DllImport("ntdll.dll")] private static extern int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation); + [DllImport("dwmapi.dll")] + private static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins); + [DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)] private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs); @@ -202,10 +214,12 @@ namespace SourceGit.Native private void FixWindowFrameOnWin10(Window w) { - if (w.WindowState == WindowState.Maximized || w.WindowState == WindowState.FullScreen) - w.SystemDecorations = SystemDecorations.Full; - else if (w.WindowState == WindowState.Normal) - w.SystemDecorations = SystemDecorations.BorderOnly; + 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); } #region EXTERNAL_EDITOR_FINDER