fix: missing popup window shadows on Windows 10 (#879)

This commit is contained in:
leo 2025-01-08 09:40:23 +08:00
parent 5f7b6c3c66
commit df422b2219
No known key found for this signature in database

View file

@ -26,9 +26,21 @@ namespace SourceGit.Native
internal string szCSDVersion; 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); 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)] [DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)]
private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs); private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs);
@ -202,10 +214,12 @@ namespace SourceGit.Native
private void FixWindowFrameOnWin10(Window w) private void FixWindowFrameOnWin10(Window w)
{ {
if (w.WindowState == WindowState.Maximized || w.WindowState == WindowState.FullScreen) var platformHandle = w.TryGetPlatformHandle();
w.SystemDecorations = SystemDecorations.Full; if (platformHandle == null)
else if (w.WindowState == WindowState.Normal) return;
w.SystemDecorations = SystemDecorations.BorderOnly;
var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 };
DwmExtendFrameIntoClientArea(platformHandle.Handle, ref margins);
} }
#region EXTERNAL_EDITOR_FINDER #region EXTERNAL_EDITOR_FINDER