diff options
Diffstat (limited to 'indra/llwindow')
-rwxr-xr-x | indra/llwindow/CMakeLists.txt | 2 | ||||
-rwxr-xr-x | indra/llwindow/llcursortypes.cpp | 91 | ||||
-rwxr-xr-x | indra/llwindow/llcursortypes.h | 79 | ||||
-rwxr-xr-x | indra/llwindow/lldragdropwin32.cpp | 10 | ||||
-rwxr-xr-x | indra/llwindow/lldragdropwin32.h | 4 | ||||
-rwxr-xr-x | indra/llwindow/lldxhardware.cpp | 210 | ||||
-rwxr-xr-x | indra/llwindow/llkeyboard.cpp | 8 | ||||
-rwxr-xr-x | indra/llwindow/llkeyboard.h | 3 | ||||
-rwxr-xr-x | indra/llwindow/llkeyboardwin32.cpp | 7 | ||||
-rwxr-xr-x | indra/llwindow/llmousehandler.cpp | 4 | ||||
-rw-r--r-- | indra/llwindow/llopenglview-objc.h | 4 | ||||
-rw-r--r-- | indra/llwindow/llopenglview-objc.mm | 219 | ||||
-rwxr-xr-x | indra/llwindow/llwindow.cpp | 13 | ||||
-rwxr-xr-x | indra/llwindow/llwindow.h | 3 | ||||
-rwxr-xr-x | indra/llwindow/llwindowmacosx-objc.h | 1 | ||||
-rwxr-xr-x | indra/llwindow/llwindowmacosx-objc.mm | 7 | ||||
-rwxr-xr-x | indra/llwindow/llwindowmacosx.cpp | 68 | ||||
-rwxr-xr-x | indra/llwindow/llwindowmacosx.h | 5 | ||||
-rwxr-xr-x | indra/llwindow/llwindowmesaheadless.cpp | 4 | ||||
-rwxr-xr-x | indra/llwindow/llwindowsdl.cpp | 230 | ||||
-rwxr-xr-x | indra/llwindow/llwindowwin32.cpp | 151 | ||||
-rwxr-xr-x | indra/llwindow/llwindowwin32.h | 4 |
22 files changed, 811 insertions, 316 deletions
diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index aec6d7af4a..0743fd899f 100755 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -38,6 +38,7 @@ include_directories(SYSTEM ) set(llwindow_SOURCE_FILES + llcursortypes.cpp llkeyboard.cpp llkeyboardheadless.cpp llwindowheadless.cpp @@ -48,6 +49,7 @@ set(llwindow_SOURCE_FILES set(llwindow_HEADER_FILES CMakeLists.txt + llcursortypes.h llkeyboard.h llkeyboardheadless.h llwindowheadless.h diff --git a/indra/llwindow/llcursortypes.cpp b/indra/llwindow/llcursortypes.cpp new file mode 100755 index 0000000000..ec60097195 --- /dev/null +++ b/indra/llwindow/llcursortypes.cpp @@ -0,0 +1,91 @@ +/** + * @file llcursortypes.cpp + * @brief Cursor types and lookup of types from a string + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llcursortypes.h" + +ECursorType getCursorFromString(const std::string& cursor_string) +{ + static std::map<std::string,U32> cursor_string_table; + if (cursor_string_table.empty()) + { + cursor_string_table["UI_CURSOR_ARROW"] = UI_CURSOR_ARROW; + cursor_string_table["UI_CURSOR_WAIT"] = UI_CURSOR_WAIT; + cursor_string_table["UI_CURSOR_HAND"] = UI_CURSOR_HAND; + cursor_string_table["UI_CURSOR_IBEAM"] = UI_CURSOR_IBEAM; + cursor_string_table["UI_CURSOR_CROSS"] = UI_CURSOR_CROSS; + cursor_string_table["UI_CURSOR_SIZENWSE"] = UI_CURSOR_SIZENWSE; + cursor_string_table["UI_CURSOR_SIZENESW"] = UI_CURSOR_SIZENESW; + cursor_string_table["UI_CURSOR_SIZEWE"] = UI_CURSOR_SIZEWE; + cursor_string_table["UI_CURSOR_SIZENS"] = UI_CURSOR_SIZENS; + cursor_string_table["UI_CURSOR_NO"] = UI_CURSOR_NO; + cursor_string_table["UI_CURSOR_WORKING"] = UI_CURSOR_WORKING; + cursor_string_table["UI_CURSOR_TOOLGRAB"] = UI_CURSOR_TOOLGRAB; + cursor_string_table["UI_CURSOR_TOOLLAND"] = UI_CURSOR_TOOLLAND; + cursor_string_table["UI_CURSOR_TOOLFOCUS"] = UI_CURSOR_TOOLFOCUS; + cursor_string_table["UI_CURSOR_TOOLCREATE"] = UI_CURSOR_TOOLCREATE; + cursor_string_table["UI_CURSOR_ARROWDRAG"] = UI_CURSOR_ARROWDRAG; + cursor_string_table["UI_CURSOR_ARROWCOPY"] = UI_CURSOR_ARROWCOPY; + cursor_string_table["UI_CURSOR_ARROWDRAGMULTI"] = UI_CURSOR_ARROWDRAGMULTI; + cursor_string_table["UI_CURSOR_ARROWCOPYMULTI"] = UI_CURSOR_ARROWCOPYMULTI; + cursor_string_table["UI_CURSOR_NOLOCKED"] = UI_CURSOR_NOLOCKED; + cursor_string_table["UI_CURSOR_ARROWLOCKED"] = UI_CURSOR_ARROWLOCKED; + cursor_string_table["UI_CURSOR_GRABLOCKED"] = UI_CURSOR_GRABLOCKED; + cursor_string_table["UI_CURSOR_TOOLTRANSLATE"] = UI_CURSOR_TOOLTRANSLATE; + cursor_string_table["UI_CURSOR_TOOLROTATE"] = UI_CURSOR_TOOLROTATE; + cursor_string_table["UI_CURSOR_TOOLSCALE"] = UI_CURSOR_TOOLSCALE; + cursor_string_table["UI_CURSOR_TOOLCAMERA"] = UI_CURSOR_TOOLCAMERA; + cursor_string_table["UI_CURSOR_TOOLPAN"] = UI_CURSOR_TOOLPAN; + cursor_string_table["UI_CURSOR_TOOLZOOMIN"] = UI_CURSOR_TOOLZOOMIN; + cursor_string_table["UI_CURSOR_TOOLPICKOBJECT3"] = UI_CURSOR_TOOLPICKOBJECT3; + cursor_string_table["UI_CURSOR_TOOLPLAY"] = UI_CURSOR_TOOLPLAY; + cursor_string_table["UI_CURSOR_TOOLPAUSE"] = UI_CURSOR_TOOLPAUSE; + cursor_string_table["UI_CURSOR_TOOLMEDIAOPEN"] = UI_CURSOR_TOOLMEDIAOPEN; + cursor_string_table["UI_CURSOR_PIPETTE"] = UI_CURSOR_PIPETTE; + cursor_string_table["UI_CURSOR_TOOLSIT"] = UI_CURSOR_TOOLSIT; + cursor_string_table["UI_CURSOR_TOOLBUY"] = UI_CURSOR_TOOLBUY; + cursor_string_table["UI_CURSOR_TOOLOPEN"] = UI_CURSOR_TOOLOPEN; + cursor_string_table["UI_CURSOR_TOOLPATHFINDING"] = UI_CURSOR_TOOLPATHFINDING; + cursor_string_table["UI_CURSOR_TOOLPATHFINDINGPATHSTART"] = UI_CURSOR_TOOLPATHFINDING_PATH_START; + cursor_string_table["UI_CURSOR_TOOLPATHFINDINGPATHSTARTADD"] = UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD; + cursor_string_table["UI_CURSOR_TOOLPATHFINDINGPATHEND"] = UI_CURSOR_TOOLPATHFINDING_PATH_END; + cursor_string_table["UI_CURSOR_TOOLPATHFINDINGPATHENDADD"] = UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD; + cursor_string_table["UI_CURSOR_TOOLNO"] = UI_CURSOR_TOOLNO; + } + + std::map<std::string,U32>::const_iterator iter = cursor_string_table.find(cursor_string); + + if (iter != cursor_string_table.end()) + { + return (ECursorType)iter->second; + } + + return UI_CURSOR_ARROW; +} + + + diff --git a/indra/llwindow/llcursortypes.h b/indra/llwindow/llcursortypes.h new file mode 100755 index 0000000000..cb6d6636a0 --- /dev/null +++ b/indra/llwindow/llcursortypes.h @@ -0,0 +1,79 @@ +/** + * @file llcursortypes.h + * @brief Cursor types + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLCURSORTYPES_H +#define LL_LLCURSORTYPES_H + +// If you add types here, add them in LLCursor::getCursorFromString +enum ECursorType { + UI_CURSOR_ARROW, + UI_CURSOR_WAIT, + UI_CURSOR_HAND, + UI_CURSOR_IBEAM, + UI_CURSOR_CROSS, + UI_CURSOR_SIZENWSE, + UI_CURSOR_SIZENESW, + UI_CURSOR_SIZEWE, + UI_CURSOR_SIZENS, + UI_CURSOR_NO, + UI_CURSOR_WORKING, + UI_CURSOR_TOOLGRAB, + UI_CURSOR_TOOLLAND, + UI_CURSOR_TOOLFOCUS, + UI_CURSOR_TOOLCREATE, + UI_CURSOR_ARROWDRAG, + UI_CURSOR_ARROWCOPY, // drag with copy + UI_CURSOR_ARROWDRAGMULTI, + UI_CURSOR_ARROWCOPYMULTI, // drag with copy + UI_CURSOR_NOLOCKED, + UI_CURSOR_ARROWLOCKED, + UI_CURSOR_GRABLOCKED, + UI_CURSOR_TOOLTRANSLATE, + UI_CURSOR_TOOLROTATE, + UI_CURSOR_TOOLSCALE, + UI_CURSOR_TOOLCAMERA, + UI_CURSOR_TOOLPAN, + UI_CURSOR_TOOLZOOMIN, + UI_CURSOR_TOOLPICKOBJECT3, + UI_CURSOR_TOOLPLAY, + UI_CURSOR_TOOLPAUSE, + UI_CURSOR_TOOLMEDIAOPEN, + UI_CURSOR_PIPETTE, + UI_CURSOR_TOOLSIT, + UI_CURSOR_TOOLBUY, + UI_CURSOR_TOOLOPEN, + UI_CURSOR_TOOLPATHFINDING, + UI_CURSOR_TOOLPATHFINDING_PATH_START, + UI_CURSOR_TOOLPATHFINDING_PATH_START_ADD, + UI_CURSOR_TOOLPATHFINDING_PATH_END, + UI_CURSOR_TOOLPATHFINDING_PATH_END_ADD, + UI_CURSOR_TOOLNO, + UI_CURSOR_COUNT // Number of elements in this enum (NOT a cursor) +}; + +LL_COMMON_API ECursorType getCursorFromString(const std::string& cursor_string); + +#endif // LL_LLCURSORTYPES_H diff --git a/indra/llwindow/lldragdropwin32.cpp b/indra/llwindow/lldragdropwin32.cpp index 15acddd987..d00d9ab47e 100755 --- a/indra/llwindow/lldragdropwin32.cpp +++ b/indra/llwindow/lldragdropwin32.cpp @@ -242,11 +242,11 @@ class LLDragDropWin32Target: LLCoordWindow cursor_coord_window( pt_client.x, pt_client.y ); LLCoordGL gl_coord(cursor_coord_window.convert()); - llinfos << "### (Drop) URL is: " << mDropUrl << llendl; - llinfos << "### raw coords are: " << pt.x << " x " << pt.y << llendl; - llinfos << "### client coords are: " << pt_client.x << " x " << pt_client.y << llendl; - llinfos << "### GL coords are: " << gl_coord.mX << " x " << gl_coord.mY << llendl; - llinfos << llendl; + LL_INFOS() << "### (Drop) URL is: " << mDropUrl << LL_ENDL; + LL_INFOS() << "### raw coords are: " << pt.x << " x " << pt.y << LL_ENDL; + LL_INFOS() << "### client coords are: " << pt_client.x << " x " << pt_client.y << LL_ENDL; + LL_INFOS() << "### GL coords are: " << gl_coord.mX << " x " << gl_coord.mY << LL_ENDL; + LL_INFOS() << LL_ENDL; // no keyboard modifier option yet but we could one day MASK mask = gKeyboard->currentMask( TRUE ); diff --git a/indra/llwindow/lldragdropwin32.h b/indra/llwindow/lldragdropwin32.h index a6824f3e90..4673242cba 100755 --- a/indra/llwindow/lldragdropwin32.h +++ b/indra/llwindow/lldragdropwin32.h @@ -31,7 +31,7 @@ #ifndef LL_LLDRAGDROP32_H #define LL_LLDRAGDROP32_H -#include <windows.h> +#include "llwin32headerslean.h" #include <ole2.h> class LLDragDropWin32 @@ -54,7 +54,7 @@ class LLDragDropWin32 #ifndef LL_LLDRAGDROP32_H #define LL_LLDRAGDROP32_H -#include <windows.h> +#include "llwin32headerslean.h" #include <ole2.h> // impostor class that does nothing diff --git a/indra/llwindow/lldxhardware.cpp b/indra/llwindow/lldxhardware.cpp index b0f4bc5503..e7afef63f8 100755 --- a/indra/llwindow/lldxhardware.cpp +++ b/indra/llwindow/lldxhardware.cpp @@ -34,9 +34,12 @@ #include <dxdiag.h> #undef INITGUID +#include <wbemidl.h> + #include <boost/tokenizer.hpp> #include "lldxhardware.h" + #include "llerror.h" #include "llstring.h" @@ -53,11 +56,160 @@ LLDXHardware gDXHardware; #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } } -std::string get_string(IDxDiagContainer *containerp, WCHAR *wszPropName) +typedef BOOL ( WINAPI* PfnCoSetProxyBlanket )( IUnknown* pProxy, DWORD dwAuthnSvc, DWORD dwAuthzSvc, + OLECHAR* pServerPrincName, DWORD dwAuthnLevel, DWORD dwImpLevel, + RPC_AUTH_IDENTITY_HANDLE pAuthInfo, DWORD dwCapabilities ); + +HRESULT GetVideoMemoryViaWMI( WCHAR* strInputDeviceID, DWORD* pdwAdapterRam ) { HRESULT hr; + bool bGotMemory = false; + HRESULT hrCoInitialize = S_OK; + IWbemLocator* pIWbemLocator = nullptr; + IWbemServices* pIWbemServices = nullptr; + BSTR pNamespace = nullptr; + + *pdwAdapterRam = 0; + hrCoInitialize = CoInitialize( 0 ); + + hr = CoCreateInstance( CLSID_WbemLocator, + nullptr, + CLSCTX_INPROC_SERVER, + IID_IWbemLocator, + ( LPVOID* )&pIWbemLocator ); +#ifdef PRINTF_DEBUGGING + if( FAILED( hr ) ) wprintf( L"WMI: CoCreateInstance failed: 0x%0.8x\n", hr ); +#endif + + if( SUCCEEDED( hr ) && pIWbemLocator ) + { + // Using the locator, connect to WMI in the given namespace. + pNamespace = SysAllocString( L"\\\\.\\root\\cimv2" ); + + hr = pIWbemLocator->ConnectServer( pNamespace, nullptr, nullptr, 0L, + 0L, nullptr, nullptr, &pIWbemServices ); +#ifdef PRINTF_DEBUGGING + if( FAILED( hr ) ) wprintf( L"WMI: pIWbemLocator->ConnectServer failed: 0x%0.8x\n", hr ); +#endif + if( SUCCEEDED( hr ) && pIWbemServices != 0 ) + { + HINSTANCE hinstOle32 = nullptr; + + hinstOle32 = LoadLibraryW( L"ole32.dll" ); + if( hinstOle32 ) + { + PfnCoSetProxyBlanket pfnCoSetProxyBlanket = nullptr; + + pfnCoSetProxyBlanket = ( PfnCoSetProxyBlanket )GetProcAddress( hinstOle32, "CoSetProxyBlanket" ); + if( pfnCoSetProxyBlanket != 0 ) + { + // Switch security level to IMPERSONATE. + pfnCoSetProxyBlanket( pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, nullptr, + RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, nullptr, 0 ); + } + + FreeLibrary( hinstOle32 ); + } + + IEnumWbemClassObject* pEnumVideoControllers = nullptr; + BSTR pClassName = nullptr; + + pClassName = SysAllocString( L"Win32_VideoController" ); + + hr = pIWbemServices->CreateInstanceEnum( pClassName, 0, + nullptr, &pEnumVideoControllers ); +#ifdef PRINTF_DEBUGGING + if( FAILED( hr ) ) wprintf( L"WMI: pIWbemServices->CreateInstanceEnum failed: 0x%0.8x\n", hr ); +#endif + + if( SUCCEEDED( hr ) && pEnumVideoControllers ) + { + IWbemClassObject* pVideoControllers[10] = {0}; + DWORD uReturned = 0; + BSTR pPropName = nullptr; + + // Get the first one in the list + pEnumVideoControllers->Reset(); + hr = pEnumVideoControllers->Next( 5000, // timeout in 5 seconds + 10, // return the first 10 + pVideoControllers, + &uReturned ); +#ifdef PRINTF_DEBUGGING + if( FAILED( hr ) ) wprintf( L"WMI: pEnumVideoControllers->Next failed: 0x%0.8x\n", hr ); + if( uReturned == 0 ) wprintf( L"WMI: pEnumVideoControllers uReturned == 0\n" ); +#endif + + VARIANT var; + if( SUCCEEDED( hr ) ) + { + bool bFound = false; + for( UINT iController = 0; iController < uReturned; iController++ ) + { + if ( !pVideoControllers[iController] ) + continue; + + pPropName = SysAllocString( L"PNPDeviceID" ); + hr = pVideoControllers[iController]->Get( pPropName, 0L, &var, nullptr, nullptr ); +#ifdef PRINTF_DEBUGGING + if( FAILED( hr ) ) + wprintf( L"WMI: pVideoControllers[iController]->Get PNPDeviceID failed: 0x%0.8x\n", hr ); +#endif + if( SUCCEEDED( hr ) ) + { + if( wcsstr( var.bstrVal, strInputDeviceID ) != 0 ) + bFound = true; + } + VariantClear( &var ); + if( pPropName ) SysFreeString( pPropName ); + + if( bFound ) + { + pPropName = SysAllocString( L"AdapterRAM" ); + hr = pVideoControllers[iController]->Get( pPropName, 0L, &var, nullptr, nullptr ); +#ifdef PRINTF_DEBUGGING + if( FAILED( hr ) ) + wprintf( L"WMI: pVideoControllers[iController]->Get AdapterRAM failed: 0x%0.8x\n", + hr ); +#endif + if( SUCCEEDED( hr ) ) + { + bGotMemory = true; + *pdwAdapterRam = var.ulVal; + } + VariantClear( &var ); + if( pPropName ) SysFreeString( pPropName ); + break; + } + SAFE_RELEASE( pVideoControllers[iController] ); + } + } + } + + if( pClassName ) + SysFreeString( pClassName ); + SAFE_RELEASE( pEnumVideoControllers ); + } + + if( pNamespace ) + SysFreeString( pNamespace ); + SAFE_RELEASE( pIWbemServices ); + } + + SAFE_RELEASE( pIWbemLocator ); + + if( SUCCEEDED( hrCoInitialize ) ) + CoUninitialize(); + + if( bGotMemory ) + return S_OK; + else + return E_FAIL; +} + +void get_wstring(IDxDiagContainer* containerp, WCHAR* wszPropName, WCHAR* wszPropValue, int outputSize) +{ + HRESULT hr; VARIANT var; - WCHAR wszPropValue[256]; VariantInit( &var ); hr = containerp->GetProp(wszPropName, &var ); @@ -76,13 +228,19 @@ std::string get_string(IDxDiagContainer *containerp, WCHAR *wszPropName) wcscpy( wszPropValue, (var.boolVal) ? L"true" : L"false" ); /* Flawfinder: ignore */ break; case VT_BSTR: - wcsncpy( wszPropValue, var.bstrVal, 255 ); /* Flawfinder: ignore */ - wszPropValue[255] = 0; + wcsncpy( wszPropValue, var.bstrVal, outputSize-1 ); /* Flawfinder: ignore */ + wszPropValue[outputSize-1] = 0; break; } } // Clear the variant (this is needed to free BSTR memory) VariantClear( &var ); +} + +std::string get_string(IDxDiagContainer *containerp, WCHAR *wszPropName) +{ + WCHAR wszPropValue[256]; + get_wstring(containerp, wszPropName, wszPropValue, 256); return utf16str_to_utf8str(wszPropValue); } @@ -120,7 +278,7 @@ BOOL LLVersion::set(const std::string &version_string) } if (count < 4) { - //llwarns << "Potentially bogus version string!" << version_string << llendl; + //LL_WARNS() << "Potentially bogus version string!" << version_string << LL_ENDL; for (i = 0; i < 4; i++) { mFields[i] = 0; @@ -160,10 +318,10 @@ std::string LLDXDriverFile::dump() gWriteDebug(mDateString.c_str()); gWriteDebug("\n"); } - llinfos << mFilepath << llendl; - llinfos << mName << llendl; - llinfos << mVersionString << llendl; - llinfos << mDateString << llendl; + LL_INFOS() << mFilepath << LL_ENDL; + LL_INFOS() << mName << LL_ENDL; + LL_INFOS() << mVersionString << LL_ENDL; + LL_INFOS() << mDateString << LL_ENDL; return ""; } @@ -186,11 +344,11 @@ std::string LLDXDevice::dump() gWriteDebug(mPCIString.c_str()); gWriteDebug("\n"); } - llinfos << llendl; - llinfos << "DeviceName:" << mName << llendl; - llinfos << "PCIString:" << mPCIString << llendl; - llinfos << "Drivers" << llendl; - llinfos << "-------" << llendl; + LL_INFOS() << LL_ENDL; + LL_INFOS() << "DeviceName:" << mName << LL_ENDL; + LL_INFOS() << "PCIString:" << mPCIString << LL_ENDL; + LL_INFOS() << "Drivers" << LL_ENDL; + LL_INFOS() << "-------" << LL_ENDL; for (driver_file_map_t::iterator iter = mDriverFiles.begin(), end = mDriverFiles.end(); iter != end; iter++) @@ -361,8 +519,18 @@ BOOL LLDXHardware::getInfo(BOOL vram_only) goto LCleanup; } - // Get the English VRAM string + DWORD vram = 0; + + WCHAR deviceID[512]; + + get_wstring(device_containerp, L"szDeviceID", deviceID, 512); + + if (SUCCEEDED(GetVideoMemoryViaWMI(deviceID, &vram))) { + mVRAM = vram/(1024*1024); + } + else + { // Get the English VRAM string std::string ram_str = get_string(device_containerp, L"szDisplayMemoryEnglish"); // We don't need the device any more @@ -551,7 +719,7 @@ LLSD LLDXHardware::getDisplayInfo() IDxDiagContainer *driver_containerp = NULL; // CoCreate a IDxDiagProvider* - llinfos << "CoCreateInstance IID_IDxDiagProvider" << llendl; + LL_INFOS() << "CoCreateInstance IID_IDxDiagProvider" << LL_ENDL; hr = CoCreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, @@ -560,7 +728,7 @@ LLSD LLDXHardware::getDisplayInfo() if (FAILED(hr)) { - llwarns << "No DXDiag provider found! DirectX 9 not installed!" << llendl; + LL_WARNS() << "No DXDiag provider found! DirectX 9 not installed!" << LL_ENDL; gWriteDebug("No DXDiag provider found! DirectX 9 not installed!\n"); goto LCleanup; } @@ -578,14 +746,14 @@ LLSD LLDXHardware::getDisplayInfo() dx_diag_init_params.bAllowWHQLChecks = TRUE; dx_diag_init_params.pReserved = NULL; - llinfos << "dx_diag_providerp->Initialize" << llendl; + LL_INFOS() << "dx_diag_providerp->Initialize" << LL_ENDL; hr = dx_diag_providerp->Initialize(&dx_diag_init_params); if(FAILED(hr)) { goto LCleanup; } - llinfos << "dx_diag_providerp->GetRootContainer" << llendl; + LL_INFOS() << "dx_diag_providerp->GetRootContainer" << LL_ENDL; hr = dx_diag_providerp->GetRootContainer( &dx_diag_rootp ); if(FAILED(hr) || !dx_diag_rootp) { @@ -595,7 +763,7 @@ LLSD LLDXHardware::getDisplayInfo() HRESULT hr; // Get display driver information - llinfos << "dx_diag_rootp->GetChildContainer" << llendl; + LL_INFOS() << "dx_diag_rootp->GetChildContainer" << LL_ENDL; hr = dx_diag_rootp->GetChildContainer(L"DxDiag_DisplayDevices", &devices_containerp); if(FAILED(hr) || !devices_containerp) { @@ -603,7 +771,7 @@ LLSD LLDXHardware::getDisplayInfo() } // Get device 0 - llinfos << "devices_containerp->GetChildContainer" << llendl; + LL_INFOS() << "devices_containerp->GetChildContainer" << LL_ENDL; hr = devices_containerp->GetChildContainer(L"0", &device_containerp); if(FAILED(hr) || !device_containerp) { diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index 8b356ba138..f6f6c3931c 100755 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -187,7 +187,7 @@ BOOL LLKeyboard::translateKey(const U16 os_key, KEY *out_key) iter = mTranslateKeyMap.find(os_key); if (iter == mTranslateKeyMap.end()) { - //llwarns << "Unknown virtual key " << os_key << llendl; + //LL_WARNS() << "Unknown virtual key " << os_key << LL_ENDL; *out_key = 0; return FALSE; } @@ -258,7 +258,7 @@ BOOL LLKeyboard::handleTranslatedKeyUp(KEY translated_key, U32 translated_mask) handled = mCallbacks->handleTranslatedKeyUp(translated_key, translated_mask); } - lldebugst(LLERR_USER_INPUT) << "keyup -" << translated_key << "-" << llendl; + LL_DEBUGS("UserInput") << "keyup -" << translated_key << "-" << LL_ENDL; return handled; } @@ -321,7 +321,7 @@ BOOL LLKeyboard::keyFromString(const std::string& str, KEY *key) *key = res; return TRUE; } - llwarns << "keyFromString failed: " << str << llendl; + LL_WARNS() << "keyFromString failed: " << str << LL_ENDL; return FALSE; } @@ -363,7 +363,7 @@ std::string LLKeyboard::stringFromAccelerator( MASK accel_mask, KEY key ) if( trans == NULL ) { - llerrs << "No mKeyStringTranslator" << llendl; + LL_ERRS() << "No mKeyStringTranslator" << LL_ENDL; return res; } diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index 92449c123f..6f2dc87317 100755 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -28,8 +28,9 @@ #define LL_LLKEYBOARD_H #include <map> +#include <boost/function.hpp> -#include "string_table.h" +#include "llstringtable.h" #include "lltimer.h" #include "indra_constants.h" diff --git a/indra/llwindow/llkeyboardwin32.cpp b/indra/llwindow/llkeyboardwin32.cpp index be3fe5deb0..dc40dcdde0 100755 --- a/indra/llwindow/llkeyboardwin32.cpp +++ b/indra/llwindow/llkeyboardwin32.cpp @@ -28,10 +28,7 @@ #include "linden_common.h" -#define WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> - +#include "llwin32headerslean.h" #include "llkeyboardwin32.h" #include "llwindowcallbacks.h" @@ -269,7 +266,7 @@ void LLKeyboardWin32::scanKeyboard() // keydown in highest bit if (!pending_key_events && !(GetAsyncKeyState(virtual_key) & 0x8000)) { - //llinfos << "Key up event missed, resetting" << llendl; + //LL_INFOS() << "Key up event missed, resetting" << LL_ENDL; mKeyLevel[key] = FALSE; } } diff --git a/indra/llwindow/llmousehandler.cpp b/indra/llwindow/llmousehandler.cpp index 8695e92f77..bea66e763c 100755 --- a/indra/llwindow/llmousehandler.cpp +++ b/indra/llwindow/llmousehandler.cpp @@ -39,7 +39,7 @@ BOOL LLMouseHandler::handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType cli case CLICK_MIDDLE: handled = handleMiddleMouseDown(x, y, mask); break; case CLICK_DOUBLELEFT: handled = handleDoubleClick(x, y, mask); break; default: - llwarns << "Unhandled enum." << llendl; + LL_WARNS() << "Unhandled enum." << LL_ENDL; } } else @@ -51,7 +51,7 @@ BOOL LLMouseHandler::handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType cli case CLICK_MIDDLE: handled = handleMiddleMouseUp(x, y, mask); break; case CLICK_DOUBLELEFT: handled = handleDoubleClick(x, y, mask); break; default: - llwarns << "Unhandled enum." << llendl; + LL_WARNS() << "Unhandled enum." << LL_ENDL; } } return handled; diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h index 1e0e47cd02..072d40f739 100644 --- a/indra/llwindow/llopenglview-objc.h +++ b/indra/llwindow/llopenglview-objc.h @@ -42,6 +42,7 @@ unsigned int mMarkedTextLength; bool mMarkedTextAllowed; bool mSimulatedRightClick; + bool mOldResize; } - (id) initWithSamples:(NSUInteger)samples; - (id) initWithSamples:(NSUInteger)samples andVsync:(BOOL)vsync; @@ -49,6 +50,8 @@ - (void)commitCurrentPreedit; +- (void) setOldResize:(bool)oldresize; + // rebuildContext // Destroys and recreates a context with the view's internal format set via setPixelFormat; // Use this in event of needing to rebuild a context for whatever reason, without needing to assign a new pixel format. @@ -76,6 +79,7 @@ @interface LLNonInlineTextView : NSTextView { LLOpenGLView *glview; + unichar mKeyPressed; } - (void) setGLView:(LLOpenGLView*)view; diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 9155e59a1d..ff312945b6 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -94,8 +94,11 @@ attributedStringInfo getSegments(NSAttributedString *str) // Force a high quality update after live resizing - (void) viewDidEndLiveResize { - NSSize size = [self frame].size; - callResize(size.width, size.height); + if (mOldResize) //Maint-3135 + { + NSSize size = [self frame].size; + callResize(size.width, size.height); + } } - (unsigned long)getVramSize @@ -124,10 +127,18 @@ attributedStringInfo getSegments(NSAttributedString *str) object:[self window]]; } +- (void)setOldResize:(bool)oldresize +{ + mOldResize = oldresize; +} + - (void)windowResized:(NSNotification *)notification; { - //NSSize size = [self frame].size; - //callResize(size.width, size.height); + if (!mOldResize) //Maint-3288 + { + NSSize size = [self frame].size; + callResize(size.width, size.height); + } } - (void)dealloc @@ -204,6 +215,8 @@ attributedStringInfo getSegments(NSAttributedString *str) [glContext setValues:(const GLint*)0 forParameter:NSOpenGLCPSwapInterval]; } + mOldResize = false; + return self; } @@ -257,14 +270,14 @@ attributedStringInfo getSegments(NSAttributedString *str) !([theEvent modifierFlags] & NSFunctionKeyMask) && !([theEvent modifierFlags] & NSHelpKeyMask)) { - callRightMouseDown(mMousePos, mModifiers); + callRightMouseDown(mMousePos, [theEvent modifierFlags]); mSimulatedRightClick = true; } else { if ([theEvent clickCount] >= 2) { - callDoubleClick(mMousePos, mModifiers); + callDoubleClick(mMousePos, [theEvent modifierFlags]); } else if ([theEvent clickCount] == 1) { - callLeftMouseDown(mMousePos, mModifiers); + callLeftMouseDown(mMousePos, [theEvent modifierFlags]); } } } @@ -273,21 +286,21 @@ attributedStringInfo getSegments(NSAttributedString *str) { if (mSimulatedRightClick) { - callRightMouseUp(mMousePos, mModifiers); + callRightMouseUp(mMousePos, [theEvent modifierFlags]); mSimulatedRightClick = false; } else { - callLeftMouseUp(mMousePos, mModifiers); + callLeftMouseUp(mMousePos, [theEvent modifierFlags]); } } - (void) rightMouseDown:(NSEvent *)theEvent { - callRightMouseDown(mMousePos, mModifiers); + callRightMouseDown(mMousePos, [theEvent modifierFlags]); } - (void) rightMouseUp:(NSEvent *)theEvent { - callRightMouseUp(mMousePos, mModifiers); + callRightMouseUp(mMousePos, [theEvent modifierFlags]); } - (void)mouseMoved:(NSEvent *)theEvent @@ -328,12 +341,12 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void) otherMouseDown:(NSEvent *)theEvent { - callMiddleMouseDown(mMousePos, mModifiers); + callMiddleMouseDown(mMousePos, [theEvent modifierFlags]); } - (void) otherMouseUp:(NSEvent *)theEvent { - callMiddleMouseUp(mMousePos, mModifiers); + callMiddleMouseUp(mMousePos, [theEvent modifierFlags]); } - (void) otherMouseDragged:(NSEvent *)theEvent @@ -353,22 +366,27 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void) keyUp:(NSEvent *)theEvent { - callKeyUp([theEvent keyCode], mModifiers); + callKeyUp([theEvent keyCode], [theEvent modifierFlags]); } - (void) keyDown:(NSEvent *)theEvent { uint keycode = [theEvent keyCode]; + // We must not depend on flagsChange event to detect modifier flags changed, + // must depend on the modifire flags in the event parameter. + // Because flagsChange event handler misses event when other window is activated, + // e.g. OS Window for upload something or Input Window... + // mModifiers instance variable is for insertText: or insertText:replacementRange: (by Pell Smit) + mModifiers = [theEvent modifierFlags]; bool acceptsText = mHasMarkedText ? false : callKeyDown(keycode, mModifiers); + unichar ch; if (acceptsText && !mMarkedTextAllowed && + !(mModifiers & (NSControlKeyMask | NSCommandKeyMask)) && // commands don't invoke InputWindow ![(LLAppDelegate*)[NSApp delegate] romanScript] && - [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSDeleteCharacter && - [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSBackspaceCharacter && - [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSDownArrowFunctionKey && - [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSUpArrowFunctionKey && - [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSLeftArrowFunctionKey && - [[theEvent charactersIgnoringModifiers] characterAtIndex:0] != NSRightArrowFunctionKey) + (ch = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]) > ' ' && + ch != NSDeleteCharacter && + (ch < 0xF700 || ch > 0xF8FF)) // 0xF700-0xF8FF: reserved for function keys on the keyboard(from NSEvent.h) { [(LLAppDelegate*)[NSApp delegate] showInputWindow:true withEvent:theEvent]; } else @@ -385,9 +403,35 @@ attributedStringInfo getSegments(NSAttributedString *str) } } -- (void)flagsChanged:(NSEvent *)theEvent { +- (void)flagsChanged:(NSEvent *)theEvent +{ mModifiers = [theEvent modifierFlags]; callModifier([theEvent modifierFlags]); + + NSInteger mask = 0; + switch([theEvent keyCode]) + { + case 56: + mask = NSShiftKeyMask; + break; + case 58: + mask = NSAlternateKeyMask; + break; + case 59: + mask = NSControlKeyMask; + break; + default: + return; + } + + if (mModifiers & mask) + { + callKeyDown([theEvent keyCode], 0); + } + else + { + callKeyUp([theEvent keyCode], 0); + } } - (BOOL) acceptsFirstResponder @@ -459,31 +503,58 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange { - if ([aString class] == NSClassFromString(@"NSConcreteMutableAttributedString")) + // Apple says aString can be either an NSString or NSAttributedString instance. + // But actually it's NSConcreteMutableAttributedString or __NSCFConstantString. + // I observed aString was __NSCFConstantString only aString was null string(zero length). + // Apple also says when aString is an NSString object, + // the receiver is expected to render the marked text with distinguishing appearance. + // So I tried to make attributedStringInfo, but it won't be used... (Pell Smit) + + if (mMarkedTextAllowed) { - if (mMarkedTextAllowed) + unsigned int selected[2] = { + selectedRange.location, + selectedRange.length + }; + + unsigned int replacement[2] = { + replacementRange.location, + replacementRange.length + }; + + int string_length = [aString length]; + unichar text[string_length]; + attributedStringInfo segments; + // I used 'respondsToSelector:@selector(string)' + // to judge aString is an attributed string or not. + if ([aString respondsToSelector:@selector(string)]) + { + // aString is attibuted + [[aString string] getCharacters:text range:NSMakeRange(0, string_length)]; + segments = getSegments((NSAttributedString *)aString); + } + else + { + // aString is not attributed + [aString getCharacters:text range:NSMakeRange(0, string_length)]; + segments.seg_lengths.push_back(string_length); + segments.seg_standouts.push_back(true); + } + setMarkedText(text, selected, replacement, string_length, segments); + if (string_length > 0) { - unsigned int selected[2] = { - selectedRange.location, - selectedRange.length - }; - - unsigned int replacement[2] = { - replacementRange.location, - replacementRange.length - }; - - unichar text[[aString length]]; - [[aString mutableString] getCharacters:text range:NSMakeRange(0, [aString length])]; - attributedStringInfo segments = getSegments((NSAttributedString *)aString); - setMarkedText(text, selected, replacement, [aString length], segments); mHasMarkedText = TRUE; - mMarkedTextLength = [aString length]; - } else { - if (mHasMarkedText) - { - [self unmarkText]; - } + mMarkedTextLength = string_length; + } + else + { + // we must clear the marked text when aString is null. + [self unmarkText]; + } + } else { + if (mHasMarkedText) + { + [self unmarkText]; } } } @@ -602,37 +673,63 @@ attributedStringInfo getSegments(NSAttributedString *str) @implementation LLNonInlineTextView +/* Input Window is a legacy of 20 century, so we want to remove related classes. + But unfortunately, Viwer web browser has no support for modern inline input, + we need to leave these classes... + We will be back to get rid of Input Window after fixing viewer web browser. + + How Input Window should work: + 1) Input Window must not be empty. + It must close when it become empty result of edithing. + 2) Input Window must not close when it still has input data. + It must keep open user types next char before commit. by Pell Smit +*/ + - (void) setGLView:(LLOpenGLView *)view { glview = view; } -- (void) insertText:(id)insertString +- (void)keyDown:(NSEvent *)theEvent { - [[self inputContext] discardMarkedText]; - [self setString:@""]; - [_window orderOut:_window]; - [self insertText:insertString replacementRange:NSMakeRange(0, [insertString length])]; + // mKeyPressed is used later to determine whethere Input Window should close or not + mKeyPressed = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; + // setMarkedText and insertText is called indirectly from inside keyDown: method + [super keyDown:theEvent]; } -- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange +// setMarkedText: is called for incomplete input(on the way to conversion). +- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange { - [glview insertText:aString replacementRange:replacementRange]; + [super setMarkedText:aString selectedRange:selectedRange replacementRange:replacementRange]; + if ([aString length] == 0) // this means Input Widow becomes empty + { + [_window orderOut:_window]; // Close this to avoid empty Input Window + } } -- (void) insertNewline:(id)sender +// insertText: is called for inserting commited text. +// There are two ways to be called here: +// a) explicitly commited (must close) +// In case of user typed commit key(usually return key) or delete key or something +// b) automatically commited (must not close) +// In case of user typed next letter after conversion +- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange { - [[self textStorage] setValue:@""]; - [[self inputContext] discardMarkedText]; + [[self inputContext] discardMarkedText]; [self setString:@""]; -} - -- (void)doCommandBySelector:(SEL)aSelector -{ - if (aSelector == @selector(insertNewline:)) - { - [self insertNewline:self]; - } + [glview insertText:aString replacementRange:replacementRange]; + if (mKeyPressed == NSEnterCharacter || + mKeyPressed == NSBackspaceCharacter || + mKeyPressed == NSTabCharacter || + mKeyPressed == NSNewlineCharacter || + mKeyPressed == NSCarriageReturnCharacter || + mKeyPressed == NSDeleteCharacter || + (mKeyPressed >= 0xF700 && mKeyPressed <= 0xF8FF)) + { + // this is case a) of above comment + [_window orderOut:_window]; // to avoid empty Input Window + } } @end diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 93b9d36939..5720660034 100755 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -39,7 +39,6 @@ #include "llerror.h" #include "llkeyboard.h" -#include "linked_lists.h" #include "llwindowcallbacks.h" @@ -72,8 +71,8 @@ S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) } S32 result = 0; -#if LL_MESA_HEADLESS // !!! *FIX: (???) - llwarns << "OSMessageBox: " << text << llendl; +#if LL_MESA_HEADLESS // !!! *FIX: (?) + LL_WARNS() << "OSMessageBox: " << text << LL_ENDL; return OSBTN_OK; #elif LL_WINDOWS result = OSMessageBoxWin32(text, caption, type); @@ -324,7 +323,7 @@ bool LLSplashScreen::isVisible() // static LLSplashScreen *LLSplashScreen::create() { -#if LL_MESA_HEADLESS || LL_SDL // !!! *FIX: (???) +#if LL_MESA_HEADLESS || LL_SDL // !!! *FIX: (?) return 0; #elif LL_WINDOWS return new LLSplashScreenWin32; @@ -423,7 +422,7 @@ LLWindow* LLWindowManager::createWindow( if (FALSE == new_window->isValid()) { delete new_window; - llwarns << "LLWindowManager::create() : Error creating window." << llendl; + LL_WARNS() << "LLWindowManager::create() : Error creating window." << LL_ENDL; return NULL; } sWindowList.insert(new_window); @@ -434,8 +433,8 @@ BOOL LLWindowManager::destroyWindow(LLWindow* window) { if (sWindowList.find(window) == sWindowList.end()) { - llerrs << "LLWindowManager::destroyWindow() : Window pointer not valid, this window doesn't exist!" - << llendl; + LL_ERRS() << "LLWindowManager::destroyWindow() : Window pointer not valid, this window doesn't exist!" + << LL_ENDL; return FALSE; } diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 78186004b8..0a30f4c807 100755 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -31,6 +31,7 @@ #include "llcoord.h" #include "llstring.h" #include "llcursortypes.h" +#include "llinstancetracker.h" #include "llsd.h" class LLSplashScreen; @@ -123,7 +124,7 @@ public: virtual void swapBuffers() = 0; virtual void bringToFront() = 0; virtual void focusClient() { }; // this may not have meaning or be required on other platforms, therefore, it's not abstract - + virtual void setOldResize(bool oldresize) { }; // handy coordinate space conversion routines // NB: screen to window and vice verse won't work on width/height coordinate pairs, // as the conversion must take into account left AND right border widths, etc. diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index 81b25601a9..d64525fbdd 100755 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -74,6 +74,7 @@ void showNSCursor(); void hideNSCursorTillMove(bool hide); void requestUserAttention(); long showAlert(std::string title, std::string text, int type); +void setResizeMode(bool oldresize, void* glview); NSWindowRef createNSWindow(int x, int y, int width, int height); diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 0768d0352e..1a21bf8430 100755 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -91,7 +91,7 @@ const unsigned short *copyFromPBoard() NSArray *objToPaste = [pboard readObjectsForClasses:classArray options:[NSDictionary dictionary]]; str = [objToPaste objectAtIndex:0]; } - unichar* temp = (unichar*)calloc([str length], sizeof(unichar)); + unichar* temp = (unichar*)calloc([str length]+1, sizeof(unichar)); [str getCharacters:temp]; [pool release]; return temp; @@ -222,6 +222,11 @@ GLViewRef createOpenGLView(NSWindowRef window, unsigned int samples, bool vsync) return glview; } +void setResizeMode(bool oldresize, void* glview) +{ + [(LLOpenGLView *)glview setOldResize:oldresize]; +} + void glSwapBuffers(void* context) { [(NSOpenGLContext*)context flushBuffer]; diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 11c0b51086..75900c3cb4 100755 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -39,6 +39,7 @@ #include "indra_constants.h" #include <OpenGL/OpenGL.h> +#include <Carbon/Carbon.h> #include <CoreServices/CoreServices.h> extern BOOL gDebugWindowProc; @@ -785,7 +786,7 @@ BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position) } else { - llerrs << "LLWindowMacOSX::getPosition(): no window and not fullscreen!" << llendl; + LL_ERRS() << "LLWindowMacOSX::getPosition(): no window and not fullscreen!" << LL_ENDL; } return (err == noErr); @@ -811,7 +812,7 @@ BOOL LLWindowMacOSX::getSize(LLCoordScreen *size) } else { - llerrs << "LLWindowMacOSX::getPosition(): no window and not fullscreen!" << llendl; + LL_ERRS() << "LLWindowMacOSX::getPosition(): no window and not fullscreen!" << LL_ENDL; } return (err == noErr); @@ -837,7 +838,7 @@ BOOL LLWindowMacOSX::getSize(LLCoordWindow *size) } else { - llerrs << "LLWindowMacOSX::getPosition(): no window and not fullscreen!" << llendl; + LL_ERRS() << "LLWindowMacOSX::getPosition(): no window and not fullscreen!" << LL_ENDL; } return (err == noErr); @@ -998,11 +999,11 @@ void LLWindowMacOSX::setMouseClipping( BOOL b ) if(b) { - // llinfos << "setMouseClipping(TRUE)" << llendl; + // LL_INFOS() << "setMouseClipping(TRUE)" << LL_ENDL; } else { - // llinfos << "setMouseClipping(FALSE)" << llendl; + // LL_INFOS() << "setMouseClipping(FALSE)" << LL_ENDL; } adjustCursorDecouple(); @@ -1020,7 +1021,7 @@ BOOL LLWindowMacOSX::setCursorPosition(const LLCoordWindow position) CGPoint newPosition; - // llinfos << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << llendl; + // LL_INFOS() << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << LL_ENDL; newPosition.x = screen_pos.mX; newPosition.y = screen_pos.mY; @@ -1082,7 +1083,7 @@ void LLWindowMacOSX::adjustCursorDecouple(bool warpingMouse) // The cursor should be decoupled. Make sure it is. if(!mCursorDecoupled) { - // llinfos << "adjustCursorDecouple: decoupling cursor" << llendl; + // LL_INFOS() << "adjustCursorDecouple: decoupling cursor" << LL_ENDL; CGAssociateMouseAndMouseCursorPosition(false); mCursorDecoupled = true; mCursorIgnoreNextDelta = TRUE; @@ -1094,7 +1095,7 @@ void LLWindowMacOSX::adjustCursorDecouple(bool warpingMouse) // The cursor should not be decoupled. Make sure it isn't. if(mCursorDecoupled) { - // llinfos << "adjustCursorDecouple: recoupling cursor" << llendl; + // LL_INFOS() << "adjustCursorDecouple: recoupling cursor" << LL_ENDL; CGAssociateMouseAndMouseCursorPosition(true); mCursorDecoupled = false; } @@ -1359,7 +1360,7 @@ const char* cursorIDToName(int id) case UI_CURSOR_TOOLNO: return "UI_CURSOR_NO"; } - llerrs << "cursorIDToName: unknown cursor id" << id << llendl; + LL_ERRS() << "cursorIDToName: unknown cursor id" << id << LL_ENDL; return "UI_CURSOR_ARROW"; } @@ -1542,14 +1543,14 @@ void LLWindowMacOSX::hideCursor() { if(!mCursorHidden) { - // llinfos << "hideCursor: hiding" << llendl; + // LL_INFOS() << "hideCursor: hiding" << LL_ENDL; mCursorHidden = TRUE; mHideCursorPermanent = TRUE; hideNSCursor(); } else { - // llinfos << "hideCursor: already hidden" << llendl; + // LL_INFOS() << "hideCursor: already hidden" << LL_ENDL; } adjustCursorDecouple(); @@ -1559,14 +1560,14 @@ void LLWindowMacOSX::showCursor() { if(mCursorHidden) { - // llinfos << "showCursor: showing" << llendl; + // LL_INFOS() << "showCursor: showing" << LL_ENDL; mCursorHidden = FALSE; mHideCursorPermanent = FALSE; showNSCursor(); } else { - // llinfos << "showCursor: already visible" << llendl; + // LL_INFOS() << "showCursor: already visible" << LL_ENDL; } adjustCursorDecouple(); @@ -1651,14 +1652,14 @@ void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url, bool async) if (!found) { - llwarns << "spawn_web_browser called for url with protocol not on whitelist: " << escaped_url << llendl; + LL_WARNS() << "spawn_web_browser called for url with protocol not on whitelist: " << escaped_url << LL_ENDL; return; } S32 result = 0; CFURLRef urlRef = NULL; - llinfos << "Opening URL " << escaped_url << llendl; + LL_INFOS() << "Opening URL " << escaped_url << LL_ENDL; CFStringRef stringRef = CFStringCreateWithCString(NULL, escaped_url.c_str(), kCFStringEncodingUTF8); if (stringRef) @@ -1678,14 +1679,14 @@ void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url, bool async) if (result != noErr) { - llinfos << "Error " << result << " on open." << llendl; + LL_INFOS() << "Error " << result << " on open." << LL_ENDL; } CFRelease(urlRef); } else { - llinfos << "Error: couldn't create URL." << llendl; + LL_INFOS() << "Error: couldn't create URL." << LL_ENDL; } } @@ -1738,21 +1739,39 @@ LLSD LLWindowMacOSX::getNativeKeyData() } #endif - lldebugs << "native key data is: " << result << llendl; + LL_DEBUGS() << "native key data is: " << result << LL_ENDL; return result; } - BOOL LLWindowMacOSX::dialogColorPicker( F32 *r, F32 *g, F32 *b) { - // Is this even used anywhere? Do we really need an OS color picker? BOOL retval = FALSE; - //S32 error = 0; + OSErr error = noErr; + NColorPickerInfo info; + + memset(&info, 0, sizeof(info)); + info.theColor.color.rgb.red = (UInt16)(*r * 65535.f); + info.theColor.color.rgb.green = (UInt16)(*g * 65535.f); + info.theColor.color.rgb.blue = (UInt16)(*b * 65535.f); + info.placeWhere = kCenterOnMainScreen; + + error = NPickColor(&info); + + if (error == noErr) + { + retval = info.newColorChosen; + if (info.newColorChosen) + { + *r = ((float) info.theColor.color.rgb.red) / 65535.0; + *g = ((float) info.theColor.color.rgb.green) / 65535.0; + *b = ((float) info.theColor.color.rgb.blue) / 65535.0; + } + } + return (retval); } - void *LLWindowMacOSX::getPlatformWindow() { // NOTE: this will be NULL in fullscreen mode. Plan accordingly. @@ -1786,8 +1805,6 @@ static long getDictLong (CFDictionaryRef refDict, CFStringRef key) void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) { - allowDirectMarkedTextInput(b, mGLView); - if (preeditor != mPreeditor && !b) { // This condition may occur by a call to @@ -1817,6 +1834,7 @@ void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) return; } mLanguageTextInputAllowed = b; + allowDirectMarkedTextInput(b, mGLView); // mLanguageTextInputAllowed and mMarkedTextAllowed should be updated at once (by Pell Smit } void LLWindowMacOSX::interruptLanguageTextInput() @@ -1849,7 +1867,7 @@ S16 LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef t S16 result = 0; LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; - lldebugs << "drag tracking handler, message = " << message << llendl; + LL_DEBUGS() << "drag tracking handler, message = " << message << LL_ENDL; switch(message) { diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 6a6b39e674..825fd05c5f 100755 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -152,7 +152,10 @@ protected: BOOL resetDisplayResolution(); BOOL shouldPostQuit() { return mPostQuit; } - + + //Satisfy MAINT-3135 and MAINT-3288 with a flag. + /*virtual */ void setOldResize(bool oldresize) {setResizeMode(oldresize, mGLView); } + protected: // diff --git a/indra/llwindow/llwindowmesaheadless.cpp b/indra/llwindow/llwindowmesaheadless.cpp index 11c22ac94e..4b01f7a979 100755 --- a/indra/llwindow/llwindowmesaheadless.cpp +++ b/indra/llwindow/llwindowmesaheadless.cpp @@ -46,7 +46,7 @@ LLWindowMesaHeadless::LLWindowMesaHeadless(LLWindowCallbacks* callbacks, { if (use_gl) { - llinfos << "MESA Init" << llendl; + LL_INFOS() << "MESA Init" << LL_ENDL; mMesaContext = OSMesaCreateContextExt( GL_RGBA, 32, 0, 0, NULL ); /* Allocate the image buffer */ @@ -58,7 +58,7 @@ LLWindowMesaHeadless::LLWindowMesaHeadless(LLWindowCallbacks* callbacks, /* Bind the buffer to the context and make it current */ if (!OSMesaMakeCurrent( mMesaContext, mMesaBuffer, MESA_CHANNEL_TYPE, width, height )) { - llerrs << "MESA: OSMesaMakeCurrent failed!" << llendl; + LL_ERRS() << "MESA: OSMesaMakeCurrent failed!" << LL_ENDL; } llverify(gGLManager.initGL()); diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 205466e936..c20e639fc7 100755 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -109,7 +109,7 @@ bool LLWindowSDL::ll_try_gtk_init(void) if (!done_setlocale) { - llinfos << "Starting GTK Initialization." << llendl; + LL_INFOS() << "Starting GTK Initialization." << LL_ENDL; maybe_lock_display(); gtk_disable_setlocale(); maybe_unlock_display(); @@ -124,20 +124,20 @@ bool LLWindowSDL::ll_try_gtk_init(void) gtk_is_good = gtk_init_check(NULL, NULL); maybe_unlock_display(); if (!gtk_is_good) - llwarns << "GTK Initialization failed." << llendl; + LL_WARNS() << "GTK Initialization failed." << LL_ENDL; } if (gtk_is_good && !done_gtk_diag) { - llinfos << "GTK Initialized." << llendl; - llinfos << "- Compiled against GTK version " + LL_INFOS() << "GTK Initialized." << LL_ENDL; + LL_INFOS() << "- Compiled against GTK version " << GTK_MAJOR_VERSION << "." << GTK_MINOR_VERSION << "." - << GTK_MICRO_VERSION << llendl; - llinfos << "- Running against GTK version " + << GTK_MICRO_VERSION << LL_ENDL; + LL_INFOS() << "- Running against GTK version " << gtk_major_version << "." << gtk_minor_version << "." - << gtk_micro_version << llendl; + << gtk_micro_version << LL_ENDL; maybe_lock_display(); const gchar* gtk_warning = gtk_check_version( GTK_MAJOR_VERSION, @@ -146,11 +146,11 @@ bool LLWindowSDL::ll_try_gtk_init(void) maybe_unlock_display(); if (gtk_warning) { - llwarns << "- GTK COMPATIBILITY WARNING: " << - gtk_warning << llendl; + LL_WARNS() << "- GTK COMPATIBILITY WARNING: " << + gtk_warning << LL_ENDL; gtk_is_good = FALSE; } else { - llinfos << "- GTK version is good." << llendl; + LL_INFOS() << "- GTK version is good." << LL_ENDL; } done_gtk_diag = TRUE; @@ -223,7 +223,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, mOriginalAspectRatio = 1024.0 / 768.0; if (title.empty()) - mWindowTitle = "SDL Window"; // *FIX: (???) + mWindowTitle = "SDL Window"; // *FIX: (?) else mWindowTitle = title; @@ -278,7 +278,7 @@ static int x11_detect_VRAM_kb_fp(FILE *fp, const char *prefix_str) char line_buf[line_buf_size]; while (fgets(line_buf, line_buf_size, fp)) { - //lldebugs << "XLOG: " << line_buf << llendl; + //LL_DEBUGS() << "XLOG: " << line_buf << LL_ENDL; // Why the ad-hoc parser instead of using a regex? Our // favourite regex implementation - libboost_regex - is @@ -353,8 +353,8 @@ static int x11_detect_VRAM_kb() fp = fopen(fname.c_str(), "r"); if (fp) { - llinfos << "Looking in " << fname - << " for VRAM info..." << llendl; + LL_INFOS() << "Looking in " << fname + << " for VRAM info..." << LL_ENDL; rtn = x11_detect_VRAM_kb_fp(fp, ": VideoRAM: "); fclose(fp); if (0 == rtn) @@ -378,8 +378,8 @@ static int x11_detect_VRAM_kb() } else { - llinfos << "Could not open " << fname - << " - skipped." << llendl; + LL_INFOS() << "Could not open " << fname + << " - skipped." << LL_ENDL; // Try old XFree86 log otherwise fname = x_log_location; fname += "XFree86."; @@ -388,8 +388,8 @@ static int x11_detect_VRAM_kb() fp = fopen(fname.c_str(), "r"); if (fp) { - llinfos << "Looking in " << fname - << " for VRAM info..." << llendl; + LL_INFOS() << "Looking in " << fname + << " for VRAM info..." << LL_ENDL; rtn = x11_detect_VRAM_kb_fp(fp, ": VideoRAM: "); fclose(fp); if (0 == rtn) @@ -404,8 +404,8 @@ static int x11_detect_VRAM_kb() } else { - llinfos << "Could not open " << fname - << " - skipped." << llendl; + LL_INFOS() << "Could not open " << fname + << " - skipped." << LL_ENDL; } } return rtn; @@ -417,8 +417,8 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B { //bool glneedsinit = false; - llinfos << "createContext, fullscreen=" << fullscreen << - " size=" << width << "x" << height << llendl; + LL_INFOS() << "createContext, fullscreen=" << fullscreen << + " size=" << width << "x" << height << LL_ENDL; // captures don't survive contexts mGrabbyKeyFlags = 0; @@ -426,28 +426,28 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B if (SDL_Init(SDL_INIT_VIDEO) < 0) { - llinfos << "sdl_init() failed! " << SDL_GetError() << llendl; + LL_INFOS() << "sdl_init() failed! " << SDL_GetError() << LL_ENDL; setupFailure("sdl_init() failure, window creation error", "error", OSMB_OK); return false; } SDL_version c_sdl_version; SDL_VERSION(&c_sdl_version); - llinfos << "Compiled against SDL " + LL_INFOS() << "Compiled against SDL " << int(c_sdl_version.major) << "." << int(c_sdl_version.minor) << "." - << int(c_sdl_version.patch) << llendl; + << int(c_sdl_version.patch) << LL_ENDL; const SDL_version *r_sdl_version; r_sdl_version = SDL_Linked_Version(); - llinfos << " Running against SDL " + LL_INFOS() << " Running against SDL " << int(r_sdl_version->major) << "." << int(r_sdl_version->minor) << "." - << int(r_sdl_version->patch) << llendl; + << int(r_sdl_version->patch) << LL_ENDL; const SDL_VideoInfo *video_info = SDL_GetVideoInfo( ); if (!video_info) { - llinfos << "SDL_GetVideoInfo() failed! " << SDL_GetError() << llendl; + LL_INFOS() << "SDL_GetVideoInfo() failed! " << SDL_GetError() << LL_ENDL; setupFailure("SDL_GetVideoInfo() failed, Window creation error", "Error", OSMB_OK); return FALSE; } @@ -455,7 +455,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B if (video_info->current_h > 0) { mOriginalAspectRatio = (float)video_info->current_w / (float)video_info->current_h; - llinfos << "Original aspect ratio was " << video_info->current_w << ":" << video_info->current_h << "=" << mOriginalAspectRatio << llendl; + LL_INFOS() << "Original aspect ratio was " << video_info->current_w << ":" << video_info->current_h << "=" << mOriginalAspectRatio << LL_ENDL; } SDL_EnableUNICODE(1); @@ -525,7 +525,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B if (mFullscreen) { - llinfos << "createContext: setting up fullscreen " << width << "x" << height << llendl; + LL_INFOS() << "createContext: setting up fullscreen " << width << "x" << height << LL_ENDL; // If the requested width or height is 0, find the best default for the monitor. if((width == 0) || (height == 0)) @@ -543,18 +543,18 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B U32 closestWidth = 0; int i; - llinfos << "createContext: searching for a display mode, original aspect is " << mOriginalAspectRatio << llendl; + LL_INFOS() << "createContext: searching for a display mode, original aspect is " << mOriginalAspectRatio << LL_ENDL; for(i=0; i < resolutionCount; i++) { F32 aspect = (F32)resolutionList[i].mWidth / (F32)resolutionList[i].mHeight; - llinfos << "createContext: width " << resolutionList[i].mWidth << " height " << resolutionList[i].mHeight << " aspect " << aspect << llendl; + LL_INFOS() << "createContext: width " << resolutionList[i].mWidth << " height " << resolutionList[i].mHeight << " aspect " << aspect << LL_ENDL; if( (resolutionList[i].mHeight >= 700) && (resolutionList[i].mHeight <= 800) && (fabs(aspect - mOriginalAspectRatio) < fabs(closestAspect - mOriginalAspectRatio))) { - llinfos << " (new closest mode) " << llendl; + LL_INFOS() << " (new closest mode) " << LL_ENDL; // This is the closest mode we've seen yet. closestWidth = resolutionList[i].mWidth; @@ -590,15 +590,15 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B mFullscreenBits = mWindow->format->BitsPerPixel; mFullscreenRefresh = -1; - llinfos << "Running at " << mFullscreenWidth + LL_INFOS() << "Running at " << mFullscreenWidth << "x" << mFullscreenHeight << "x" << mFullscreenBits << " @ " << mFullscreenRefresh - << llendl; + << LL_ENDL; } else { - llwarns << "createContext: fullscreen creation failure. SDL: " << SDL_GetError() << llendl; + LL_WARNS() << "createContext: fullscreen creation failure. SDL: " << SDL_GetError() << LL_ENDL; // No fullscreen support mFullscreen = FALSE; mFullscreenWidth = -1; @@ -618,7 +618,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B if (height == 0) width = 768; - llinfos << "createContext: creating window " << width << "x" << height << "x" << bits << llendl; + LL_INFOS() << "createContext: creating window " << width << "x" << height << "x" << bits << LL_ENDL; mWindow = SDL_SetVideoMode(width, height, bits, sdlflags); if (!mWindow && bits > 16) { @@ -628,13 +628,13 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B if (!mWindow) { - llwarns << "createContext: window creation failure. SDL: " << SDL_GetError() << llendl; + LL_WARNS() << "createContext: window creation failure. SDL: " << SDL_GetError() << LL_ENDL; setupFailure("Window creation error", "Error", OSMB_OK); return FALSE; } } else if (!mFullscreen && (mWindow != NULL)) { - llinfos << "createContext: SKIPPING - !fullscreen, but +mWindow " << width << "x" << height << "x" << bits << llendl; + LL_INFOS() << "createContext: SKIPPING - !fullscreen, but +mWindow " << width << "x" << height << "x" << bits << LL_ENDL; } // Detect video memory size. @@ -642,7 +642,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024; if (gGLManager.mVRAM != 0) { - llinfos << "X11 log-parser detected " << gGLManager.mVRAM << "MB VRAM." << llendl; + LL_INFOS() << "X11 log-parser detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; } else # endif // LL_X11 { @@ -652,7 +652,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B gGLManager.mVRAM = video_info->video_mem / 1024; if (gGLManager.mVRAM != 0) { - llinfos << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << llendl; + LL_INFOS() << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; } } // If VRAM is not detected, that is handled later @@ -670,13 +670,13 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B glGetIntegerv(GL_DEPTH_BITS, &depthBits); glGetIntegerv(GL_STENCIL_BITS, &stencilBits); - llinfos << "GL buffer:" << llendl; - llinfos << " Red Bits " << S32(redBits) << llendl; - llinfos << " Green Bits " << S32(greenBits) << llendl; - llinfos << " Blue Bits " << S32(blueBits) << llendl; - llinfos << " Alpha Bits " << S32(alphaBits) << llendl; - llinfos << " Depth Bits " << S32(depthBits) << llendl; - llinfos << " Stencil Bits " << S32(stencilBits) << llendl; + LL_INFOS() << "GL buffer:" << LL_ENDL; + LL_INFOS() << " Red Bits " << S32(redBits) << LL_ENDL; + LL_INFOS() << " Green Bits " << S32(greenBits) << LL_ENDL; + LL_INFOS() << " Blue Bits " << S32(blueBits) << LL_ENDL; + LL_INFOS() << " Alpha Bits " << S32(alphaBits) << LL_ENDL; + LL_INFOS() << " Depth Bits " << S32(depthBits) << LL_ENDL; + LL_INFOS() << " Stencil Bits " << S32(stencilBits) << LL_ENDL; GLint colorBits = redBits + greenBits + blueBits + alphaBits; // fixme: actually, it's REALLY important for picking that we get at @@ -741,14 +741,14 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B } else { - llwarns << "We're not running under X11? Wild." - << llendl; + LL_WARNS() << "We're not running under X11? Wild." + << LL_ENDL; } } else { - llwarns << "We're not running under any known WM. Wild." - << llendl; + LL_WARNS() << "We're not running under any known WM. Wild." + << LL_ENDL; } #endif // LL_X11 @@ -759,7 +759,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B // We need to do this here, once video is init'd if (-1 == SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL)) - llwarns << "Couldn't enable key-repeat: " << SDL_GetError() <<llendl; + LL_WARNS() << "Couldn't enable key-repeat: " << SDL_GetError() <<LL_ENDL; // Don't need to get the current gamma, since there's a call that restores it to the system defaults. return TRUE; @@ -772,7 +772,7 @@ BOOL LLWindowSDL::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL const BOOL needsRebuild = TRUE; // Just nuke the context and start over. BOOL result = true; - llinfos << "switchContext, fullscreen=" << fullscreen << llendl; + LL_INFOS() << "switchContext, fullscreen=" << fullscreen << LL_ENDL; stop_glerror(); if(needsRebuild) { @@ -795,7 +795,7 @@ BOOL LLWindowSDL::switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL void LLWindowSDL::destroyContext() { - llinfos << "destroyContext begins" << llendl; + LL_INFOS() << "destroyContext begins" << LL_ENDL; #if LL_X11 mSDL_Display = NULL; @@ -805,9 +805,9 @@ void LLWindowSDL::destroyContext() #endif // LL_X11 // Clean up remaining GL state before blowing away window - llinfos << "shutdownGL begins" << llendl; + LL_INFOS() << "shutdownGL begins" << LL_ENDL; gGLManager.shutdownGL(); - llinfos << "SDL_QuitSS/VID begins" << llendl; + LL_INFOS() << "SDL_QuitSS/VID begins" << LL_ENDL; SDL_QuitSubSystem(SDL_INIT_VIDEO); // *FIX: this might be risky... mWindow = NULL; @@ -956,7 +956,7 @@ BOOL LLWindowSDL::setPosition(const LLCoordScreen position) { if(mWindow) { - // *FIX: (???) + // *FIX: (?) //MacMoveWindow(mWindow, position.mX, position.mY, false); } @@ -1081,12 +1081,12 @@ BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position) return FALSE; } - //llinfos << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << llendl; + //LL_INFOS() << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << LL_ENDL; // do the actual forced cursor move. SDL_WarpMouse(screen_pos.mX, screen_pos.mY); - //llinfos << llformat("llcw %d,%d -> scr %d,%d", position.mX, position.mY, screen_pos.mX, screen_pos.mY) << llendl; + //LL_INFOS() << llformat("llcw %d,%d -> scr %d,%d", position.mX, position.mY, screen_pos.mX, screen_pos.mY) << LL_ENDL; return result; } @@ -1171,7 +1171,7 @@ void LLWindowSDL::beforeDialog() running_x11 = (mSDL_XWindowID != None); #endif //LL_X11 - llinfos << "LLWindowSDL::beforeDialog()" << llendl; + LL_INFOS() << "LLWindowSDL::beforeDialog()" << LL_ENDL; if (SDLReallyCaptureInput(FALSE)) // must ungrab input so popup works! { @@ -1214,7 +1214,7 @@ void LLWindowSDL::afterDialog() running_x11 = (mSDL_XWindowID != None); #endif //LL_X11 - llinfos << "LLWindowSDL::afterDialog()" << llendl; + LL_INFOS() << "LLWindowSDL::afterDialog()" << LL_ENDL; maybe_unlock_display(); @@ -1238,7 +1238,7 @@ void LLWindowSDL::x11_set_urgent(BOOL urgent) { XWMHints *wm_hints; - llinfos << "X11 hint for urgency, " << urgent << llendl; + LL_INFOS() << "X11 hint for urgency, " << urgent << LL_ENDL; maybe_lock_display(); wm_hints = XGetWMHints(mSDL_Display, mSDL_XWindowID); @@ -1261,9 +1261,9 @@ void LLWindowSDL::x11_set_urgent(BOOL urgent) void LLWindowSDL::flashIcon(F32 seconds) { #if !LL_X11 - llinfos << "Stub LLWindowSDL::flashIcon(" << seconds << ")" << llendl; + LL_INFOS() << "Stub LLWindowSDL::flashIcon(" << seconds << ")" << LL_ENDL; #else - llinfos << "X11 LLWindowSDL::flashIcon(" << seconds << ")" << llendl; + LL_INFOS() << "X11 LLWindowSDL::flashIcon(" << seconds << ")" << LL_ENDL; F32 remaining_time = mFlashTimer.getRemainingTimeF32(); if (remaining_time < seconds) @@ -1530,7 +1530,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) if (mReallyCapturedCount < 0) // yuck, imbalance. { mReallyCapturedCount = 0; - llwarns << "ReallyCapture count was < 0" << llendl; + LL_WARNS() << "ReallyCapture count was < 0" << LL_ENDL; } if (!mFullscreen) /* only bother if we're windowed anyway */ @@ -1550,7 +1550,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) int result; if (wantmode == SDL_GRAB_ON) { - //llinfos << "X11 POINTER GRABBY" << llendl; + //LL_INFOS() << "X11 POINTER GRABBY" << LL_ENDL; //newmode = SDL_WM_GrabInput(wantmode); maybe_lock_display(); result = XGrabPointer(mSDL_Display, mSDL_XWindowID, @@ -1564,7 +1564,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) newmode = SDL_GRAB_OFF; } else if (wantmode == SDL_GRAB_OFF) { - //llinfos << "X11 POINTER UNGRABBY" << llendl; + //LL_INFOS() << "X11 POINTER UNGRABBY" << LL_ENDL; newmode = SDL_GRAB_OFF; //newmode = SDL_WM_GrabInput(SDL_GRAB_OFF); @@ -1625,7 +1625,7 @@ U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain) else mGrabbyKeyFlags &= ~mask; - //llinfos << "mGrabbyKeyFlags=" << mGrabbyKeyFlags << llendl; + //LL_INFOS() << "mGrabbyKeyFlags=" << mGrabbyKeyFlags << LL_ENDL; /* 0 means we don't need to mousegrab, otherwise grab. */ return mGrabbyKeyFlags; @@ -1655,7 +1655,7 @@ void check_vm_bloat() res = getdelim(&ptr, &dummy, ' ', fp); if (-1 == res) { - llwarns << "Unable to parse " << STATS_FILE << llendl; + LL_WARNS() << "Unable to parse " << STATS_FILE << LL_ENDL; goto finally; } free(ptr); @@ -1666,7 +1666,7 @@ void check_vm_bloat() llassert(ptr); if (-1 == res) { - llwarns << "Unable to parse " << STATS_FILE << llendl; + LL_WARNS() << "Unable to parse " << STATS_FILE << LL_ENDL; goto finally; } this_vm_size = atoll(ptr); @@ -1677,25 +1677,25 @@ void check_vm_bloat() llassert(ptr); if (-1 == res) { - llwarns << "Unable to parse " << STATS_FILE << llendl; + LL_WARNS() << "Unable to parse " << STATS_FILE << LL_ENDL; goto finally; } this_rss_size = getpagesize() * atoll(ptr); free(ptr); ptr = NULL; - llinfos << "VM SIZE IS NOW " << (this_vm_size/(1024*1024)) << " MB, RSS SIZE IS NOW " << (this_rss_size/(1024*1024)) << " MB" << llendl; + LL_INFOS() << "VM SIZE IS NOW " << (this_vm_size/(1024*1024)) << " MB, RSS SIZE IS NOW " << (this_rss_size/(1024*1024)) << " MB" << LL_ENDL; if (llabs(last_vm_size - this_vm_size) > significant_vm_difference) { if (this_vm_size > last_vm_size) { - llwarns << "VM size grew by " << (this_vm_size - last_vm_size)/(1024*1024) << " MB in last frame" << llendl; + LL_WARNS() << "VM size grew by " << (this_vm_size - last_vm_size)/(1024*1024) << " MB in last frame" << LL_ENDL; } else { - llinfos << "VM size shrank by " << (last_vm_size - this_vm_size)/(1024*1024) << " MB in last frame" << llendl; + LL_INFOS() << "VM size shrank by " << (last_vm_size - this_vm_size)/(1024*1024) << " MB in last frame" << LL_ENDL; } } @@ -1704,11 +1704,11 @@ void check_vm_bloat() { if (this_rss_size > last_rss_size) { - llwarns << "RSS size grew by " << (this_rss_size - last_rss_size)/(1024*1024) << " MB in last frame" << llendl; + LL_WARNS() << "RSS size grew by " << (this_rss_size - last_rss_size)/(1024*1024) << " MB in last frame" << LL_ENDL; } else { - llinfos << "RSS size shrank by " << (last_rss_size - this_rss_size)/(1024*1024) << " MB in last frame" << llendl; + LL_INFOS() << "RSS size shrank by " << (last_rss_size - this_rss_size)/(1024*1024) << " MB in last frame" << LL_ENDL; } } @@ -1905,8 +1905,8 @@ void LLWindowSDL::gatherInput() case SDL_VIDEORESIZE: // *FIX: handle this? { - llinfos << "Handling a resize event: " << event.resize.w << - "x" << event.resize.h << llendl; + LL_INFOS() << "Handling a resize event: " << event.resize.w << + "x" << event.resize.h << LL_ENDL; S32 width = llmax(event.resize.w, (S32)mMinWindowWidth); S32 height = llmax(event.resize.h, (S32)mMinWindowHeight); @@ -1916,7 +1916,7 @@ void LLWindowSDL::gatherInput() if (!mWindow) { // *FIX: More informative dialog? - llinfos << "Could not recreate context after resize! Quitting..." << llendl; + LL_INFOS() << "Could not recreate context after resize! Quitting..." << LL_ENDL; if(mCallbacks->handleCloseRequest(this)) { // Get the app to initiate cleanup. @@ -1957,11 +1957,11 @@ void LLWindowSDL::gatherInput() mIsMinimized = (!event.active.gain); mCallbacks->handleActivate(this, !mIsMinimized); - llinfos << "SDL deiconification state switched to " << BOOL(event.active.gain) << llendl; + LL_INFOS() << "SDL deiconification state switched to " << BOOL(event.active.gain) << LL_ENDL; } else { - llinfos << "Ignored bogus redundant SDL deiconification state switch to " << BOOL(event.active.gain) << llendl; + LL_INFOS() << "Ignored bogus redundant SDL deiconification state switch to " << BOOL(event.active.gain) << LL_ENDL; } } break; @@ -1975,7 +1975,7 @@ void LLWindowSDL::gatherInput() } break; default: - //llinfos << "Unhandled SDL event type " << event.type << llendl; + //LL_INFOS() << "Unhandled SDL event type " << event.type << LL_ENDL; break; } } @@ -2003,8 +2003,8 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty if (bmpsurface && bmpsurface->w%8==0) { SDL_Surface *cursurface; - lldebugs << "Loaded cursor file " << filename << " " - << bmpsurface->w << "x" << bmpsurface->h << llendl; + LL_DEBUGS() << "Loaded cursor file " << filename << " " + << bmpsurface->w << "x" << bmpsurface->h << LL_ENDL; cursurface = SDL_CreateRGBSurface (SDL_SWSURFACE, bmpsurface->w, bmpsurface->h, @@ -2056,12 +2056,12 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty delete[] cursor_data; delete[] cursor_mask; } else { - llwarns << "CURSOR BLIT FAILURE, cursurface: " << cursurface << llendl; + LL_WARNS() << "CURSOR BLIT FAILURE, cursurface: " << cursurface << LL_ENDL; } SDL_FreeSurface(cursurface); SDL_FreeSurface(bmpsurface); } else { - llwarns << "CURSOR LOAD FAILURE " << filename << llendl; + LL_WARNS() << "CURSOR LOAD FAILURE " << filename << LL_ENDL; } return sdlcursor; @@ -2087,7 +2087,7 @@ void LLWindowSDL::updateCursor() if (sdlcursor) SDL_SetCursor(sdlcursor); } else { - llwarns << "Tried to set invalid cursor number " << mNextCursor << llendl; + LL_WARNS() << "Tried to set invalid cursor number " << mNextCursor << LL_ENDL; } mCurrentCursor = mNextCursor; } @@ -2149,7 +2149,7 @@ void LLWindowSDL::initCursors() mSDLCursors[UI_CURSOR_TOOLNO] = makeSDLCursorFromBMP("llno.BMP",8,8); if (getenv("LL_ATI_MOUSE_CURSOR_BUG") != NULL) { - llinfos << "Disabling cursor updating due to LL_ATI_MOUSE_CURSOR_BUG" << llendl; + LL_INFOS() << "Disabling cursor updating due to LL_ATI_MOUSE_CURSOR_BUG" << LL_ENDL; ATIbug = true; } } @@ -2170,7 +2170,7 @@ void LLWindowSDL::quitCursors() } else { // SDL doesn't refcount cursors, so if the window has // already been destroyed then the cursors have gone with it. - llinfos << "Skipping quitCursors: mWindow already gone." << llendl; + LL_INFOS() << "Skipping quitCursors: mWindow already gone." << LL_ENDL; for (i=0; i<UI_CURSOR_COUNT; ++i) mSDLCursors[i] = NULL; } @@ -2181,31 +2181,31 @@ void LLWindowSDL::captureMouse() // SDL already enforces the semantics that captureMouse is // used for, i.e. that we continue to get mouse events as long // as a button is down regardless of whether we left the - // window, and in a less obnoxious way than SDL_WM_GrabInput + // window, and in a less obnoxious way than SDL_WM_GrabInput // which would confine the cursor to the window too. - lldebugs << "LLWindowSDL::captureMouse" << llendl; + LL_DEBUGS() << "LLWindowSDL::captureMouse" << LL_ENDL; } void LLWindowSDL::releaseMouse() { // see LWindowSDL::captureMouse() - lldebugs << "LLWindowSDL::releaseMouse" << llendl; + LL_DEBUGS() << "LLWindowSDL::releaseMouse" << LL_ENDL; } void LLWindowSDL::hideCursor() { if(!mCursorHidden) { - // llinfos << "hideCursor: hiding" << llendl; + // LL_INFOS() << "hideCursor: hiding" << LL_ENDL; mCursorHidden = TRUE; mHideCursorPermanent = TRUE; SDL_ShowCursor(0); } else { - // llinfos << "hideCursor: already hidden" << llendl; + // LL_INFOS() << "hideCursor: already hidden" << LL_ENDL; } } @@ -2213,14 +2213,14 @@ void LLWindowSDL::showCursor() { if(mCursorHidden) { - // llinfos << "showCursor: showing" << llendl; + // LL_INFOS() << "showCursor: showing" << LL_ENDL; mCursorHidden = FALSE; mHideCursorPermanent = FALSE; SDL_ShowCursor(1); } else { - // llinfos << "showCursor: already visible" << llendl; + // LL_INFOS() << "showCursor: already visible" << LL_ENDL; } } @@ -2291,7 +2291,7 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ { GtkWidget *win = NULL; - llinfos << "Creating a dialog because we're in windowed mode and GTK is happy." << llendl; + LL_INFOS() << "Creating a dialog because we're in windowed mode and GTK is happy." << LL_ENDL; GtkDialogFlags flags = GTK_DIALOG_MODAL; GtkMessageType messagetype; @@ -2350,7 +2350,7 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ gtk_widget_show_all (win); gtk_main(); - //llinfos << "response: " << response << llendl; + //LL_INFOS() << "response: " << response << LL_ENDL; switch (response) { case GTK_RESPONSE_OK: rtn = OSBTN_OK; break; @@ -2366,8 +2366,8 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ } else { - llinfos << "MSGBOX: " << caption << ": " << text << llendl; - llinfos << "Skipping dialog because we're in fullscreen mode or GTK is not happy." << llendl; + LL_INFOS() << "MSGBOX: " << caption << ": " << text << LL_ENDL; + LL_INFOS() << "Skipping dialog because we're in fullscreen mode or GTK is not happy." << LL_ENDL; rtn = OSBTN_OK; } @@ -2493,7 +2493,7 @@ BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) #else S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 type) { - llinfos << "MSGBOX: " << caption << ": " << text << llendl; + LL_INFOS() << "MSGBOX: " << caption << ": " << text << LL_ENDL; return 0; } @@ -2521,7 +2521,7 @@ void exec_cmd(const std::string& cmd, const std::string& arg) // end ourself by running the command execv(cmd.c_str(), argv); /* Flawfinder: ignore */ // if execv returns at all, there was a problem. - llwarns << "execv failure when trying to start " << cmd << llendl; + LL_WARNS() << "execv failure when trying to start " << cmd << LL_ENDL; _exit(1); // _exit because we don't want atexit() clean-up! } else { if (pid > 0) @@ -2530,7 +2530,7 @@ void exec_cmd(const std::string& cmd, const std::string& arg) int childExitStatus; waitpid(pid, &childExitStatus, 0); } else { - llwarns << "fork failure." << llendl; + LL_WARNS() << "fork failure." << LL_ENDL; } } } @@ -2553,11 +2553,11 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) if (!found) { - llwarns << "spawn_web_browser called for url with protocol not on whitelist: " << escaped_url << llendl; + LL_WARNS() << "spawn_web_browser called for url with protocol not on whitelist: " << escaped_url << LL_ENDL; return; } - llinfos << "spawn_web_browser: " << escaped_url << llendl; + LL_INFOS() << "spawn_web_browser: " << escaped_url << LL_ENDL; #if LL_LINUX || LL_SOLARIS # if LL_X11 @@ -2580,7 +2580,7 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) exec_cmd(cmd, arg); #endif // LL_LINUX || LL_SOLARIS - llinfos << "spawn_web_browser returning." << llendl; + LL_INFOS() << "spawn_web_browser returning." << LL_ENDL; } @@ -2615,7 +2615,7 @@ void LLWindowSDL::bringToFront() { // This is currently used when we are 'launched' to a specific // map position externally. - llinfos << "bringToFront" << llendl; + LL_INFOS() << "bringToFront" << LL_ENDL; #if LL_X11 if (mSDL_Display && !mFullscreen) { @@ -2650,7 +2650,7 @@ std::vector<std::string> LLWindowSDL::getDynamicFallbackFontList() FcFontSet *fs = NULL; FcPattern *sortpat = NULL; - llinfos << "Getting system font list from FontConfig..." << llendl; + LL_INFOS() << "Getting system font list from FontConfig..." << LL_ENDL; // If the user has a system-wide language preference, then favor // fonts from that language group. This doesn't affect the types @@ -2667,9 +2667,9 @@ std::vector<std::string> LLWindowSDL::getDynamicFallbackFontList() LL_INFOS("AppInit") << "Location " << locale->country << LL_ENDL; LL_INFOS("AppInit") << "Variant " << locale->variant << LL_ENDL; - llinfos << "Preferring fonts of language: " + LL_INFOS() << "Preferring fonts of language: " << locale->lang - << llendl; + << LL_ENDL; sort_order = "lang=" + std::string(locale->lang) + ":" + sort_order; } @@ -2678,7 +2678,7 @@ std::vector<std::string> LLWindowSDL::getDynamicFallbackFontList() if (!FcInit()) { - llwarns << "FontConfig failed to initialize." << llendl; + LL_WARNS() << "FontConfig failed to initialize." << LL_ENDL; rtns.push_back(final_fallback); return rtns; } @@ -2715,14 +2715,14 @@ std::vector<std::string> LLWindowSDL::getDynamicFallbackFontList() FcFontSetDestroy (fs); } - lldebugs << "Using font list: " << llendl; + LL_DEBUGS() << "Using font list: " << LL_ENDL; for (std::vector<std::string>::iterator it = rtns.begin(); it != rtns.end(); ++it) { - lldebugs << " file: " << *it << llendl; + LL_DEBUGS() << " file: " << *it << LL_ENDL; } - llinfos << "Using " << rtns.size() << "/" << found_font_count << " system fonts." << llendl; + LL_INFOS() << "Using " << rtns.size() << "/" << found_font_count << " system fonts." << LL_ENDL; rtns.push_back(final_fallback); return rtns; diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 30f5526500..cd2be87fad 100755 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -38,6 +38,7 @@ // Linden library includes #include "llerror.h" +#include "llfasttimer.h" #include "llgl.h" #include "llstring.h" #include "lldir.h" @@ -85,6 +86,18 @@ void show_window_creation_error(const std::string& title) LL_WARNS("Window") << title << LL_ENDL; } +HGLRC SafeCreateContext(HDC hdc) +{ + __try + { + return wglCreateContext(hdc); + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + return NULL; + } +} + //static BOOL LLWindowWin32::sIsClassRegistered = FALSE; @@ -202,7 +215,7 @@ LLWinImm::LLWinImm() : mHImmDll(NULL) // the case, since it is very unusual; these APIs are available from // the beginning, and all versions of IMM32.DLL should have them all. // Unfortunately, this code may be executed before initialization of - // the logging channel (llwarns), and we can't do it here... Yes, this + // the logging channel (LL_WARNS()), and we can't do it here... Yes, this // is one of disadvantages to use static constraction to DLL loading. FreeLibrary(mHImmDll); mHImmDll = NULL; @@ -656,7 +669,7 @@ LLWindowWin32::~LLWindowWin32() delete [] mSupportedResolutions; mSupportedResolutions = NULL; - delete mWindowClassName; + delete [] mWindowClassName; mWindowClassName = NULL; } @@ -1056,7 +1069,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO mhInstance, NULL); - LL_INFOS("Window") << "window is created." << llendl ; + LL_INFOS("Window") << "window is created." << LL_ENDL ; //----------------------------------------------------------------------- // Create GL drawing context @@ -1089,7 +1102,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO return FALSE; } - LL_INFOS("Window") << "Device context retrieved." << llendl ; + LL_INFOS("Window") << "Device context retrieved." << LL_ENDL ; if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd))) { @@ -1099,7 +1112,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO return FALSE; } - LL_INFOS("Window") << "Pixel format chosen." << llendl ; + LL_INFOS("Window") << "Pixel format chosen." << LL_ENDL ; // Verify what pixel format we actually received. if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), @@ -1112,35 +1125,35 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO } // (EXP-1765) dump pixel data to see if there is a pattern that leads to unreproducible crash - LL_INFOS("Window") << "--- begin pixel format dump ---" << llendl ; - LL_INFOS("Window") << "pixel_format is " << pixel_format << llendl ; - LL_INFOS("Window") << "pfd.nSize: " << pfd.nSize << llendl ; - LL_INFOS("Window") << "pfd.nVersion: " << pfd.nVersion << llendl ; - LL_INFOS("Window") << "pfd.dwFlags: 0x" << std::hex << pfd.dwFlags << std::dec << llendl ; - LL_INFOS("Window") << "pfd.iPixelType: " << (int)pfd.iPixelType << llendl ; - LL_INFOS("Window") << "pfd.cColorBits: " << (int)pfd.cColorBits << llendl ; - LL_INFOS("Window") << "pfd.cRedBits: " << (int)pfd.cRedBits << llendl ; - LL_INFOS("Window") << "pfd.cRedShift: " << (int)pfd.cRedShift << llendl ; - LL_INFOS("Window") << "pfd.cGreenBits: " << (int)pfd.cGreenBits << llendl ; - LL_INFOS("Window") << "pfd.cGreenShift: " << (int)pfd.cGreenShift << llendl ; - LL_INFOS("Window") << "pfd.cBlueBits: " << (int)pfd.cBlueBits << llendl ; - LL_INFOS("Window") << "pfd.cBlueShift: " << (int)pfd.cBlueShift << llendl ; - LL_INFOS("Window") << "pfd.cAlphaBits: " << (int)pfd.cAlphaBits << llendl ; - LL_INFOS("Window") << "pfd.cAlphaShift: " << (int)pfd.cAlphaShift << llendl ; - LL_INFOS("Window") << "pfd.cAccumBits: " << (int)pfd.cAccumBits << llendl ; - LL_INFOS("Window") << "pfd.cAccumRedBits: " << (int)pfd.cAccumRedBits << llendl ; - LL_INFOS("Window") << "pfd.cAccumGreenBits: " << (int)pfd.cAccumGreenBits << llendl ; - LL_INFOS("Window") << "pfd.cAccumBlueBits: " << (int)pfd.cAccumBlueBits << llendl ; - LL_INFOS("Window") << "pfd.cAccumAlphaBits: " << (int)pfd.cAccumAlphaBits << llendl ; - LL_INFOS("Window") << "pfd.cDepthBits: " << (int)pfd.cDepthBits << llendl ; - LL_INFOS("Window") << "pfd.cStencilBits: " << (int)pfd.cStencilBits << llendl ; - LL_INFOS("Window") << "pfd.cAuxBuffers: " << (int)pfd.cAuxBuffers << llendl ; - LL_INFOS("Window") << "pfd.iLayerType: " << (int)pfd.iLayerType << llendl ; - LL_INFOS("Window") << "pfd.bReserved: " << (int)pfd.bReserved << llendl ; - LL_INFOS("Window") << "pfd.dwLayerMask: " << pfd.dwLayerMask << llendl ; - LL_INFOS("Window") << "pfd.dwVisibleMask: " << pfd.dwVisibleMask << llendl ; - LL_INFOS("Window") << "pfd.dwDamageMask: " << pfd.dwDamageMask << llendl ; - LL_INFOS("Window") << "--- end pixel format dump ---" << llendl ; + LL_INFOS("Window") << "--- begin pixel format dump ---" << LL_ENDL ; + LL_INFOS("Window") << "pixel_format is " << pixel_format << LL_ENDL ; + LL_INFOS("Window") << "pfd.nSize: " << pfd.nSize << LL_ENDL ; + LL_INFOS("Window") << "pfd.nVersion: " << pfd.nVersion << LL_ENDL ; + LL_INFOS("Window") << "pfd.dwFlags: 0x" << std::hex << pfd.dwFlags << std::dec << LL_ENDL ; + LL_INFOS("Window") << "pfd.iPixelType: " << (int)pfd.iPixelType << LL_ENDL ; + LL_INFOS("Window") << "pfd.cColorBits: " << (int)pfd.cColorBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cRedBits: " << (int)pfd.cRedBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cRedShift: " << (int)pfd.cRedShift << LL_ENDL ; + LL_INFOS("Window") << "pfd.cGreenBits: " << (int)pfd.cGreenBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cGreenShift: " << (int)pfd.cGreenShift << LL_ENDL ; + LL_INFOS("Window") << "pfd.cBlueBits: " << (int)pfd.cBlueBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cBlueShift: " << (int)pfd.cBlueShift << LL_ENDL ; + LL_INFOS("Window") << "pfd.cAlphaBits: " << (int)pfd.cAlphaBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cAlphaShift: " << (int)pfd.cAlphaShift << LL_ENDL ; + LL_INFOS("Window") << "pfd.cAccumBits: " << (int)pfd.cAccumBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cAccumRedBits: " << (int)pfd.cAccumRedBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cAccumGreenBits: " << (int)pfd.cAccumGreenBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cAccumBlueBits: " << (int)pfd.cAccumBlueBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cAccumAlphaBits: " << (int)pfd.cAccumAlphaBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cDepthBits: " << (int)pfd.cDepthBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cStencilBits: " << (int)pfd.cStencilBits << LL_ENDL ; + LL_INFOS("Window") << "pfd.cAuxBuffers: " << (int)pfd.cAuxBuffers << LL_ENDL ; + LL_INFOS("Window") << "pfd.iLayerType: " << (int)pfd.iLayerType << LL_ENDL ; + LL_INFOS("Window") << "pfd.bReserved: " << (int)pfd.bReserved << LL_ENDL ; + LL_INFOS("Window") << "pfd.dwLayerMask: " << pfd.dwLayerMask << LL_ENDL ; + LL_INFOS("Window") << "pfd.dwVisibleMask: " << pfd.dwVisibleMask << LL_ENDL ; + LL_INFOS("Window") << "pfd.dwDamageMask: " << pfd.dwDamageMask << LL_ENDL ; + LL_INFOS("Window") << "--- end pixel format dump ---" << LL_ENDL ; if (pfd.cColorBits < 32) { @@ -1166,14 +1179,15 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO return FALSE; } - if (!(mhRC = wglCreateContext(mhDC))) + + if (!(mhRC = SafeCreateContext(mhDC))) { close(); OSMessageBox(mCallbacks->translateString("MBGLContextErr"), mCallbacks->translateString("MBError"), OSMB_OK); return FALSE; } - + if (!wglMakeCurrent(mhDC, mhRC)) { close(); @@ -1182,7 +1196,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO return FALSE; } - LL_INFOS("Window") << "Drawing context is created." << llendl ; + LL_INFOS("Window") << "Drawing context is created." << LL_ENDL ; gGLManager.initWGL(); @@ -1239,7 +1253,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO while(!result && mFSAASamples > 0) { - llwarns << "FSAASamples: " << mFSAASamples << " not supported." << llendl ; + LL_WARNS() << "FSAASamples: " << mFSAASamples << " not supported." << LL_ENDL ; mFSAASamples /= 2 ; //try to decrease sample pixel number until to disable anti-aliasing if(mFSAASamples < 2) @@ -1261,13 +1275,13 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO if(result) { - llwarns << "Only support FSAASamples: " << mFSAASamples << llendl ; + LL_WARNS() << "Only support FSAASamples: " << mFSAASamples << LL_ENDL ; } } if (!result) { - llwarns << "mFSAASamples: " << mFSAASamples << llendl ; + LL_WARNS() << "mFSAASamples: " << mFSAASamples << LL_ENDL ; close(); show_window_creation_error("Error after wglChoosePixelFormatARB 32-bit"); @@ -1320,7 +1334,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO LL_INFOS("Window") << "Choosing pixel formats: " << num_formats << " pixel formats returned" << LL_ENDL; } - LL_INFOS("Window") << "pixel formats done." << llendl ; + LL_INFOS("Window") << "pixel formats done." << LL_ENDL ; S32 swap_method = 0; S32 cur_format = num_formats-1; @@ -1370,7 +1384,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO mhInstance, NULL); - LL_INFOS("Window") << "recreate window done." << llendl ; + LL_INFOS("Window") << "recreate window done." << LL_ENDL ; if (!(mhDC = GetDC(mWindowHandle))) { @@ -1479,8 +1493,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO } else { - llinfos << "Created OpenGL " << llformat("%d.%d", attribs[1], attribs[3]) << - (LLRender::sGLCoreProfile ? " core" : " compatibility") << " context." << llendl; + LL_INFOS() << "Created OpenGL " << llformat("%d.%d", attribs[1], attribs[3]) << + (LLRender::sGLCoreProfile ? " core" : " compatibility") << " context." << LL_ENDL; done = true; if (LLRender::sGLCoreProfile) @@ -1822,8 +1836,8 @@ void LLWindowWin32::gatherInput() mMousePositionModified = FALSE; } -static LLFastTimer::DeclareTimer FTM_KEYHANDLER("Handle Keyboard"); -static LLFastTimer::DeclareTimer FTM_MOUSEHANDLER("Handle Mouse"); +static LLTrace::BlockTimerStatHandle FTM_KEYHANDLER("Handle Keyboard"); +static LLTrace::BlockTimerStatHandle FTM_MOUSEHANDLER("Handle Mouse"); LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_param, LPARAM l_param) { @@ -1831,6 +1845,10 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // This helps prevent avatar walking after maximizing the window by double-clicking the title bar. static bool sHandleLeftMouseUp = true; + // Ignore the double click received right after activating app. + // This is to avoid triggering double click teleport after returning focus (see MAINT-3786). + static bool sHandleDoubleClick = true; + LLWindowWin32 *window_imp = (LLWindowWin32 *)GetWindowLong(h_wnd, GWL_USERDATA); @@ -1877,8 +1895,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_DEVICECHANGE"); if (gDebugWindowProc) { - llinfos << " WM_DEVICECHANGE: wParam=" << w_param - << "; lParam=" << l_param << llendl; + LL_INFOS() << " WM_DEVICECHANGE: wParam=" << w_param + << "; lParam=" << l_param << LL_ENDL; } if (w_param == DBT_DEVNODES_CHANGED || w_param == DBT_DEVICEARRIVAL) { @@ -1958,6 +1976,11 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ } } + if (!activating) + { + sHandleDoubleClick = false; + } + window_imp->mCallbacks->handleActivateApp(window_imp, activating); break; @@ -2069,7 +2092,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mKeyVirtualKey = w_param; window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_KEYUP"); - LLFastTimer t2(FTM_KEYHANDLER); + LL_RECORD_BLOCK_TIME(FTM_KEYHANDLER); if (gDebugWindowProc) { @@ -2089,7 +2112,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_SETCONTEXT"); if (gDebugWindowProc) { - llinfos << "WM_IME_SETCONTEXT" << llendl; + LL_INFOS() << "WM_IME_SETCONTEXT" << LL_ENDL; } if (LLWinImm::isAvailable() && window_imp->mPreeditor) { @@ -2102,7 +2125,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_STARTCOMPOSITION"); if (gDebugWindowProc) { - llinfos << "WM_IME_STARTCOMPOSITION" << llendl; + LL_INFOS() << "WM_IME_STARTCOMPOSITION" << LL_ENDL; } if (LLWinImm::isAvailable() && window_imp->mPreeditor) { @@ -2115,7 +2138,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_ENDCOMPOSITION"); if (gDebugWindowProc) { - llinfos << "WM_IME_ENDCOMPOSITION" << llendl; + LL_INFOS() << "WM_IME_ENDCOMPOSITION" << LL_ENDL; } if (LLWinImm::isAvailable() && window_imp->mPreeditor) { @@ -2127,7 +2150,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_COMPOSITION"); if (gDebugWindowProc) { - llinfos << "WM_IME_COMPOSITION" << llendl; + LL_INFOS() << "WM_IME_COMPOSITION" << LL_ENDL; } if (LLWinImm::isAvailable() && window_imp->mPreeditor) { @@ -2140,7 +2163,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_IME_REQUEST"); if (gDebugWindowProc) { - llinfos << "WM_IME_REQUEST" << llendl; + LL_INFOS() << "WM_IME_REQUEST" << LL_ENDL; } if (LLWinImm::isAvailable() && window_imp->mPreeditor) { @@ -2182,13 +2205,14 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_NCLBUTTONDOWN"); // A click in a non-client area, e.g. title bar or window border. sHandleLeftMouseUp = false; + sHandleDoubleClick = true; } break; case WM_LBUTTONDOWN: { window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_LBUTTONDOWN"); - LLFastTimer t2(FTM_MOUSEHANDLER); + LL_RECORD_BLOCK_TIME(FTM_MOUSEHANDLER); sHandleLeftMouseUp = true; if (LLWinImm::isAvailable() && window_imp->mPreeditor) @@ -2226,6 +2250,13 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ //case WM_RBUTTONDBLCLK: { window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_LBUTTONDBLCLK"); + + if (!sHandleDoubleClick) + { + sHandleDoubleClick = true; + break; + } + // Because we move the cursor position in the app, we need to query // to find out where the cursor at the time the event is handled. // If we don't do this, many clicks could get buffered up, and if the @@ -2254,7 +2285,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ case WM_LBUTTONUP: { window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_LBUTTONUP"); - LLFastTimer t2(FTM_MOUSEHANDLER); + LL_RECORD_BLOCK_TIME(FTM_MOUSEHANDLER); if (!sHandleLeftMouseUp) { @@ -2295,7 +2326,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ case WM_RBUTTONDOWN: { window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_RBUTTONDOWN"); - LLFastTimer t2(FTM_MOUSEHANDLER); + LL_RECORD_BLOCK_TIME(FTM_MOUSEHANDLER); if (LLWinImm::isAvailable() && window_imp->mPreeditor) { window_imp->interruptLanguageTextInput(); @@ -2329,7 +2360,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ case WM_RBUTTONUP: { window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_RBUTTONUP"); - LLFastTimer t2(FTM_MOUSEHANDLER); + LL_RECORD_BLOCK_TIME(FTM_MOUSEHANDLER); // Because we move the cursor position in the app, we need to query // to find out where the cursor at the time the event is handled. // If we don't do this, many clicks could get buffered up, and if the @@ -2359,7 +2390,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ // case WM_MBUTTONDBLCLK: { window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MBUTTONDOWN"); - LLFastTimer t2(FTM_MOUSEHANDLER); + LL_RECORD_BLOCK_TIME(FTM_MOUSEHANDLER); if (LLWinImm::isAvailable() && window_imp->mPreeditor) { window_imp->interruptLanguageTextInput(); @@ -2393,7 +2424,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ case WM_MBUTTONUP: { window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_MBUTTONUP"); - LLFastTimer t2(FTM_MOUSEHANDLER); + LL_RECORD_BLOCK_TIME(FTM_MOUSEHANDLER); // Because we move the cursor position in the llviewer app, we need to query // to find out where the cursor at the time the event is handled. // If we don't do this, many clicks could get buffered up, and if the diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 54c9ac4d4d..169d264808 100755 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -28,9 +28,7 @@ #define LL_LLWINDOWWIN32_H // Limit Windows API to small and manageable set. -#define WIN32_LEAN_AND_MEAN -#include <winsock2.h> -#include <windows.h> +#include "llwin32headerslean.h" #include "llwindow.h" #include "llwindowcallbacks.h" |