|
6 | 6 | using System.Text; |
7 | 7 |
|
8 | 8 | using Avalonia; |
| 9 | +using Avalonia.Controls; |
9 | 10 | using Avalonia.Media; |
10 | 11 |
|
11 | 12 | namespace SourceGit.Native |
12 | 13 | { |
13 | 14 | [SupportedOSPlatform("windows")] |
14 | 15 | internal class Windows : OS.IBackend |
15 | 16 | { |
| 17 | + [StructLayout(LayoutKind.Sequential)] |
| 18 | + internal struct RTL_OSVERSIONINFOEX |
| 19 | + { |
| 20 | + internal uint dwOSVersionInfoSize; |
| 21 | + internal uint dwMajorVersion; |
| 22 | + internal uint dwMinorVersion; |
| 23 | + internal uint dwBuildNumber; |
| 24 | + internal uint dwPlatformId; |
| 25 | + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] |
| 26 | + internal string szCSDVersion; |
| 27 | + } |
| 28 | + |
| 29 | + [StructLayout(LayoutKind.Sequential)] |
| 30 | + internal struct MARGINS |
| 31 | + { |
| 32 | + public int cxLeftWidth; |
| 33 | + public int cxRightWidth; |
| 34 | + public int cyTopHeight; |
| 35 | + public int cyBottomHeight; |
| 36 | + } |
| 37 | + |
16 | 38 | [DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)] |
17 | 39 | private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs); |
18 | 40 |
|
| 41 | + [DllImport("ntdll")] |
| 42 | + private static extern int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation); |
| 43 | + |
| 44 | + [DllImport("dwmapi.dll")] |
| 45 | + private static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins); |
| 46 | + |
19 | 47 | public void SetupApp(AppBuilder builder) |
20 | 48 | { |
21 | 49 | builder.With(new FontManagerOptions() |
22 | 50 | { |
23 | 51 | DefaultFamilyName = "Microsoft YaHei UI", |
24 | 52 | FontFallbacks = [new FontFallback { FontFamily = "Microsoft YaHei" }], |
25 | 53 | }); |
| 54 | + |
| 55 | + // Fix drop shadow issue on Windows 10 |
| 56 | + RTL_OSVERSIONINFOEX v = new RTL_OSVERSIONINFOEX(); |
| 57 | + v.dwOSVersionInfoSize = (uint)Marshal.SizeOf<RTL_OSVERSIONINFOEX>(); |
| 58 | + if (RtlGetVersion(ref v) == 0 && (v.dwMajorVersion < 10 || v.dwBuildNumber < 22000)) |
| 59 | + { |
| 60 | + Window.WindowStateProperty.Changed.AddClassHandler<Window>((w, e) => |
| 61 | + { |
| 62 | + if (w.WindowState != WindowState.Maximized) |
| 63 | + { |
| 64 | + var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 }; |
| 65 | + DwmExtendFrameIntoClientArea(w.TryGetPlatformHandle().Handle, ref margins); |
| 66 | + } |
| 67 | + }); |
| 68 | + |
| 69 | + Window.LoadedEvent.AddClassHandler<Window>((w, e) => |
| 70 | + { |
| 71 | + if (w.WindowState != WindowState.Maximized) |
| 72 | + { |
| 73 | + var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 }; |
| 74 | + DwmExtendFrameIntoClientArea(w.TryGetPlatformHandle().Handle, ref margins); |
| 75 | + } |
| 76 | + }); |
| 77 | + } |
26 | 78 | } |
27 | 79 |
|
28 | 80 | public string FindGitExecutable() |
|
0 commit comments