Skip to content

Commit 48d0412

Browse files
committed
refactor: customize WM_NCHITTEST does not work any more
Signed-off-by: leo <longshuang@msn.cn>
1 parent 18667f7 commit 48d0412

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

src/Native/Windows.cs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ namespace SourceGit.Native
1717
[SupportedOSPlatform("windows")]
1818
internal class Windows : OS.IBackend
1919
{
20-
[StructLayout(LayoutKind.Sequential)]
21-
internal struct RECT
22-
{
23-
public int left;
24-
public int top;
25-
public int right;
26-
public int bottom;
27-
}
28-
2920
[StructLayout(LayoutKind.Sequential)]
3021
internal struct MARGINS
3122
{
@@ -50,9 +41,6 @@ internal struct MARGINS
5041
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = false)]
5142
private static extern int SHOpenFolderAndSelectItems(IntPtr pidlFolder, int cild, IntPtr apidl, int dwFlags);
5243

53-
[DllImport("user32.dll")]
54-
private static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
55-
5644
public void SetupApp(AppBuilder builder)
5745
{
5846
// Fix drop shadow issue on Windows 10
@@ -68,50 +56,6 @@ public void SetupWindow(Window window)
6856
window.ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome;
6957
window.ExtendClientAreaToDecorationsHint = true;
7058
window.BorderThickness = new Thickness(1);
71-
72-
Win32Properties.AddWndProcHookCallback(window, (IntPtr hWnd, uint msg, IntPtr _, IntPtr lParam, ref bool handled) =>
73-
{
74-
// Custom WM_NCHITTEST only used to limit the resize border to 4 * window.RenderScaling pixels.
75-
if (msg == 0x0084 && window.WindowState == WindowState.Normal)
76-
{
77-
var p = IntPtrToPixelPoint(lParam);
78-
GetWindowRect(hWnd, out var rcWindow);
79-
80-
var borderThickness = (int)(4 * window.RenderScaling);
81-
int y = 1;
82-
int x = 1;
83-
if (p.X >= rcWindow.left && p.X < rcWindow.left + borderThickness)
84-
x = 0;
85-
else if (p.X < rcWindow.right && p.X >= rcWindow.right - borderThickness)
86-
x = 2;
87-
88-
if (p.Y >= rcWindow.top && p.Y < rcWindow.top + borderThickness)
89-
y = 0;
90-
else if (p.Y < rcWindow.bottom && p.Y >= rcWindow.bottom - borderThickness)
91-
y = 2;
92-
93-
// If it's in the client area, do not handle it here.
94-
var zone = y * 3 + x;
95-
if (zone == 4)
96-
return IntPtr.Zero;
97-
98-
// If it's in the resize border area, return the proper HT code.
99-
handled = true;
100-
return zone switch
101-
{
102-
0 => 13, // HTTOPLEFT
103-
1 => 12, // HTTOP
104-
2 => 14, // HTTOPRIGHT
105-
3 => 10, // HTLEFT
106-
5 => 11, // HTRIGHT
107-
6 => 16, // HTBOTTOMLEFT
108-
7 => 15, // HTBOTTOM
109-
_ => 17, // HTBOTTOMRIGHT
110-
};
111-
}
112-
113-
return IntPtr.Zero;
114-
});
11559
}
11660

11761
public string GetDataDir()

0 commit comments

Comments
 (0)