浏览代码

Added simulated mouse up event for resize/move events

Marko Pintera 12 年之前
父节点
当前提交
e217ac68ce
共有 3 个文件被更改,包括 18 次插入3 次删除
  1. 2 0
      CamelotCore/Include/CmPlatformWndProc.h
  2. 16 0
      CamelotCore/Source/CmPlatformWndProc.cpp
  3. 0 3
      EditorWindowDock.txt

+ 2 - 0
CamelotCore/Include/CmPlatformWndProc.h

@@ -11,6 +11,8 @@ namespace CamelotFramework
 		static LRESULT CALLBACK _win32WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 	private:
+		static UINT32 mMoveResizeMouseUpState; // 0 - Didn't receive and not waiting for mouse up, 1 - Awaiting mouse up, 2 - Received mouse up
+
 		static LRESULT translateNonClientAreaType(NonClientAreaBorderType type);
 	};
 }

+ 16 - 0
CamelotCore/Source/CmPlatformWndProc.cpp

@@ -1,9 +1,12 @@
 #include "CmPlatformWndProc.h"
 #include "CmRenderWindow.h"
 #include "CmApplication.h"
+#include "CmInput.h"
 
 namespace CamelotFramework
 {
+	UINT32 PlatformWndProc::mMoveResizeMouseUpState = 0;
+
 	LRESULT CALLBACK PlatformWndProc::_win32WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 	{
 		if (uMsg == WM_CREATE)
@@ -65,8 +68,14 @@ namespace CamelotFramework
 				return 0;
 			break;
 		case WM_ENTERSIZEMOVE:
+			mMoveResizeMouseUpState = 1;
 			break;
 		case WM_EXITSIZEMOVE:
+			// HACK - Windows doesn't send mouseUp event after move/resize if the cursor moved out of the original window bounds
+			if(mMoveResizeMouseUpState != 2)
+				gInput().instance().simulateButtonUp(BC_MOUSE_LEFT);
+
+			mMoveResizeMouseUpState = 0;
 			break;
 		case WM_MOVE:
 			windowMovedOrResized(win);
@@ -190,6 +199,13 @@ namespace CamelotFramework
 				}
 			}
 			break;
+		case WM_NCLBUTTONUP:
+		case WM_LBUTTONUP:
+			// Part of a hack that's done in WM_EXITSIZEMOVE (see there)
+			if(mMoveResizeMouseUpState = 1)
+				mMoveResizeMouseUpState = 2;
+
+			break;
 		case WM_NCMOUSEMOVE:
 		case WM_MOUSEMOVE:
 			{

+ 0 - 3
EditorWindowDock.txt

@@ -15,9 +15,6 @@ Possible solution to MouseUp problem:
   on WM_ENTERSIZEMOVE call OIS and SetCooperativeLevel(BACKGROUND)
   and on WM_EXITSIZEMOVE revert back to FOREGROUND coop level
 
-And for MouseMove problem:
-  Track mouse leave events, add a handler to Platform and hook up GUIManager to it
-
 ------------------------
 
 Other things to remember: