mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
refactor: a better way to fix window drop shadow effect on Win10
This commit is contained in:
parent
687b58576d
commit
5574dd2c38
1 changed files with 9 additions and 23 deletions
|
@ -26,23 +26,11 @@ namespace SourceGit.Native
|
||||||
internal string szCSDVersion;
|
internal string szCSDVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
internal struct MARGINS
|
|
||||||
{
|
|
||||||
public int cxLeftWidth;
|
|
||||||
public int cxRightWidth;
|
|
||||||
public int cyTopHeight;
|
|
||||||
public int cyBottomHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)]
|
|
||||||
private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs);
|
|
||||||
|
|
||||||
[DllImport("ntdll")]
|
[DllImport("ntdll")]
|
||||||
private static extern int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation);
|
private static extern int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation);
|
||||||
|
|
||||||
[DllImport("dwmapi.dll")]
|
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, SetLastError = false)]
|
||||||
private static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);
|
private static extern bool PathFindOnPath([In, Out] StringBuilder pszFile, [In] string[] ppszOtherDirs);
|
||||||
|
|
||||||
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = false)]
|
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = false)]
|
||||||
private static extern IntPtr ILCreateFromPathW(string pszPath);
|
private static extern IntPtr ILCreateFromPathW(string pszPath);
|
||||||
|
@ -60,8 +48,8 @@ namespace SourceGit.Native
|
||||||
v.dwOSVersionInfoSize = (uint)Marshal.SizeOf<RTL_OSVERSIONINFOEX>();
|
v.dwOSVersionInfoSize = (uint)Marshal.SizeOf<RTL_OSVERSIONINFOEX>();
|
||||||
if (RtlGetVersion(ref v) == 0 && (v.dwMajorVersion < 10 || v.dwBuildNumber < 22000))
|
if (RtlGetVersion(ref v) == 0 && (v.dwMajorVersion < 10 || v.dwBuildNumber < 22000))
|
||||||
{
|
{
|
||||||
Window.WindowStateProperty.Changed.AddClassHandler<Window>((w, _) => ExtendWindowFrame(w));
|
Window.WindowStateProperty.Changed.AddClassHandler<Window>((w, _) => FixWindowFrameOnWin10(w));
|
||||||
Control.LoadedEvent.AddClassHandler<Window>((w, _) => ExtendWindowFrame(w));
|
Control.LoadedEvent.AddClassHandler<Window>((w, _) => FixWindowFrameOnWin10(w));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,14 +194,12 @@ namespace SourceGit.Native
|
||||||
Process.Start(start);
|
Process.Start(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExtendWindowFrame(Window w)
|
private void FixWindowFrameOnWin10(Window w)
|
||||||
{
|
{
|
||||||
var platformHandle = w.TryGetPlatformHandle();
|
if (w.WindowState != WindowState.Normal)
|
||||||
if (platformHandle == null)
|
w.SystemDecorations = SystemDecorations.Full;
|
||||||
return;
|
else
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in a new issue