Browse Source

Moved Cursor and WindowEventUtilities to the new Platform class

Marko Pintera 12 years ago
parent
commit
d65fbbfe0e

+ 4 - 4
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -12,7 +12,7 @@
 #include "CmFont.h"
 #include "CmTextUtility.h"
 #include "CmTexture.h"
-#include "CmCursor.h"
+#include "CmPlatform.h"
 #include "BsGUIInputCaret.h"
 #include "BsGUIInputSelection.h"
 #include "BsDragAndDropManager.h"
@@ -351,7 +351,7 @@ namespace BansheeEngine
 
 			if(!mInputCursorSet)
 			{
-				Cursor::setCursor(CursorType::IBeam);
+				Platform::setCursor(CursorType::IBeam);
 				mInputCursorSet = true;
 			}
 
@@ -367,7 +367,7 @@ namespace BansheeEngine
 
 			if(!mDragInProgress && mInputCursorSet)
 			{
-				Cursor::setCursor(CursorType::Arrow);
+				Platform::setCursor(CursorType::Arrow);
 				mInputCursorSet = false;
 			}
 
@@ -431,7 +431,7 @@ namespace BansheeEngine
 
 				if(ev.getMouseOverElement() != this && mInputCursorSet)
 				{
-					Cursor::setCursor(CursorType::Arrow);
+					Platform::setCursor(CursorType::Arrow);
 					mInputCursorSet = false;
 				}
 

+ 1 - 1
BansheeEngine/Source/BsGUIManager.cpp

@@ -10,7 +10,7 @@
 #include "CmMesh.h"
 #include "CmUtil.h"
 #include "CmRenderWindowManager.h"
-#include "CmCursor.h"
+#include "CmPlatform.h"
 #include "CmRect.h"
 #include "CmApplication.h"
 #include "CmException.h"

+ 10 - 10
BansheeEngine/Source/BsGUIWindowFrame.cpp

@@ -6,7 +6,7 @@
 #include "BsGUILayoutOptions.h"
 #include "BsGUIMouseEvent.h"
 #include "CmApplication.h"
-#include "CmCursor.h"
+#include "CmPlatform.h"
 #include "CmTexture.h"
 #include "CmRenderWindow.h"
 
@@ -234,28 +234,28 @@ namespace BansheeEngine
 				switch (subArea)
 				{
 				case BansheeEngine::FrameSubArea::TopLeft:
-					Cursor::setCursor(CursorType::SizeNWSE);
+					Platform::setCursor(CursorType::SizeNWSE);
 					break;
 				case BansheeEngine::FrameSubArea::TopCenter:
-					Cursor::setCursor(CursorType::SizeNS);
+					Platform::setCursor(CursorType::SizeNS);
 					break;
 				case BansheeEngine::FrameSubArea::TopRight:
-					Cursor::setCursor(CursorType::SizeNESW);
+					Platform::setCursor(CursorType::SizeNESW);
 					break;
 				case BansheeEngine::FrameSubArea::MiddleLeft:
-					Cursor::setCursor(CursorType::SizeWE);
+					Platform::setCursor(CursorType::SizeWE);
 					break;
 				case BansheeEngine::FrameSubArea::MiddleRight:
-					Cursor::setCursor(CursorType::SizeWE);
+					Platform::setCursor(CursorType::SizeWE);
 					break;
 				case BansheeEngine::FrameSubArea::BottomLeft:
-					Cursor::setCursor(CursorType::SizeNESW);
+					Platform::setCursor(CursorType::SizeNESW);
 					break;
 				case BansheeEngine::FrameSubArea::BottomCenter:
-					Cursor::setCursor(CursorType::SizeNS);
+					Platform::setCursor(CursorType::SizeNS);
 					break;
 				case BansheeEngine::FrameSubArea::BottomRight:
-					Cursor::setCursor(CursorType::SizeNWSE);
+					Platform::setCursor(CursorType::SizeNWSE);
 					break;
 				}
 
@@ -311,7 +311,7 @@ namespace BansheeEngine
 		{
 			if(mResizeCursorSet)
 			{
-				Cursor::setCursor(CursorType::Arrow);
+				Platform::setCursor(CursorType::Arrow);
 				mResizeCursorSet = false;
 
 				return true;

+ 1 - 1
CamelotClient/CamelotClient.cpp

@@ -33,7 +33,7 @@
 #include "DbgEditorWidget1.h"
 #include "DbgEditorWidget2.h"
 #include "CmRTTIType.h"
-#include "CmCursor.h"
+#include "CmPlatform.h"
 
 #define DX11
 //#define DX9

+ 3 - 3
CamelotClient/Source/CmDebugCamera.cpp

@@ -5,7 +5,7 @@
 #include "CmMath.h"
 #include "CmSceneObject.h"
 #include "BsCamera.h"
-#include "CmCursor.h"
+#include "CmPlatform.h"
 
 using namespace BansheeEngine;
 
@@ -42,9 +42,9 @@ namespace CamelotFramework
 		if(camRotating != mLastButtonState)
 		{
 			if(camRotating)
-				Cursor::hide();
+				Platform::hideCursor();
 			else
-				Cursor::show();
+				Platform::showCursor();
 
 			mLastButtonState = camRotating;
 		}

+ 5 - 5
CamelotCore/CamelotCore.vcxproj

@@ -288,6 +288,7 @@
     <ClInclude Include="Include\CmPixelData.h" />
     <ClInclude Include="Include\CmPixelDataRTTI.h" />
     <ClInclude Include="Include\CmPixelUtil.h" />
+    <ClInclude Include="Include\CmPlatformWndProc.h" />
     <ClInclude Include="Include\CmRenderOperation.h" />
     <ClInclude Include="Include\CmRenderQueue.h" />
     <ClInclude Include="Include\CmSceneObjectRTTI.h" />
@@ -348,7 +349,7 @@
     <ClInclude Include="Include\CmMeshData.h" />
     <ClInclude Include="Include\CmMeshDataRTTI.h" />
     <ClInclude Include="Include\CmMultiRenderTexture.h" />
-    <ClInclude Include="Include\CmCursor.h" />
+    <ClInclude Include="Include\CmPlatform.h" />
     <ClInclude Include="Include\CmPass.h" />
     <ClInclude Include="Include\CmPassRTTI.h" />
     <ClInclude Include="Include\CmPrerequisites.h" />
@@ -385,7 +386,6 @@
     <ClInclude Include="Include\CmVertexDeclaration.h" />
     <ClInclude Include="Include\CmVertexData.h" />
     <ClInclude Include="Include\CmViewport.h" />
-    <ClInclude Include="Include\CmWindowEventUtilities.h" />
     <ClInclude Include="Include\CmResourceRTTI.h" />
     <ClInclude Include="Include\CmSceneObject.h" />
     <ClInclude Include="Include\CmComponent.h" />
@@ -395,7 +395,7 @@
     <ClInclude Include="Include\targetver.h" />
     <ClInclude Include="Include\CmVertexDeclarationRTTI.h" />
     <ClInclude Include="Include\CmTechnique.h" />
-    <ClInclude Include="Include\Win32\CmCursorImpl.h" />
+    <ClInclude Include="Include\Win32\CmPlatformImpl.h" />
     <ClInclude Include="Source\CmMeshRTTI.h" />
   </ItemGroup>
   <ItemGroup>
@@ -441,6 +441,7 @@
     <ClCompile Include="Source\CmGpuProgIncludeImporter.cpp" />
     <ClCompile Include="Source\CmPixelData.cpp" />
     <ClCompile Include="Source\CmPixelUtil.cpp" />
+    <ClCompile Include="Source\CmPlatformWndProc.cpp" />
     <ClCompile Include="Source\CmRenderer.cpp" />
     <ClCompile Include="Source\CmRenderQueue.cpp" />
     <ClCompile Include="Source\CmTextureView.cpp" />
@@ -479,11 +480,10 @@
     <ClCompile Include="Source\CmVertexDeclaration.cpp" />
     <ClCompile Include="Source\CmVertexData.cpp" />
     <ClCompile Include="Source\CmViewport.cpp" />
-    <ClCompile Include="Source\CmWindowEventUtilities.cpp" />
     <ClCompile Include="Source\CmSceneObject.cpp" />
     <ClCompile Include="Source\CmComponent.cpp" />
     <ClCompile Include="Source\stdafx.cpp" />
-    <ClCompile Include="Source\Win32\CmCursorImpl.cpp" />
+    <ClCompile Include="Source\Win32\CmPlatformImpl.cpp" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 15 - 15
CamelotCore/CamelotCore.vcxproj.filters

@@ -93,9 +93,6 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClInclude Include="Include\CmWindowEventUtilities.h">
-      <Filter>Header Files\Utility</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmApplication.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -420,12 +417,6 @@
     <ClInclude Include="Include\CmGpuResourceDataRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\Win32\CmCursorImpl.h">
-      <Filter>Header Files\Win32</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\CmCursor.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmTextUtility.h">
       <Filter>Header Files\Text</Filter>
     </ClInclude>
@@ -468,6 +459,15 @@
     <ClInclude Include="Include\CmRenderQueue.h">
       <Filter>Header Files\Renderer</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmPlatform.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\Win32\CmPlatformImpl.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmPlatformWndProc.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmApplication.cpp">
@@ -479,9 +479,6 @@
     <ClCompile Include="Source\stdafx.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\CmWindowEventUtilities.cpp">
-      <Filter>Source Files\Utility</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmGpuProgram.cpp">
       <Filter>Source Files\RenderSystem</Filter>
     </ClCompile>
@@ -689,9 +686,6 @@
     <ClCompile Include="Source\CmPixelData.cpp">
       <Filter>Source Files\Resources</Filter>
     </ClCompile>
-    <ClCompile Include="Source\Win32\CmCursorImpl.cpp">
-      <Filter>Source Files\Win32</Filter>
-    </ClCompile>
     <ClCompile Include="Source\CmTextUtility.cpp">
       <Filter>Source Files\Text</Filter>
     </ClCompile>
@@ -725,5 +719,11 @@
     <ClCompile Include="Source\CmRenderer.cpp">
       <Filter>Source Files\Renderer</Filter>
     </ClCompile>
+    <ClCompile Include="Source\Win32\CmPlatformImpl.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmPlatformWndProc.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 3 - 3
CamelotCore/Include/CmCursor.h → CamelotCore/Include/CmPlatform.h

@@ -18,9 +18,9 @@ enum class CursorType
 
 //Bring in the specific platform's header file
 #if CM_PLATFORM == CM_PLATFORM_WIN32
-# include "Win32/CmCursorImpl.h"
+# include "Win32/CmPlatformImpl.h"
 #elif (CM_PLATFORM == CM_PLATFORM_LINUX)
-# include "GLX/CmCursorImpl.h"
+# include "GLX/CmPlatformImpl.h"
 #elif CM_PLATFORM == CM_PLATFORM_APPLE
-# include "OSX/CmCursorImpl.h"
+# include "OSX/CmPlatformImpl.h"
 #endif

+ 22 - 0
CamelotCore/Include/CmPlatformWndProc.h

@@ -0,0 +1,22 @@
+#pragma once
+
+#include "CmPlatform.h"
+
+#define WM_CM_HIDECURSOR WM_USER + 101
+#define WM_CM_SHOWCURSOR WM_USER + 102
+
+#define WIN32_LEAN_AND_MEAN
+#if !defined(NOMINMAX) && defined(_MSC_VER)
+#	define NOMINMAX // Required to stop windows.h messing up std::min
+#endif
+#include <windows.h>
+#include <windowsx.h>
+
+namespace CamelotFramework
+{
+	class CM_EXPORT PlatformWndProc : public Platform
+	{
+	public:
+		static LRESULT CALLBACK _win32WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+	};
+}

+ 0 - 100
CamelotCore/Include/CmWindowEventUtilities.h

@@ -1,100 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __OgreWindowEventUtils_H__
-#define __OgreWindowEventUtils_H__
-
-#include "CmPrerequisites.h"
-#include <boost/signals.hpp>
-
-#if CM_PLATFORM == CM_PLATFORM_WIN32
-#  define WIN32_LEAN_AND_MEAN
-#  if !defined(NOMINMAX) && defined(_MSC_VER)
-#	define NOMINMAX // required to stop windows.h messing up std::min
-#  endif
-#  include <windows.h>
-#  include <windowsx.h>
-#elif CM_PLATFORM == CM_PLATFORM_APPLE && !defined(__LP64__)
-#  include <Carbon/Carbon.h>
-#endif
-
-#define WM_CM_HIDECURSOR WM_USER + 101
-#define WM_CM_SHOWCURSOR WM_USER + 102
-
-namespace CamelotFramework
-{
-	/**
-	@Remarks
-		Utility class to handle Window Events/Pumping/Messages
-	*/
-	class CM_EXPORT WindowEventUtilities
-	{
-	public:
-		/**
-		@Remarks
-			Call this once per frame if not using Root:startRendering(). This will update all registered
-			RenderWindows (If using external Windows, you can optionally register those yourself)
-		*/
-		static void messagePump();
-
-		/**
-		@Remarks
-			Called by RenderWindows upon creation for Ogre generated windows. You are free to add your
-			external windows here too if needed.
-		@param window
-			The RenderWindow to monitor
-		*/
-		static void _addRenderWindow(RenderWindow* window);
-
-		/**
-		@Remarks
-			Called by RenderWindows upon creation for Ogre generated windows. You are free to add your
-			external windows here too if needed.
-		@param window
-			The RenderWindow to remove from list
-		*/
-		static void _removeRenderWindow(RenderWindow* window);
-
-#if CM_PLATFORM == CM_PLATFORM_WIN32
-		//! Internal winProc (RenderWindow's use this when creating the Win32 Window)
-		static LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-#elif CM_PLATFORM == CM_PLATFORM_APPLE && !defined __OBJC__ && !defined(__LP64__)
-        //! Internal UPP Window Handler (RenderWindow's use this when creating the OS X Carbon Window
-        static OSStatus _CarbonWindowHandler(EventHandlerCallRef nextHandler, EventRef event, void* wnd);
-#endif
-
-		typedef Vector<RenderWindow*>::type Windows;
-		static Windows _msWindows;
-
-		static boost::signal<void(const Int2&)> onMouseMoved;
-		static boost::signal<void(float)> onMouseWheelScrolled;
-		static boost::signal<void(UINT32)> onCharInput;
-	};
-	/** @} */
-	/** @} */
-}
-#endif

+ 0 - 54
CamelotCore/Include/Win32/CmCursorImpl.h

@@ -1,54 +0,0 @@
-#pragma once
-
-#include "CmPrerequisites.h"
-#include "CmInt2.h"
-#include "CmRect.h"
-
-namespace CamelotFramework
-{
-	// Encapsulate native cursor type so we can avoid including windows.h as it pollutes the global namespace
-	struct CM_EXPORT NativeCursorData
-	{
-		struct Pimpl;
-
-		NativeCursorData();
-		~NativeCursorData();
-
-		Pimpl* data;
-	};
-
-	/**
-	 * @brief	Provides controls for Windows operating system cursor.
-	 */
-	class CM_EXPORT Cursor
-	{
-	public:
-		Cursor();
-		~Cursor();
-
-		/**
-		 * @brief	Moves the cursor to the specified screen position.
-		 */
-		static void setPosition(const Int2& screenPos);
-
-		static void clipToWindow(const RenderWindow& window);
-		static void clipToRect(const Rect& screenRect);
-		static void clipDisable();
-
-		static void hide();
-		static void show();
-
-		static bool isHidden() { return mIsHidden; }
-		
-		static void setCursor(CursorType type);
-		static void setCustomCursor(PixelData& pixelData, const Int2& hotSpot);
-
-		static void _win32ShowCursor();
-		static void _win32HideCursor();
-		
-	private:
-		static bool mIsHidden;
-		static NativeCursorData mCursor;
-		static bool mUsingCustom;
-	};
-}

+ 69 - 0
CamelotCore/Include/Win32/CmPlatformImpl.h

@@ -0,0 +1,69 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmInt2.h"
+#include "CmRect.h"
+#include <boost/signals.hpp>
+
+namespace CamelotFramework
+{
+	// Encapsulate native cursor type so we can avoid including windows.h as it pollutes the global namespace
+	struct CM_EXPORT NativeCursorData
+	{
+		struct Pimpl;
+
+		NativeCursorData();
+		~NativeCursorData();
+
+		Pimpl* data;
+	};
+
+	/**
+	 * @brief	Provides access for version Windows operating system functions, including
+	 * 			the main message pump.
+	 */
+	class CM_EXPORT Platform
+	{
+	public:
+		Platform() { }
+		virtual ~Platform() { }
+
+		/**
+		 * @brief	Moves the cursor to the specified screen position.
+		 */
+		static void setCursorPosition(const Int2& screenPos);
+
+		static void captureMouse(const RenderWindow& window);
+		static void releaseMouseCapture();
+
+		static void clipCursorToWindow(const RenderWindow& window);
+		static void clipCursorToRect(const Rect& screenRect);
+		static void clipCursorDisable();
+
+		static void hideCursor();
+		static void showCursor();
+
+		static bool isCursorHidden() { return mIsCursorHidden; }
+		
+		static void setCursor(CursorType type);
+		static void setCustomCursor(PixelData& pixelData, const Int2& hotSpot);
+
+		/**
+		 * @brief	Message pump. Processes OS messages and returns when it's free.
+		 * 			
+		 * @note	This method must be called from the core thread.
+		 */
+		static void messagePump();
+
+		static boost::signal<void(const Int2&)> onMouseMoved;
+		static boost::signal<void(float)> onMouseWheelScrolled;
+		static boost::signal<void(UINT32)> onCharInput;
+	protected:
+		static bool mIsCursorHidden;
+		static NativeCursorData mCursor;
+		static bool mUsingCustomCursor;
+
+		static void win32ShowCursor();
+		static void win32HideCursor();
+	};
+}

+ 3 - 4
CamelotCore/Source/CmApplication.cpp

@@ -3,7 +3,7 @@
 #include "CmRenderSystem.h"
 #include "CmRenderSystemManager.h"
 
-#include "CmWindowEventUtilities.h"
+#include "CmPlatform.h"
 #include "CmHardwareBufferManager.h"
 #include "CmRenderWindow.h"
 #include "CmViewport.h"
@@ -33,7 +33,6 @@
 #include "CmShader.h"
 #include "CmTechnique.h"
 #include "CmPass.h"
-#include "CmCursor.h"
 
 #include "CmRendererManager.h"
 
@@ -83,7 +82,7 @@ namespace CamelotFramework
 
 		loadPlugin(desc.input);
 
-		Cursor::setCursor(CursorType::Arrow);
+		Platform::setCursor(CursorType::Arrow);
 	}
 
 	void Application::runMainLoop()
@@ -131,7 +130,7 @@ namespace CamelotFramework
 
 	void Application::updateMessagePump()
 	{
-		WindowEventUtilities::messagePump();
+		Platform::messagePump();
 	}
 
 	void Application::frameRenderingFinishedCallback()

+ 4 - 4
CamelotCore/Source/CmOSInputHandler.cpp

@@ -1,5 +1,5 @@
 #include "CmOSInputHandler.h"
-#include "CmWindowEventUtilities.h"
+#include "CmPlatform.h"
 #include "CmMath.h"
 
 namespace CamelotFramework
@@ -7,9 +7,9 @@ namespace CamelotFramework
 	OSInputHandler::OSInputHandler()
 		:mMouseScroll(0.0f)
 	{
-		mCharInputConn = WindowEventUtilities::onCharInput.connect(boost::bind(&OSInputHandler::charInput, this, _1));
-		mMouseMovedConn = WindowEventUtilities::onMouseMoved.connect(boost::bind(&OSInputHandler::mouseMoved, this, _1));
-		mMouseWheelScrolledConn  = WindowEventUtilities::onMouseWheelScrolled.connect(boost::bind(&OSInputHandler::mouseWheelScrolled, this, _1));
+		mCharInputConn = Platform::onCharInput.connect(boost::bind(&OSInputHandler::charInput, this, _1));
+		mMouseMovedConn = Platform::onMouseMoved.connect(boost::bind(&OSInputHandler::mouseMoved, this, _1));
+		mMouseWheelScrolledConn  = Platform::onMouseWheelScrolled.connect(boost::bind(&OSInputHandler::mouseWheelScrolled, this, _1));
 	}
 
 	OSInputHandler::~OSInputHandler()

+ 185 - 0
CamelotCore/Source/CmPlatformWndProc.cpp

@@ -0,0 +1,185 @@
+#include "CmPlatformWndProc.h"
+#include "CmRenderWindow.h"
+#include "CmApplication.h"
+
+namespace CamelotFramework
+{
+	LRESULT CALLBACK PlatformWndProc::_win32WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+	{
+		if (uMsg == WM_CREATE)
+		{	// Store pointer to Win32Window in user data area
+			SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)(((LPCREATESTRUCT)lParam)->lpCreateParams));
+			return 0;
+		}
+
+		// look up window instance
+		// note: it is possible to get a WM_SIZE before WM_CREATE
+		RenderWindow* win = (RenderWindow*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+		if (!win)
+			return DefWindowProc(hWnd, uMsg, wParam, lParam);
+
+		switch( uMsg )
+		{
+		case WM_ACTIVATE:
+			{
+				bool active = (LOWORD(wParam) != WA_INACTIVE);
+				if( active )
+				{
+					win->setActive(true);
+
+					if(!win->hasFocus())
+						win->_windowFocusReceived();
+				}
+				else
+				{
+					if(win->hasFocus())
+						win->_windowFocusLost();
+				}
+
+				break;
+			}
+		case WM_SYSKEYDOWN:
+			switch( wParam )
+			{
+			case VK_CONTROL:
+			case VK_SHIFT:
+			case VK_MENU: //ALT
+				//return zero to bypass defProc and signal we processed the message
+				return 0;
+			}
+			break;
+		case WM_SYSKEYUP:
+			switch( wParam )
+			{
+			case VK_CONTROL:
+			case VK_SHIFT:
+			case VK_MENU: //ALT
+			case VK_F10:
+				//return zero to bypass defProc and signal we processed the message
+				return 0;
+			}
+			break;
+		case WM_SYSCHAR:
+			// return zero to bypass defProc and signal we processed the message, unless it's an ALT-space
+			if (wParam != VK_SPACE)
+				return 0;
+			break;
+		case WM_ENTERSIZEMOVE:
+			break;
+		case WM_EXITSIZEMOVE:
+			break;
+		case WM_MOVE:
+			win->_windowMovedOrResized();
+			break;
+		case WM_DISPLAYCHANGE:
+			win->_windowMovedOrResized();
+			break;
+		case WM_SIZE:
+			win->_windowMovedOrResized();
+			break;
+		case WM_SETCURSOR:
+			if(isCursorHidden())
+				win32HideCursor();
+			else
+				win32ShowCursor();
+			return true;
+		case WM_GETMINMAXINFO:
+			// Prevent the window from going smaller than some minimu size
+			((MINMAXINFO*)lParam)->ptMinTrackSize.x = 100;
+			((MINMAXINFO*)lParam)->ptMinTrackSize.y = 100;
+			break;
+		case WM_CLOSE:
+			{
+				// TODO - Only stop main loop if primary window is closed!!
+				gApplication().stopMainLoop();
+
+				return 0;
+			}
+		case WM_NCLBUTTONUP:
+			{
+				break;
+			}
+		case WM_LBUTTONUP:
+			{
+				break;
+			}
+		case WM_MOUSEMOVE:
+			{
+				POINT mousePos;
+
+				mousePos.x = GET_X_LPARAM(lParam);
+				mousePos.y = GET_Y_LPARAM(lParam); 
+
+				ClientToScreen(hWnd, &mousePos);
+
+				if(!onMouseMoved.empty())
+					onMouseMoved(Int2(mousePos.x, mousePos.y));
+
+				return true;
+			}
+		case WM_MOUSEWHEEL:
+			{
+				INT16 wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam);
+
+				float wheelDeltaFlt = wheelDelta / (float)WHEEL_DELTA;
+				if(!onMouseWheelScrolled.empty())
+					onMouseWheelScrolled(wheelDeltaFlt);
+
+				return true;
+			}
+		case WM_DEADCHAR:
+		case WM_CHAR:
+			{
+				switch (wParam) 
+				{ 
+				case VK_BACK:
+				case 0x0A:  // linefeed 
+				case 0x0D:  // carriage return 
+				case VK_ESCAPE:
+				case VK_TAB: 
+					break; 
+
+				default:    // displayable character 
+					{
+						UINT8 scanCode = (lParam >> 16) & 0xFF;
+
+						BYTE keyState[256];
+						HKL layout = GetKeyboardLayout(0);
+						if(GetKeyboardState(keyState) == 0)
+							return 0;
+
+						unsigned int vk = MapVirtualKeyEx(scanCode, MAPVK_VSC_TO_VK_EX, layout);
+						if(vk == 0)
+							return 0;
+
+						bool isDeadKey = (MapVirtualKeyEx(vk, MAPVK_VK_TO_CHAR, layout) & (1 << 31)) != 0;
+						if(isDeadKey)
+							return 0;
+
+						wchar_t buff[3] = {0};
+						int numChars = ToUnicodeEx(vk, scanCode, keyState, buff, 3, 0, layout);
+
+						// TODO - I am ignoring dead keys here - primarily because I haven't found a good way of retrieving non-combined dead key
+						// value. ToUnicodeEx and MapVirtualKeyEx only return precombined (i.e. spacing) versions, which can't be combined using other characters.
+						// I need non-combined version so I can use it with FoldString to apply to a certain character.
+
+						UINT32 finalChar = 0;
+						if(numChars == 1)
+							finalChar = buff[0];
+						else
+							return 0;
+
+						if(!onCharInput.empty())
+							onCharInput(finalChar);
+
+						return 0;
+					}
+				} 
+
+				break;
+			}
+		}
+
+		return DefWindowProc( hWnd, uMsg, wParam, lParam );
+	}
+}

+ 0 - 417
CamelotCore/Source/CmWindowEventUtilities.cpp

@@ -1,417 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#include "CmWindowEventUtilities.h"
-#include "CmRenderWindow.h"
-#include "CmApplication.h"
-#include "CmException.h"
-#include "CmCursor.h"
-#include "CmInput.h"
-
-#if CM_PLATFORM == CM_PLATFORM_LINUX
-#include <X11/Xlib.h>
-void GLXProc( CamelotFramework::RenderWindow *win, const XEvent &event );
-#endif
-
-using namespace CamelotFramework;
-
-WindowEventUtilities::Windows WindowEventUtilities::_msWindows;
-boost::signal<void(const Int2&)> WindowEventUtilities::onMouseMoved;
-boost::signal<void(float)> WindowEventUtilities::onMouseWheelScrolled;
-boost::signal<void(CamelotFramework::UINT32)> WindowEventUtilities::onCharInput;
-
-//--------------------------------------------------------------------------------//
-void WindowEventUtilities::messagePump()
-{
-#if CM_PLATFORM == CM_PLATFORM_WIN32
-	// Windows Message Loop (NULL means check all HWNDs belonging to this context)
-	MSG  msg;
-	while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
-	{
-		TranslateMessage( &msg );
-		DispatchMessage( &msg );
-	}
-#elif CM_PLATFORM == CM_PLATFORM_LINUX
-	//GLX Message Pump
-	Windows::iterator win = _msWindows.begin();
-	Windows::iterator end = _msWindows.end();
-
-	Display* xDisplay = 0; // same for all windows
-	
-	for (; win != end; win++)
-	{
-	    XID xid;
-	    XEvent event;
-
-	    if (!xDisplay)
-		(*win)->getCustomAttribute("XDISPLAY", &xDisplay);
-
-	    (*win)->getCustomAttribute("WINDOW", &xid);
-
-	    while (XCheckWindowEvent (xDisplay, xid, StructureNotifyMask | VisibilityChangeMask | FocusChangeMask, &event))
-	    {
-		GLXProc(*win, event);
-	    }
-
-	    // The ClientMessage event does not appear under any Event Mask
-	    while (XCheckTypedWindowEvent (xDisplay, xid, ClientMessage, &event))
-	    {
-		GLXProc(*win, event);
-	    }
-	}
-#elif CM_PLATFORM == CM_PLATFORM_APPLE && !defined __OBJC__ && !defined __LP64__
-	// OSX Message Pump
-	EventRef event = NULL;
-	EventTargetRef targetWindow;
-	targetWindow = GetEventDispatcherTarget();
-    
-    // If we are unable to get the target then we no longer care about events.
-    if( !targetWindow ) return;
-    
-    // Grab the next event, process it if it is a window event
-	if( ReceiveNextEvent( 0, NULL, kEventDurationNoWait, true, &event ) == noErr )
-	{
-        // Dispatch the event
-		SendEventToEventTarget( event, targetWindow );
-   		ReleaseEvent( event );
-	}
-#endif
-}
-//--------------------------------------------------------------------------------//
-void WindowEventUtilities::_addRenderWindow(RenderWindow* window)
-{
-	_msWindows.push_back(window);
-}
-
-//--------------------------------------------------------------------------------//
-void WindowEventUtilities::_removeRenderWindow(RenderWindow* window)
-{
-	Windows::iterator i = std::find(_msWindows.begin(), _msWindows.end(), window);
-	if( i != _msWindows.end() )
-		_msWindows.erase( i );
-}
-
-#if CM_PLATFORM == CM_PLATFORM_WIN32
-//--------------------------------------------------------------------------------//
-LRESULT CALLBACK WindowEventUtilities::_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-	if (uMsg == WM_CREATE)
-	{	// Store pointer to Win32Window in user data area
-		SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)(((LPCREATESTRUCT)lParam)->lpCreateParams));
-		return 0;
-	}
-
-	// look up window instance
-	// note: it is possible to get a WM_SIZE before WM_CREATE
-	RenderWindow* win = (RenderWindow*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
-	if (!win)
-		return DefWindowProc(hWnd, uMsg, wParam, lParam);
-
-	switch( uMsg )
-	{
-	case WM_ACTIVATE:
-	{
-        bool active = (LOWORD(wParam) != WA_INACTIVE);
-        if( active )
-        {
-		    win->setActive(true);
-
-			if(!win->hasFocus())
-				win->_windowFocusReceived();
-        }
-        else
-        {
-			if(win->hasFocus())
-				win->_windowFocusLost();
-        }
-
-		break;
-	}
-	case WM_SYSKEYDOWN:
-		switch( wParam )
-		{
-		case VK_CONTROL:
-		case VK_SHIFT:
-		case VK_MENU: //ALT
-			//return zero to bypass defProc and signal we processed the message
-			return 0;
-		}
-		break;
-	case WM_SYSKEYUP:
-		switch( wParam )
-		{
-		case VK_CONTROL:
-		case VK_SHIFT:
-		case VK_MENU: //ALT
-		case VK_F10:
-			//return zero to bypass defProc and signal we processed the message
-			return 0;
-		}
-		break;
-	case WM_SYSCHAR:
-		// return zero to bypass defProc and signal we processed the message, unless it's an ALT-space
-		if (wParam != VK_SPACE)
-			return 0;
-		break;
-	case WM_ENTERSIZEMOVE:
-		break;
-	case WM_EXITSIZEMOVE:
-		break;
-	case WM_MOVE:
-		win->_windowMovedOrResized();
-		break;
-	case WM_DISPLAYCHANGE:
-		win->_windowMovedOrResized();
-		break;
-	case WM_SIZE:
-		win->_windowMovedOrResized();
-		break;
-	case WM_SETCURSOR:
-		if(Cursor::isHidden())
-			Cursor::_win32HideCursor();
-		else
-			Cursor::_win32ShowCursor();
-		return true;
-	case WM_GETMINMAXINFO:
-		// Prevent the window from going smaller than some minimu size
-		((MINMAXINFO*)lParam)->ptMinTrackSize.x = 100;
-		((MINMAXINFO*)lParam)->ptMinTrackSize.y = 100;
-		break;
-	case WM_CLOSE:
-	{
-		// TODO - Only stop main loop if primary window is closed!!
-		gApplication().stopMainLoop();
-
-		return 0;
-	}
-	case WM_NCLBUTTONUP:
-		{
-			int b = 5;
-			break;
-		}
-	case WM_LBUTTONUP:
-		{
-			int a = 5;
-			break;
-		}
-	case WM_MOUSEMOVE:
-		{
-			POINT mousePos;
-			
-			mousePos.x = GET_X_LPARAM(lParam);
-			mousePos.y = GET_Y_LPARAM(lParam); 
-
-			ClientToScreen(hWnd, &mousePos);
-
-			if(!onMouseMoved.empty())
-				onMouseMoved(Int2(mousePos.x, mousePos.y));
-
-			return true;
-		}
-	case WM_MOUSEWHEEL:
-		{
-			INT16 wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam);
-
-			float wheelDeltaFlt = wheelDelta / (float)WHEEL_DELTA;
-			if(!onMouseWheelScrolled.empty())
-				onMouseWheelScrolled(wheelDeltaFlt);
-
-			return true;
-		}
-	case WM_DEADCHAR:
-	case WM_CHAR:
-		{
-			switch (wParam) 
-			{ 
-			case VK_BACK:
-			case 0x0A:  // linefeed 
-			case 0x0D:  // carriage return 
-			case VK_ESCAPE:
-			case VK_TAB: 
-				break; 
-
-			default:    // displayable character 
-				{
-					UINT8 scanCode = (lParam >> 16) & 0xFF;
-
-					BYTE keyState[256];
-					HKL layout = GetKeyboardLayout(0);
-					if(GetKeyboardState(keyState) == 0)
-						return 0;
-
-					unsigned int vk = MapVirtualKeyEx(scanCode, MAPVK_VSC_TO_VK_EX, layout);
-					if(vk == 0)
-						return 0;
-
-					bool isDeadKey = (MapVirtualKeyEx(vk, MAPVK_VK_TO_CHAR, layout) & (1 << 31)) != 0;
-					if(isDeadKey)
-						return 0;
-
-					wchar_t buff[3] = {0};
-					int numChars = ToUnicodeEx(vk, scanCode, keyState, buff, 3, 0, layout);
-
-					// TODO - I am ignoring dead keys here - primarily because I haven't found a good way of retrieving non-combined dead key
-					// value. ToUnicodeEx and MapVirtualKeyEx only return precombined (i.e. spacing) versions, which can't be combined using other characters.
-					// I need non-combined version so I can use it with FoldString to apply to a certain character.
-
-					UINT32 finalChar = 0;
-					if(numChars == 1)
-						finalChar = buff[0];
-					else
-						return 0;
-
-					if(!onCharInput.empty())
-						onCharInput(finalChar);
-
-					return 0;
-				}
-			} 
-
-			break;
-		}
-	}
-
-	return DefWindowProc( hWnd, uMsg, wParam, lParam );
-}
-#elif CM_PLATFORM == CM_PLATFORM_LINUX
-//--------------------------------------------------------------------------------//
-void GLXProc( RenderWindow *win, const XEvent &event )
-{
-	switch(event.type)
-	{
-	case ClientMessage:
-	{
-		::Atom atom;
-		win->getCustomAttribute("ATOM", &atom);
-		if(event.xclient.format == 32 && event.xclient.data.l[0] == (long)atom)
-		{	
-			//Window closed by window manager
-		}
-		break;
-	}
-	case DestroyNotify:
-	{
-		if (!win->isClosed())
-		{
-			// Window closed without window manager warning.
-		}
-		break;
-	}
-	case ConfigureNotify:
-	{    
-        // This could be slightly more efficient if windowMovedOrResized took arguments:
-		win->_windowMovedOrResized();
-
-		break;
-	}
-	case FocusIn:     // Gained keyboard focus
-	case FocusOut:    // Lost keyboard focus
-		break;
-	case MapNotify:   //Restored
-		win->setActive( true );
-		break;
-	case UnmapNotify: //Minimised
-		win->setActive( false );
-		win->setVisible( false );
-		break;
-	case VisibilityNotify:
-		switch(event.xvisibility.state)
-		{
-		case VisibilityUnobscured:
-			win->setActive( true );
-			win->setVisible( true );
-			break;
-		case VisibilityPartiallyObscured:
-			win->setActive( true );
-			win->setVisible( true );
-			break;
-		case VisibilityFullyObscured:
-			win->setActive( false );
-			win->setVisible( false );
-			break;
-		}
-		break;
-	default:
-		break;
-	} //End switch event.type
-}
-#elif CM_PLATFORM == CM_PLATFORM_APPLE && !defined __OBJC__ && !defined __LP64__
-//--------------------------------------------------------------------------------//
-OSStatus WindowEventUtilities::_CarbonWindowHandler(EventHandlerCallRef nextHandler, EventRef event, void* wnd)
-{
-    OSStatus status = noErr;
-    
-    // Only events from our window should make it here
-    // This ensures that our user data is our WindowRef
-    RenderWindow* curWindow = (RenderWindow*)wnd;
-    if(!curWindow) return eventNotHandledErr;
-    
-    // We only get called if a window event happens
-    UInt32 eventKind = GetEventKind( event );
-
-    switch( eventKind )
-    {
-        case kEventWindowActivated:
-            curWindow->setActive( true );
-            break;
-        case kEventWindowDeactivated:
-            break;
-        case kEventWindowShown:
-        case kEventWindowExpanded:
-            curWindow->setActive( true );
-            curWindow->setVisible( true );
-            break;
-        case kEventWindowHidden:
-        case kEventWindowCollapsed:
-            curWindow->setActive( false );
-            curWindow->setVisible( false );
-            break;            
-        case kEventWindowDragCompleted:
-            curWindow->_windowMovedOrResized();
-            break;
-        case kEventWindowBoundsChanged:
-            curWindow->_windowMovedOrResized();
-            break;
-		case kEventWindowClose:
-		{
-			bool close = true;
-			if (close)
-				// This will cause event handling to continue on to the standard handler, which calls
-				// DisposeWindow(), which leads to the 'kEventWindowClosed' event
-				status = eventNotHandledErr;
-			break;
-		}
-        case kEventWindowClosed:
-            break;
-        default:
-            status = eventNotHandledErr;
-            break;
-    }
-    
-    return status;
-}
-#endif

+ 51 - 21
CamelotCore/Source/Win32/CmCursorImpl.cpp → CamelotCore/Source/Win32/CmPlatformImpl.cpp

@@ -1,12 +1,21 @@
-#include "CmCursor.h"
+#include "CmPlatform.h"
 #include "CmRenderWindow.h"
-#include "CmWindowEventUtilities.h"
 #include "CmPixelUtil.h"
 #include "CmApplication.h"
+
+#define WIN32_LEAN_AND_MEAN
+#if !defined(NOMINMAX) && defined(_MSC_VER)
+#	define NOMINMAX // Required to stop windows.h messing up std::min
+#endif
 #include <windows.h>
+#include <windowsx.h>
 
 namespace CamelotFramework
 {
+	boost::signal<void(const Int2&)> Platform::onMouseMoved;
+	boost::signal<void(float)> Platform::onMouseWheelScrolled;
+	boost::signal<void(UINT32)> Platform::onCharInput;
+
 	struct NativeCursorData::Pimpl
 	{
 		HCURSOR cursor;
@@ -22,18 +31,29 @@ namespace CamelotFramework
 		cm_delete(data);
 	}
 
-	bool Cursor::mIsHidden = false;
-	NativeCursorData Cursor::mCursor;
-	bool Cursor::mUsingCustom = false;
+	bool Platform::mIsCursorHidden = false;
+	NativeCursorData Platform::mCursor;
+	bool Platform::mUsingCustomCursor = false;
 
-	void Cursor::setPosition(const Int2& screenPos)
+	void Platform::setCursorPosition(const Int2& screenPos)
 	{
 		SetCursorPos(screenPos.x, screenPos.y);
 	}
 
-	void Cursor::hide()
+	void Platform::captureMouse(const RenderWindow& window)
+	{
+		// POST A MESSAGE
+		//SetCapture()
+	}
+
+	void Platform::releaseMouseCapture()
+	{
+
+	}
+
+	void Platform::hideCursor()
 	{
-		mIsHidden = true;
+		mIsCursorHidden = true;
 
 		// ShowCursor(FALSE) doesn't work. Presumably because we're in the wrong thread, and using
 		// WM_SETCURSOR in message loop to hide the cursor is smarter solution anyway.
@@ -45,9 +65,9 @@ namespace CamelotFramework
 		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 	}
 
-	void Cursor::show()
+	void Platform::showCursor()
 	{
-		mIsHidden = false;
+		mIsCursorHidden = false;
 
 		// ShowCursor(FALSE) doesn't work. Presumably because we're in the wrong thread, and using
 		// WM_SETCURSOR in message loop to hide the cursor is smarter solution anyway.
@@ -59,7 +79,7 @@ namespace CamelotFramework
 		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 	}
 
-	void Cursor::clipToWindow(const RenderWindow& window)
+	void Platform::clipCursorToWindow(const RenderWindow& window)
 	{
 		HWND hwnd;
 		window.getCustomAttribute("WINDOW", &hwnd);
@@ -72,7 +92,7 @@ namespace CamelotFramework
 		}
 	}
 
-	void Cursor::clipToRect(const Rect& screenRect)
+	void Platform::clipCursorToRect(const Rect& screenRect)
 	{
 		RECT clipWindowRect;
 		clipWindowRect.left = screenRect.x;
@@ -83,18 +103,18 @@ namespace CamelotFramework
 		ClipCursor(&clipWindowRect);
 	}
 
-	void Cursor::clipDisable()
+	void Platform::clipCursorDisable()
 	{
 		ClipCursor(NULL);
 	}
 
-	void Cursor::setCursor(CursorType type)
+	void Platform::setCursor(CursorType type)
 	{
-		if(mUsingCustom)
+		if(mUsingCustomCursor)
 		{
 			SetCursor(0);
 			DestroyIcon(mCursor.data->cursor);
-			mUsingCustom = false;
+			mUsingCustomCursor = false;
 		}
 
 		switch(type)
@@ -140,15 +160,15 @@ namespace CamelotFramework
 	}
 
 	// TODO - Add support for animated custom cursor
-	void Cursor::setCustomCursor(PixelData& pixelData, const Int2& hotSpot)
+	void Platform::setCustomCursor(PixelData& pixelData, const Int2& hotSpot)
 	{
-		if(mUsingCustom)
+		if(mUsingCustomCursor)
 		{
 			SetCursor(0);
 			DestroyIcon(mCursor.data->cursor);
 		}
 
-		mUsingCustom = true;
+		mUsingCustomCursor = true;
 
 		BITMAPV5HEADER bi;
 
@@ -217,12 +237,22 @@ namespace CamelotFramework
 		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 	}
 
-	void Cursor::_win32ShowCursor()
+	void Platform::messagePump()
+	{
+		MSG  msg;
+		while(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
+		{
+			TranslateMessage(&msg);
+			DispatchMessage(&msg);
+		}
+	}
+
+	void Platform::win32ShowCursor()
 	{
 		SetCursor(mCursor.data->cursor);
 	}
 
-	void Cursor::_win32HideCursor()
+	void Platform::win32HideCursor()
 	{
 		SetCursor(nullptr);
 	}

+ 2 - 5
CamelotD3D11RenderSystem/Source/CmD3D11RenderWindow.cpp

@@ -1,6 +1,6 @@
 #include "CmD3D11RenderWindow.h"
 #include "CmCoreThread.h"
-#include "CmWindowEventUtilities.h"
+#include "CmPlatformWndProc.h"
 #include "CmD3D11RenderSystem.h"
 #include "CmD3D11Device.h"
 #include "CmD3D11RenderTexture.h"
@@ -228,7 +228,7 @@ namespace CamelotFramework
 
 			// Register the window class
 			// Allow 4 bytes of window data for D3D11RenderWindow pointer
-			WNDCLASS wc = { classStyle, WindowEventUtilities::_WndProc, 0, 0, hInst,
+			WNDCLASS wc = { classStyle, PlatformWndProc::_win32WndProc, 0, 0, hInst,
 				LoadIcon(0, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW),
 				(HBRUSH)GetStockObject(BLACK_BRUSH), 0, "D3D11Wnd" };	
 
@@ -239,8 +239,6 @@ namespace CamelotFramework
 			mIsExternal = false;
 			mHWnd = CreateWindowEx(dwStyleEx, "D3D11Wnd", mDesc.title.c_str(), dwStyle,
 				mLeft, mTop, mWidth, mHeight, parentHWnd, 0, hInst, this);
-
-			WindowEventUtilities::_addRenderWindow(this);
 		}
 		else
 		{
@@ -275,7 +273,6 @@ namespace CamelotFramework
 
 		if (mHWnd && !mIsExternal)
 		{
-			WindowEventUtilities::_removeRenderWindow(this);
 			DestroyWindow(mHWnd);
 		}
 

+ 2 - 5
CamelotD3D9Renderer/Source/CmD3D9RenderWindow.cpp

@@ -33,7 +33,7 @@ THE SOFTWARE.
 #include "CmD3D9RenderSystem.h"
 #include "CmRenderSystem.h"
 #include "CmBitwise.h"
-#include "CmWindowEventUtilities.h"
+#include "CmPlatformWndProc.h"
 #include "CmD3D9DeviceManager.h"
 
 namespace CamelotFramework
@@ -225,7 +225,7 @@ namespace CamelotFramework
 
 			// Register the window class
 			// NB allow 4 bytes of window data for D3D9RenderWindow pointer
-			WNDCLASS wc = { 0, WindowEventUtilities::_WndProc, 0, 0, hInst,
+			WNDCLASS wc = { 0, PlatformWndProc::_win32WndProc, 0, 0, hInst,
 				LoadIcon(0, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW),
 				(HBRUSH)GetStockObject(BLACK_BRUSH), 0, "D3D9Wnd" };
 			RegisterClass(&wc);
@@ -236,8 +236,6 @@ namespace CamelotFramework
 			mHWnd = CreateWindowEx(dwStyleEx, "D3D9Wnd", mDesc.title.c_str(), dwStyle,
 				mLeft, mTop, winWidth, winHeight, parentHWnd, 0, hInst, this);
 			mStyle = dwStyle;
-
-			WindowEventUtilities::_addRenderWindow(this);
 		}
 		else
 		{
@@ -279,7 +277,6 @@ namespace CamelotFramework
 
 		if (mHWnd && !mIsExternal)
 		{
-			WindowEventUtilities::_removeRenderWindow(this);
 			DestroyWindow(mHWnd);
 		}
 

+ 3 - 7
CamelotGLRenderer/Source/CmWin32Window.cpp

@@ -36,7 +36,7 @@ THE SOFTWARE.
 #include "CmException.h"
 #include "CmWin32GLSupport.h"
 #include "CmWin32Context.h"
-#include "CmWindowEventUtilities.h"
+#include "CmPlatformWndProc.h"
 #include "CmGLPixelFormat.h"
 
 namespace CamelotFramework 
@@ -259,7 +259,7 @@ namespace CamelotFramework
 			}
 
 			// register class and create window
-			WNDCLASS wc = { CS_OWNDC, WindowEventUtilities::_WndProc, 0, 0, hInst,
+			WNDCLASS wc = { CS_OWNDC, PlatformWndProc::_win32WndProc, 0, 0, hInst,
 				LoadIcon(NULL, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW),
 				(HBRUSH)GetStockObject(BLACK_BRUSH), NULL, "GLWindow" };
 			RegisterClass(&wc);
@@ -295,9 +295,7 @@ namespace CamelotFramework
 
 			// Pass pointer to self as WM_CREATE parameter
 			mHWnd = CreateWindowEx(dwStyleEx, "GLWindow", mDesc.title.c_str(),
-				dwStyle, mLeft, mTop, mWidth, mHeight, parent, 0, hInst, this);
-
-			WindowEventUtilities::_addRenderWindow(this);			
+				dwStyle, mLeft, mTop, mWidth, mHeight, parent, 0, hInst, this);		
 		}
 
 		RECT rc;
@@ -397,8 +395,6 @@ namespace CamelotFramework
 		}
 		if (!mIsExternal)
 		{
-			WindowEventUtilities::_removeRenderWindow(this);
-
 			if (mIsFullScreen)
 				ChangeDisplaySettingsEx(mDeviceName, NULL, NULL, 0, NULL);
 			DestroyWindow(mHWnd);

+ 1 - 1
CamelotUtility/CamelotUtility.vcxproj

@@ -297,7 +297,7 @@
     <ClInclude Include="Include\CmMatrix3.h" />
     <ClInclude Include="Include\CmMatrix4.h" />
     <ClInclude Include="Include\CmPlane.h" />
-    <ClInclude Include="Include\CmPlatform.h" />
+    <ClInclude Include="Include\CmPlatformDefines.h" />
     <ClInclude Include="Include\CmPrerequisitesUtil.h" />
     <ClInclude Include="Include\CmQuaternion.h" />
     <ClInclude Include="Include\CmRay.h" />

+ 3 - 3
CamelotUtility/CamelotUtility.vcxproj.filters

@@ -54,9 +54,6 @@
     <ClInclude Include="Include\CmTypes.h">
       <Filter>Header Files\Prerequisites</Filter>
     </ClInclude>
-    <ClInclude Include="Include\CmPlatform.h">
-      <Filter>Header Files\Prerequisites</Filter>
-    </ClInclude>
     <ClInclude Include="Include\CmStdHeaders.h">
       <Filter>Header Files\Prerequisites</Filter>
     </ClInclude>
@@ -219,6 +216,9 @@
     <ClInclude Include="Include\CmFRect.h">
       <Filter>Header Files\Math</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmPlatformDefines.h">
+      <Filter>Header Files\Prerequisites</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmMath.cpp">

+ 0 - 0
CamelotUtility/Include/CmPlatform.h → CamelotUtility/Include/CmPlatformDefines.h


+ 1 - 1
CamelotUtility/Include/CmPrerequisitesUtil.h

@@ -33,7 +33,7 @@ THE SOFTWARE
 #define CM_THREAD_SUPPORT 2
 
 // Platform-specific stuff
-#include "CmPlatform.h"
+#include "CmPlatformDefines.h"
 
 #if CM_COMPILER == CM_COMPILER_MSVC
 

+ 1 - 1
CamelotUtility/Include/CmTypes.h

@@ -1,6 +1,6 @@
 #pragma once
 
-#include "CmPlatform.h"
+#include "CmPlatformDefines.h"
 
 namespace CamelotFramework
 {