From 622a0d6cb27c558ce6ed0185a66bcbe3100d0f86 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 31 May 2010 13:15:36 +0200 Subject: [PATCH] Fixed: #951 Use nlWindow instead of void* for window ID --- code/nel/include/nel/3d/driver.h | 2 +- code/nel/include/nel/3d/driver_user.h | 2 +- code/nel/include/nel/3d/u_driver.h | 2 +- code/nel/include/nel/misc/system_utils.h | 4 ++-- code/nel/src/3d/driver.cpp | 2 +- .../src/3d/driver/direct3d/driver_direct3d.cpp | 14 +++++++------- .../nel/src/3d/driver/direct3d/driver_direct3d.h | 2 +- code/nel/src/3d/driver/opengl/driver_opengl.cpp | 2 +- code/nel/src/3d/driver/opengl/driver_opengl.h | 6 +++--- code/nel/src/3d/driver_user.cpp | 2 +- code/nel/src/3d/font_generator.cpp | 2 +- code/nel/src/misc/system_utils.cpp | 16 ++++++++-------- code/ryzom/client/src/bg_downloader_access.cpp | 2 +- code/ryzom/client/src/init.cpp | 6 +++--- code/ryzom/client/src/input.cpp | 6 +++--- .../src/interface_v3/action_handler_help.cpp | 2 +- .../client/src/interface_v3/custom_mouse.cpp | 6 +++--- .../ryzom/client/src/interface_v3/lua_helper.cpp | 2 +- .../client/src/interface_v3/music_player.cpp | 4 ++-- code/ryzom/client/src/login.cpp | 2 +- 20 files changed, 43 insertions(+), 43 deletions(-) diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 6dcb38e75..21ca5b079 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -201,7 +201,7 @@ public: // Return is the associated window information. (Implementation dependent) // Must be a HWND for Windows (WIN32). - virtual void *getDisplay() =0; + virtual nlWindow getDisplay() =0; /** * Setup monitor color properties. diff --git a/code/nel/include/nel/3d/driver_user.h b/code/nel/include/nel/3d/driver_user.h index 795afa19c..7070b62f8 100644 --- a/code/nel/include/nel/3d/driver_user.h +++ b/code/nel/include/nel/3d/driver_user.h @@ -162,7 +162,7 @@ public: /// Return true if driver is still active. Return false else. If he user close the window, must return false. virtual bool isActive(); /// Return an OS dependent window handle. Under Win32, it is a HWND. - virtual void *getDisplay (); + virtual nlWindow getDisplay (); // @} diff --git a/code/nel/include/nel/3d/u_driver.h b/code/nel/include/nel/3d/u_driver.h index 46472e045..02342bf54 100644 --- a/code/nel/include/nel/3d/u_driver.h +++ b/code/nel/include/nel/3d/u_driver.h @@ -221,7 +221,7 @@ public: virtual bool isActive()=0; /// Return an OS dependent window handle. Under Win32, it is a HWND. - virtual void *getDisplay () = 0; + virtual nlWindow getDisplay () = 0; // @} diff --git a/code/nel/include/nel/misc/system_utils.h b/code/nel/include/nel/misc/system_utils.h index 4c4dcfe6d..4cd13a7ac 100644 --- a/code/nel/include/nel/misc/system_utils.h +++ b/code/nel/include/nel/misc/system_utils.h @@ -30,7 +30,7 @@ namespace NLMISC */ class CSystemUtils { - static void *s_window; + static nlWindow s_window; public: /// Initialize data which needs it before using them. @@ -40,7 +40,7 @@ public: static bool uninit(); /// Set the window which will be used by some functions. - static void setWindow(void *window); + static void setWindow(nlWindow window); /// Create/update a progress bar with an appearance depending on system. static bool updateProgressBar(uint value, uint total); diff --git a/code/nel/src/3d/driver.cpp b/code/nel/src/3d/driver.cpp index 21afd042b..af6ad6c07 100644 --- a/code/nel/src/3d/driver.cpp +++ b/code/nel/src/3d/driver.cpp @@ -34,7 +34,7 @@ namespace NL3D { // *************************************************************************** -const uint32 IDriver::InterfaceVersion = 0x64; // Added nlWindow patch. +const uint32 IDriver::InterfaceVersion = 0x65; // Added nlWindow patch. // *************************************************************************** IDriver::IDriver() : _SyncTexDrvInfos( "IDriver::_SyncTexDrvInfos" ) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 49b350d00..161a67e76 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1323,7 +1323,7 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r } // Create a window - _HWnd = (HWND)wnd; + _HWnd = wnd; // Reset window state _Maximized = false; @@ -1440,19 +1440,19 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r } // Create the D3D device - HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, (HWND)_HWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE, ¶meters, &_DeviceInterface); + HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE, ¶meters, &_DeviceInterface); if (result != D3D_OK) { nlwarning ("Can't create device hr:0x%x adap:0x%x rast:0x%x", result, adapter, _Rasterizer); // Create the D3D device without puredevice - HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, (HWND)_HWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface); + HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface); if (result != D3D_OK) { nlwarning ("Can't create device without puredevice hr:0x%x adap:0x%x rast:0x%x", result, adapter, _Rasterizer); // Create the D3D device without puredevice and hardware - HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, (HWND)_HWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface); + HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface); if (result != D3D_OK) { nlwarning ("Can't create device without puredevice and hardware hr:0x%x adap:0x%x rast:0x%x", result, adapter, _Rasterizer); @@ -1462,7 +1462,7 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r } } -// _D3D->CreateDevice (adapter, _Rasterizer, (HWND)_HWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface); +// _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface); // Check some caps D3DCAPS9 caps; @@ -1794,9 +1794,9 @@ bool CDriverD3D::isActive () // *************************************************************************** -void* CDriverD3D::getDisplay() +nlWindow CDriverD3D::getDisplay() { - return (void*)_HWnd; + return _HWnd; } // *************************************************************************** diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.h b/code/nel/src/3d/driver/direct3d/driver_direct3d.h index 00cecd1df..1811b92ca 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -749,7 +749,7 @@ public: virtual bool initVertexBufferHard(uint agpMem, uint vramMem); // Windows interface - virtual void* getDisplay(); + virtual nlWindow getDisplay(); virtual emptyProc getWindowProc(); virtual NLMISC::IEventEmitter *getEventEmitter(); virtual void getWindowSize (uint32 &width, uint32 &height); diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.cpp b/code/nel/src/3d/driver/opengl/driver_opengl.cpp index fbf954ded..c69b52fbe 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -870,7 +870,7 @@ bool CDriverGL::setDisplay(nlWindow wnd, const GfxMode &mode, bool show, bool re _FullScreen= false; if (wnd) { - _hWnd=(HWND)wnd; + _hWnd=wnd; _DestroyWindow=false; } else diff --git a/code/nel/src/3d/driver/opengl/driver_opengl.h b/code/nel/src/3d/driver/opengl/driver_opengl.h index b87467cd4..9365d57f9 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl.h @@ -299,12 +299,12 @@ public: /// Show or hide the NeL window virtual void showWindow(bool show); - virtual void* getDisplay() + virtual nlWindow getDisplay() { #ifdef NL_OS_WINDOWS - return (void*)_hWnd; + return _hWnd; #else // NL_OS_WINDOWS - return NULL; + return win; #endif // NL_OS_WINDOWS } diff --git a/code/nel/src/3d/driver_user.cpp b/code/nel/src/3d/driver_user.cpp index bd22df612..89a1d0197 100644 --- a/code/nel/src/3d/driver_user.cpp +++ b/code/nel/src/3d/driver_user.cpp @@ -386,7 +386,7 @@ bool CDriverUser::isActive() // *************************************************************************** -void *CDriverUser::getDisplay () +nlWindow CDriverUser::getDisplay () { NL3D_HAUTO_UI_DRIVER; diff --git a/code/nel/src/3d/font_generator.cpp b/code/nel/src/3d/font_generator.cpp index 5c79686cd..73f05a6f4 100644 --- a/code/nel/src/3d/font_generator.cpp +++ b/code/nel/src/3d/font_generator.cpp @@ -287,7 +287,7 @@ int Height = 100; CFontGenerator::CFontGenerator (const std::string &fontFileName, const std::string &fontExFileName) { -// HWND win=(HWND)winHack; +// HWND win=winHack; // WindowHandle = win; // Format = format; // RECT rect; diff --git a/code/nel/src/misc/system_utils.cpp b/code/nel/src/misc/system_utils.cpp index d1e426a7a..544adb7c4 100644 --- a/code/nel/src/misc/system_utils.cpp +++ b/code/nel/src/misc/system_utils.cpp @@ -36,7 +36,7 @@ static const uint32 KeyMaxLength = 1024; namespace NLMISC { -void *CSystemUtils::s_window = NULL; +nlWindow CSystemUtils::s_window = EmptyWindow; bool CSystemUtils::init() { @@ -59,7 +59,7 @@ bool CSystemUtils::uninit() return true; } -void CSystemUtils::setWindow(void *window) +void CSystemUtils::setWindow(nlWindow window) { s_window = window; } @@ -83,12 +83,12 @@ bool CSystemUtils::updateProgressBar(uint value, uint total) if (total) { // update the taskbar progress - hr = pTaskbarList->SetProgressValue((HWND)s_window, (ULONGLONG)value, (ULONGLONG)total); + hr = pTaskbarList->SetProgressValue(s_window, (ULONGLONG)value, (ULONGLONG)total); } else { // don't update anymore the progress - hr = pTaskbarList->SetProgressState((HWND)s_window, value == 0 ? TBPF_INDETERMINATE:TBPF_NOPROGRESS); + hr = pTaskbarList->SetProgressState(s_window, value == 0 ? TBPF_INDETERMINATE:TBPF_NOPROGRESS); } // release the interface @@ -368,13 +368,13 @@ bool CSystemUtils::isSystemCursorInClientArea() return false; } HWND wnd = WindowFromPoint(cursPos); - if (wnd != (HWND)s_window) + if (wnd != s_window) { return false; // not the same window } // want that the mouse be in the client area RECT clientRect; - if (!GetClientRect((HWND)s_window, &clientRect)) + if (!GetClientRect(s_window, &clientRect)) { return false; } @@ -383,11 +383,11 @@ bool CSystemUtils::isSystemCursorInClientArea() tl.y = clientRect.top; br.x = clientRect.right; br.y = clientRect.bottom; - if (!ClientToScreen((HWND)s_window, &tl)) + if (!ClientToScreen(s_window, &tl)) { return false; } - if (!ClientToScreen((HWND)s_window, &br)) + if (!ClientToScreen(s_window, &br)) { return false; } diff --git a/code/ryzom/client/src/bg_downloader_access.cpp b/code/ryzom/client/src/bg_downloader_access.cpp index 256eadf91..e6bdfaf93 100644 --- a/code/ryzom/client/src/bg_downloader_access.cpp +++ b/code/ryzom/client/src/bg_downloader_access.cpp @@ -472,7 +472,7 @@ void CBGDownloaderAccess::CDownloadCoTask::restartDownloader() } *(uint32 *) Parent->_RyzomInstPIDPtr = (uint32) GetCurrentProcessId(); - HWND hWnd = (HWND)Driver->getDisplay (); + HWND hWnd = Driver->getDisplay(); // for safety, stop any running downloader if (isDownloaderProcessRunning()) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 800cdf9a1..e5c59324d 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -283,7 +283,7 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA { if (Driver) { - HWND wnd = (HWND) Driver->getDisplay(); + HWND wnd = Driver->getDisplay(); ShowWindow(wnd, SW_MINIMIZE); } browseFAQ(ClientCfg.ConfigFile); @@ -461,7 +461,7 @@ static string crashCallback() Driver->getCurrentScreenMode(mode); if (!mode.Windowed) { - HWND wnd = (HWND) Driver->getDisplay(); + HWND wnd = Driver->getDisplay(); ShowWindow(wnd, SW_MINIMIZE); } } @@ -1227,7 +1227,7 @@ void postlogInit() // tmp fix : it seems that, at this point, if the bg downloader window has focus and // not the Ryzom one, then sound init fails #ifdef NL_OS_WINDOWS - HWND hWnd = (HWND)Driver->getDisplay (); + HWND hWnd = Driver->getDisplay (); nlassert (hWnd); ShowWindow(hWnd, SW_RESTORE); SetForegroundWindow(hWnd); diff --git a/code/ryzom/client/src/input.cpp b/code/ryzom/client/src/input.cpp index 404fcd323..44488eb0f 100644 --- a/code/ryzom/client/src/input.cpp +++ b/code/ryzom/client/src/input.cpp @@ -369,7 +369,7 @@ void CaptureSystemCursor() { if (IsSystemCursorCaptured()) return; #ifdef NL_OS_WINDOWS - HWND drvWnd = (HWND) Driver->getDisplay(); + HWND drvWnd = Driver->getDisplay(); if (!drvWnd) return; SetCapture(drvWnd); #else @@ -402,7 +402,7 @@ bool IsSystemCursorCaptured() { if (!Driver) return false; #ifdef NL_OS_WINDOWS - return GetCapture() == (HWND) Driver->getDisplay(); + return GetCapture() == Driver->getDisplay(); #else return MouseCapture; #endif @@ -445,7 +445,7 @@ bool IsSystemCursorInClientArea() { if (!Driver) return false; #ifdef NL_OS_WINDOWS - HWND drvWnd = (HWND) Driver->getDisplay(); + HWND drvWnd = Driver->getDisplay(); if (!drvWnd) return false; UDriver::CMode videoMode; Driver->getCurrentScreenMode(videoMode); diff --git a/code/ryzom/client/src/interface_v3/action_handler_help.cpp b/code/ryzom/client/src/interface_v3/action_handler_help.cpp index 5b26013ee..2645135de 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_help.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_help.cpp @@ -3725,7 +3725,7 @@ public: #ifdef NL_OS_WINDOWS if (Driver) { - HWND wnd = (HWND) Driver->getDisplay(); + HWND wnd = Driver->getDisplay(); ShowWindow(wnd, SW_MINIMIZE); } #endif diff --git a/code/ryzom/client/src/interface_v3/custom_mouse.cpp b/code/ryzom/client/src/interface_v3/custom_mouse.cpp index 22ec52a5a..183c7e761 100644 --- a/code/ryzom/client/src/interface_v3/custom_mouse.cpp +++ b/code/ryzom/client/src/interface_v3/custom_mouse.cpp @@ -284,7 +284,7 @@ void CCustomMouse::release() { if (!isAlphaBlendedCursorSupported()) return; nlassert(Driver); - HWND drvWnd = (HWND) Driver->getDisplay(); + HWND drvWnd = Driver->getDisplay(); if (drvWnd) { SetClassLongPtr(drvWnd, GCLP_HCURSOR, 0); @@ -353,7 +353,7 @@ void CCustomMouse::setCursor(const std::string &name, NLMISC::CRGBA col, uint8 r if (CInputHandlerManager::getInstance()->hasFocus()) { ::SetCursor(cursorHandle); - HWND drvWnd = (HWND) Driver->getDisplay(); + HWND drvWnd = Driver->getDisplay(); if (drvWnd) { SetClassLongPtr(drvWnd, GCLP_HCURSOR, (LONG_PTR) cursorHandle); // set default mouse icon to the last one @@ -449,7 +449,7 @@ void CCustomMouse::setSystemArrow() { ::SetCursor(arrow); } - HWND drvWnd = (HWND) Driver->getDisplay(); + HWND drvWnd = Driver->getDisplay(); if (drvWnd) { SetClassLongPtr(drvWnd, GCLP_HCURSOR, (LONG_PTR) arrow); // set default mouse icon to the last one diff --git a/code/ryzom/client/src/interface_v3/lua_helper.cpp b/code/ryzom/client/src/interface_v3/lua_helper.cpp index 81039010e..80a275523 100644 --- a/code/ryzom/client/src/interface_v3/lua_helper.cpp +++ b/code/ryzom/client/src/interface_v3/lua_helper.cpp @@ -150,7 +150,7 @@ CLuaState::CLuaState() TGetLuaIDEInterface getter = (TGetLuaIDEInterface) GetProcAddress(LuaDebuggerModule, "GetLuaIDEInterface"); nlassert(getter); LuaDebuggerIDE = getter(); - LuaDebuggerIDE->prepareDebug("save\\___external_debug.lpr", l_realloc_func, l_free_func, (HWND)Driver->getDisplay()); + LuaDebuggerIDE->prepareDebug("save\\___external_debug.lpr", l_realloc_func, l_free_func, Driver->getDisplay()); _State = LuaDebuggerIDE->getLuaState(); } } diff --git a/code/ryzom/client/src/interface_v3/music_player.cpp b/code/ryzom/client/src/interface_v3/music_player.cpp index 029decf1c..e74f6d2b9 100644 --- a/code/ryzom/client/src/interface_v3/music_player.cpp +++ b/code/ryzom/client/src/interface_v3/music_player.cpp @@ -109,7 +109,7 @@ void CMusicPlayer::previous () { // Point the previous song if (_CurrentSong == 0) - _CurrentSong = _Songs.size()-1; + _CurrentSong = (uint)_Songs.size()-1; else _CurrentSong--; @@ -228,7 +228,7 @@ public: OPENFILENAME ofn; memset (&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = Driver?(HWND)Driver->getDisplay ():NULL; + ofn.hwndOwner = Driver ? Driver->getDisplay():NULL; ofn.hInstance = HInstance; ofn.lpstrFilter = szFilter; ofn.nFilterIndex = 0; diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index b07fbd061..9f8f5c3bf 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -425,7 +425,7 @@ void loginMainLoop() #ifdef NL_OS_WINDOWS { // Get the window - HWND hWnd = (HWND)Driver->getDisplay (); + HWND hWnd = Driver->getDisplay(); nlassert (hWnd); // Show the window, unless it has been minimized, in // which case we don't pop it unexpectedly