Quellcode durchsuchen

Fixed mouse left window callbacks so they properly deal with non-client and client areas

Marko Pintera vor 12 Jahren
Ursprung
Commit
ee2fe35ce7
1 geänderte Dateien mit 32 neuen und 3 gelöschten Zeilen
  1. 32 3
      CamelotCore/Source/CmPlatformWndProc.cpp

+ 32 - 3
CamelotCore/Source/CmPlatformWndProc.cpp

@@ -157,12 +157,37 @@ namespace CamelotFramework
 
 				return HTCLIENT;
 			}
+		case WM_NCMOUSELEAVE:
 		case WM_MOUSELEAVE:
 			{
-				CM_LOCK_MUTEX(mSync);
-
-				mMouseLeftWindows.push_back(win);
 				mIsTrackingMouse = false; // TrackMouseEvent ends when this message is received and needs to be re-applied
+
+				POINT mousePos;
+				GetCursorPos(&mousePos);
+
+				// Ensure we have actually left the window - it's possible we just moved from client to non-client area but
+				// that's not what we're interested in
+				if(mousePos.x < win->getLeft() || mousePos.x > (INT32)(win->getLeft() + win->getWidth()) ||
+					mousePos.y < win->getTop() || mousePos.y > (INT32)(win->getTop() + win->getHeight()))
+				{
+					CM_LOCK_MUTEX(mSync);
+
+					mMouseLeftWindows.push_back(win);
+				}
+				else
+				{
+					TRACKMOUSEEVENT tme = { sizeof(tme) };
+					
+					if(uMsg == WM_MOUSELEAVE)
+						tme.dwFlags = TME_LEAVE | TME_NONCLIENT;
+					else
+						tme.dwFlags = TME_LEAVE;
+
+					tme.hwndTrack = hWnd;
+					TrackMouseEvent(&tme);
+
+					mIsTrackingMouse = true;
+				}
 			}
 			break;
 		case WM_NCMOUSEMOVE:
@@ -173,6 +198,10 @@ namespace CamelotFramework
 				{
 					TRACKMOUSEEVENT tme = { sizeof(tme) };
 					tme.dwFlags = TME_LEAVE;
+
+					if(uMsg == WM_NCMOUSEMOVE)
+						tme.dwFlags |= TME_NONCLIENT;
+
 					tme.hwndTrack = hWnd;
 					TrackMouseEvent(&tme);