From 7a54badb4a5782c551deb2919f3c489fdb4fbc02 Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周日, 03 12月 2023 17:17:40 +0800
Subject: [PATCH] Add snap layout handling

---
 src/core/contexts/win32windowcontext_p.h |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/core/contexts/win32windowcontext_p.h b/src/core/contexts/win32windowcontext_p.h
index b218497..52f4433 100644
--- a/src/core/contexts/win32windowcontext_p.h
+++ b/src/core/contexts/win32windowcontext_p.h
@@ -12,13 +12,31 @@
         Win32WindowContext(QWindow *window, WindowItemDelegate *delegate);
         ~Win32WindowContext() override;
 
+        enum WindowPart {
+            Outside,
+            ClientArea,
+            ChromeButton,
+            ResizeBorder,
+            FixedBorder,
+            TitleBar,
+        };
+
     public:
         bool setup() override;
 
         bool windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
+        bool snapLayoutHandler(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam,
+                               LRESULT *result);
 
     protected:
-        WId windowId;
+        WId windowId = 0;
+
+        // Store the last hit test result, it's helpful to handle WM_MOUSEMOVE and WM_NCMOUSELEAVE.
+        WindowPart lastHitTestResult = WindowPart::Outside;
+
+        // True if we blocked a WM_MOUSELEAVE when mouse moves on chrome button, false when a
+        // WM_MOUSELEAVE comes or we manually call TrackMouseEvent().
+        bool mouseLeaveBlocked = false;
     };
 
 }

--
Gitblit v1.9.1