aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llwindow/llwindowwin32.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llwindow/llwindowwin32.cpp')
-rw-r--r--linden/indra/llwindow/llwindowwin32.cpp480
1 files changed, 249 insertions, 231 deletions
diff --git a/linden/indra/llwindow/llwindowwin32.cpp b/linden/indra/llwindow/llwindowwin32.cpp
index 3f33f1a..f6beb79 100644
--- a/linden/indra/llwindow/llwindowwin32.cpp
+++ b/linden/indra/llwindow/llwindowwin32.cpp
@@ -1,4 +1,4 @@
1/** 1/**
2 * @file llwindowwin32.cpp 2 * @file llwindowwin32.cpp
3 * @brief Platform-dependent implementation of llwindow 3 * @brief Platform-dependent implementation of llwindow
4 * 4 *
@@ -103,7 +103,7 @@ LLCoordWindow LLWindowWin32::sWinIMEWindowPosition(-1,-1);
103// as a default, and we can't link against imm32.lib statically. 103// as a default, and we can't link against imm32.lib statically.
104// I believe DLL loading of this type is best suited to do 104// I believe DLL loading of this type is best suited to do
105// in a static initialization of a class. What I'm not sure is 105// in a static initialization of a class. What I'm not sure is
106// whether it follows the Linden Conding Standard... 106// whether it follows the Linden Conding Standard...
107// See http://wiki.secondlife.com/wiki/Coding_standards#Static_Members 107// See http://wiki.secondlife.com/wiki/Coding_standards#Static_Members
108 108
109class LLWinImm 109class LLWinImm
@@ -113,16 +113,16 @@ public:
113 113
114public: 114public:
115 // Wrappers for IMM API. 115 // Wrappers for IMM API.
116 static BOOL isIME(HKL hkl); 116 static BOOL isIME(HKL hkl);
117 static HWND getDefaultIMEWnd(HWND hwnd); 117 static HWND getDefaultIMEWnd(HWND hwnd);
118 static HIMC getContext(HWND hwnd); 118 static HIMC getContext(HWND hwnd);
119 static BOOL releaseContext(HWND hwnd, HIMC himc); 119 static BOOL releaseContext(HWND hwnd, HIMC himc);
120 static BOOL getOpenStatus(HIMC himc); 120 static BOOL getOpenStatus(HIMC himc);
121 static BOOL setOpenStatus(HIMC himc, BOOL status); 121 static BOOL setOpenStatus(HIMC himc, BOOL status);
122 static BOOL getConversionStatus(HIMC himc, LPDWORD conversion, LPDWORD sentence); 122 static BOOL getConversionStatus(HIMC himc, LPDWORD conversion, LPDWORD sentence);
123 static BOOL setConversionStatus(HIMC himc, DWORD conversion, DWORD sentence); 123 static BOOL setConversionStatus(HIMC himc, DWORD conversion, DWORD sentence);
124 static BOOL getCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form); 124 static BOOL getCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form);
125 static BOOL setCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form); 125 static BOOL setCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form);
126 static LONG getCompositionString(HIMC himc, DWORD index, LPVOID data, DWORD length); 126 static LONG getCompositionString(HIMC himc, DWORD index, LPVOID data, DWORD length);
127 static BOOL setCompositionString(HIMC himc, DWORD index, LPVOID pComp, DWORD compLength, LPVOID pRead, DWORD readLength); 127 static BOOL setCompositionString(HIMC himc, DWORD index, LPVOID pComp, DWORD compLength, LPVOID pRead, DWORD readLength);
128 static BOOL setCompositionFont(HIMC himc, LPLOGFONTW logfont); 128 static BOOL setCompositionFont(HIMC himc, LPLOGFONTW logfont);
@@ -160,10 +160,10 @@ LLWinImm LLWinImm::sTheInstance;
160 160
161LLWinImm::LLWinImm() : mHImmDll(NULL) 161LLWinImm::LLWinImm() : mHImmDll(NULL)
162{ 162{
163 // Check system metrics 163 // Check system metrics
164 if ( !GetSystemMetrics( SM_DBCSENABLED ) ) 164 if ( !GetSystemMetrics( SM_DBCSENABLED ) )
165 return; 165 return;
166 166
167 167
168 mHImmDll = LoadLibraryA("Imm32"); 168 mHImmDll = LoadLibraryA("Imm32");
169 if (mHImmDll != NULL) 169 if (mHImmDll != NULL)
@@ -200,13 +200,13 @@ LLWinImm::LLWinImm() : mHImmDll(NULL)
200 mImmSetCandidateWindow == NULL || 200 mImmSetCandidateWindow == NULL ||
201 mImmNotifyIME == NULL) 201 mImmNotifyIME == NULL)
202 { 202 {
203 // If any of the above API entires are not found, we can't use IMM API. 203 // If any of the above API entires are not found, we can't use IMM API.
204 // So, turn off the IMM support. We should log some warning message in 204 // So, turn off the IMM support. We should log some warning message in
205 // the case, since it is very unusual; these APIs are available from 205 // the case, since it is very unusual; these APIs are available from
206 // the beginning, and all versions of IMM32.DLL should have them all. 206 // the beginning, and all versions of IMM32.DLL should have them all.
207 // Unfortunately, this code may be executed before initialization of 207 // Unfortunately, this code may be executed before initialization of
208 // the logging channel (llwarns), and we can't do it here... Yes, this 208 // the logging channel (llwarns), and we can't do it here... Yes, this
209 // is one of disadvantages to use static constraction to DLL loading. 209 // is one of disadvantages to use static constraction to DLL loading.
210 FreeLibrary(mHImmDll); 210 FreeLibrary(mHImmDll);
211 mHImmDll = NULL; 211 mHImmDll = NULL;
212 212
@@ -231,117 +231,117 @@ LLWinImm::LLWinImm() : mHImmDll(NULL)
231} 231}
232 232
233 233
234// static 234// static
235BOOL LLWinImm::isIME(HKL hkl) 235BOOL LLWinImm::isIME(HKL hkl)
236{ 236{
237 if ( sTheInstance.mImmIsIME ) 237 if ( sTheInstance.mImmIsIME )
238 return sTheInstance.mImmIsIME(hkl); 238 return sTheInstance.mImmIsIME(hkl);
239 return FALSE; 239 return FALSE;
240} 240}
241 241
242// static 242// static
243HIMC LLWinImm::getContext(HWND hwnd) 243HIMC LLWinImm::getContext(HWND hwnd)
244{ 244{
245 if ( sTheInstance.mImmGetContext ) 245 if ( sTheInstance.mImmGetContext )
246 return sTheInstance.mImmGetContext(hwnd); 246 return sTheInstance.mImmGetContext(hwnd);
247 return 0; 247 return 0;
248} 248}
249 249
250//static 250//static
251BOOL LLWinImm::releaseContext(HWND hwnd, HIMC himc) 251BOOL LLWinImm::releaseContext(HWND hwnd, HIMC himc)
252{ 252{
253 if ( sTheInstance.mImmIsIME ) 253 if ( sTheInstance.mImmIsIME )
254 return sTheInstance.mImmReleaseContext(hwnd, himc); 254 return sTheInstance.mImmReleaseContext(hwnd, himc);
255 return FALSE; 255 return FALSE;
256} 256}
257 257
258// static 258// static
259BOOL LLWinImm::getOpenStatus(HIMC himc) 259BOOL LLWinImm::getOpenStatus(HIMC himc)
260{ 260{
261 if ( sTheInstance.mImmGetOpenStatus ) 261 if ( sTheInstance.mImmGetOpenStatus )
262 return sTheInstance.mImmGetOpenStatus(himc); 262 return sTheInstance.mImmGetOpenStatus(himc);
263 return FALSE; 263 return FALSE;
264} 264}
265 265
266// static 266// static
267BOOL LLWinImm::setOpenStatus(HIMC himc, BOOL status) 267BOOL LLWinImm::setOpenStatus(HIMC himc, BOOL status)
268{ 268{
269 if ( sTheInstance.mImmSetOpenStatus ) 269 if ( sTheInstance.mImmSetOpenStatus )
270 return sTheInstance.mImmSetOpenStatus(himc, status); 270 return sTheInstance.mImmSetOpenStatus(himc, status);
271 return FALSE; 271 return FALSE;
272} 272}
273 273
274// static 274// static
275BOOL LLWinImm::getConversionStatus(HIMC himc, LPDWORD conversion, LPDWORD sentence) 275BOOL LLWinImm::getConversionStatus(HIMC himc, LPDWORD conversion, LPDWORD sentence)
276{ 276{
277 if ( sTheInstance.mImmGetConversionStatus ) 277 if ( sTheInstance.mImmGetConversionStatus )
278 return sTheInstance.mImmGetConversionStatus(himc, conversion, sentence); 278 return sTheInstance.mImmGetConversionStatus(himc, conversion, sentence);
279 return FALSE; 279 return FALSE;
280} 280}
281 281
282// static 282// static
283BOOL LLWinImm::setConversionStatus(HIMC himc, DWORD conversion, DWORD sentence) 283BOOL LLWinImm::setConversionStatus(HIMC himc, DWORD conversion, DWORD sentence)
284{ 284{
285 if ( sTheInstance.mImmSetConversionStatus ) 285 if ( sTheInstance.mImmSetConversionStatus )
286 return sTheInstance.mImmSetConversionStatus(himc, conversion, sentence); 286 return sTheInstance.mImmSetConversionStatus(himc, conversion, sentence);
287 return FALSE; 287 return FALSE;
288} 288}
289 289
290// static 290// static
291BOOL LLWinImm::getCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form) 291BOOL LLWinImm::getCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form)
292{ 292{
293 if ( sTheInstance.mImmGetCompostitionWindow ) 293 if ( sTheInstance.mImmGetCompostitionWindow )
294 return sTheInstance.mImmGetCompostitionWindow(himc, form); 294 return sTheInstance.mImmGetCompostitionWindow(himc, form);
295 return FALSE; 295 return FALSE;
296} 296}
297 297
298// static 298// static
299BOOL LLWinImm::setCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form) 299BOOL LLWinImm::setCompositionWindow(HIMC himc, LPCOMPOSITIONFORM form)
300{ 300{
301 if ( sTheInstance.mImmSetCompostitionWindow ) 301 if ( sTheInstance.mImmSetCompostitionWindow )
302 return sTheInstance.mImmSetCompostitionWindow(himc, form); 302 return sTheInstance.mImmSetCompostitionWindow(himc, form);
303 return FALSE; 303 return FALSE;
304} 304}
305 305
306 306
307// static 307// static
308LONG LLWinImm::getCompositionString(HIMC himc, DWORD index, LPVOID data, DWORD length) 308LONG LLWinImm::getCompositionString(HIMC himc, DWORD index, LPVOID data, DWORD length)
309{ 309{
310 if ( sTheInstance.mImmGetCompositionString ) 310 if ( sTheInstance.mImmGetCompositionString )
311 return sTheInstance.mImmGetCompositionString(himc, index, data, length); 311 return sTheInstance.mImmGetCompositionString(himc, index, data, length);
312 return FALSE; 312 return FALSE;
313} 313}
314 314
315 315
316// static 316// static
317BOOL LLWinImm::setCompositionString(HIMC himc, DWORD index, LPVOID pComp, DWORD compLength, LPVOID pRead, DWORD readLength) 317BOOL LLWinImm::setCompositionString(HIMC himc, DWORD index, LPVOID pComp, DWORD compLength, LPVOID pRead, DWORD readLength)
318{ 318{
319 if ( sTheInstance.mImmSetCompositionString ) 319 if ( sTheInstance.mImmSetCompositionString )
320 return sTheInstance.mImmSetCompositionString(himc, index, pComp, compLength, pRead, readLength); 320 return sTheInstance.mImmSetCompositionString(himc, index, pComp, compLength, pRead, readLength);
321 return FALSE; 321 return FALSE;
322} 322}
323 323
324// static 324// static
325BOOL LLWinImm::setCompositionFont(HIMC himc, LPLOGFONTW pFont) 325BOOL LLWinImm::setCompositionFont(HIMC himc, LPLOGFONTW pFont)
326{ 326{
327 if ( sTheInstance.mImmSetCompositionFont ) 327 if ( sTheInstance.mImmSetCompositionFont )
328 return sTheInstance.mImmSetCompositionFont(himc, pFont); 328 return sTheInstance.mImmSetCompositionFont(himc, pFont);
329 return FALSE; 329 return FALSE;
330} 330}
331 331
332// static 332// static
333BOOL LLWinImm::setCandidateWindow(HIMC himc, LPCANDIDATEFORM form) 333BOOL LLWinImm::setCandidateWindow(HIMC himc, LPCANDIDATEFORM form)
334{ 334{
335 if ( sTheInstance.mImmSetCandidateWindow ) 335 if ( sTheInstance.mImmSetCandidateWindow )
336 return sTheInstance.mImmSetCandidateWindow(himc, form); 336 return sTheInstance.mImmSetCandidateWindow(himc, form);
337 return FALSE; 337 return FALSE;
338} 338}
339 339
340// static 340// static
341BOOL LLWinImm::notifyIME(HIMC himc, DWORD action, DWORD index, DWORD value) 341BOOL LLWinImm::notifyIME(HIMC himc, DWORD action, DWORD index, DWORD value)
342{ 342{
343 if ( sTheInstance.mImmNotifyIME ) 343 if ( sTheInstance.mImmNotifyIME )
344 return sTheInstance.mImmNotifyIME(himc, action, index, value); 344 return sTheInstance.mImmNotifyIME(himc, action, index, value);
345 return FALSE; 345 return FALSE;
346} 346}
347 347
@@ -359,8 +359,8 @@ LLWinImm::~LLWinImm()
359} 359}
360 360
361 361
362LPDIRECTINPUT8 g_pDI = NULL; 362LPDIRECTINPUT8 g_pDI = NULL;
363LPDIRECTINPUTDEVICE8 g_pJoystick = NULL; 363LPDIRECTINPUTDEVICE8 g_pJoystick = NULL;
364BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, 364BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance,
365 VOID* pContext ); 365 VOID* pContext );
366BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, 366BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
@@ -368,7 +368,7 @@ BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
368 368
369 369
370LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width, 370LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
371 S32 height, U32 flags, 371 S32 height, U32 flags,
372 BOOL fullscreen, BOOL clearBg, 372 BOOL fullscreen, BOOL clearBg,
373 BOOL disable_vsync, BOOL use_gl, 373 BOOL disable_vsync, BOOL use_gl,
374 BOOL ignore_pixel_depth) 374 BOOL ignore_pixel_depth)
@@ -442,8 +442,8 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
442 442
443 // Grab screen size to sanitize the window 443 // Grab screen size to sanitize the window
444 S32 window_border_y = GetSystemMetrics(SM_CYBORDER); 444 S32 window_border_y = GetSystemMetrics(SM_CYBORDER);
445 S32 virtual_screen_x = GetSystemMetrics(SM_XVIRTUALSCREEN); 445 S32 virtual_screen_x = GetSystemMetrics(SM_XVIRTUALSCREEN);
446 S32 virtual_screen_y = GetSystemMetrics(SM_YVIRTUALSCREEN); 446 S32 virtual_screen_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
447 S32 virtual_screen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN); 447 S32 virtual_screen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
448 S32 virtual_screen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN); 448 S32 virtual_screen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
449 449
@@ -554,7 +554,7 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
554 success = setDisplayResolution(width, height, BITS_PER_PIXEL, closest_refresh); 554 success = setDisplayResolution(width, height, BITS_PER_PIXEL, closest_refresh);
555 } 555 }
556 556
557 // Keep a copy of the actual current device mode in case we minimize 557 // Keep a copy of the actual current device mode in case we minimize
558 // and change the screen resolution. JC 558 // and change the screen resolution. JC
559 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode); 559 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode);
560 560
@@ -637,7 +637,7 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
637 // track_mouse_event.dwFlags = TME_LEAVE; 637 // track_mouse_event.dwFlags = TME_LEAVE;
638 // track_mouse_event.hwndTrack = mWindowHandle; 638 // track_mouse_event.hwndTrack = mWindowHandle;
639 // track_mouse_event.dwHoverTime = HOVER_DEFAULT; 639 // track_mouse_event.dwHoverTime = HOVER_DEFAULT;
640 // TrackMouseEvent( &track_mouse_event ); 640 // TrackMouseEvent( &track_mouse_event );
641 // } 641 // }
642 642
643 643
@@ -653,9 +653,9 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
653 //----------------------------------------------------------------------- 653 //-----------------------------------------------------------------------
654 PIXELFORMATDESCRIPTOR pfd = 654 PIXELFORMATDESCRIPTOR pfd =
655 { 655 {
656 sizeof(PIXELFORMATDESCRIPTOR), 656 sizeof(PIXELFORMATDESCRIPTOR),
657 1, 657 1,
658 pfdflags, 658 pfdflags,
659 PFD_TYPE_RGBA, 659 PFD_TYPE_RGBA,
660 BITS_PER_PIXEL, 660 BITS_PER_PIXEL,
661 0, 0, 0, 0, 0, 0, // RGB bits and shift, unused 661 0, 0, 0, 0, 0, 0, // RGB bits and shift, unused
@@ -888,7 +888,7 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
888 llinfos << "Swap Method: Unknown" << llendl; 888 llinfos << "Swap Method: Unknown" << llendl;
889 break; 889 break;
890 } 890 }
891 } 891 }
892 } 892 }
893 else 893 else
894 { 894 {
@@ -903,9 +903,9 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
903 OSMessageBox("Can't get pixel format description", "Error", OSMB_OK); 903 OSMessageBox("Can't get pixel format description", "Error", OSMB_OK);
904 return; 904 return;
905 } 905 }
906 llinfos << "GL buffer: Color Bits " << S32(pfd.cColorBits) 906 llinfos << "GL buffer: Color Bits " << S32(pfd.cColorBits)
907 << " Alpha Bits " << S32(pfd.cAlphaBits) 907 << " Alpha Bits " << S32(pfd.cAlphaBits)
908 << " Depth Bits " << S32(pfd.cDepthBits) 908 << " Depth Bits " << S32(pfd.cDepthBits)
909 << llendl; 909 << llendl;
910 910
911 if (pfd.cColorBits < 32) 911 if (pfd.cColorBits < 32)
@@ -989,20 +989,20 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
989 // We're going to assume that gamma's the same for all 3 channels, because I don't feel like doing it otherwise. 989 // We're going to assume that gamma's the same for all 3 channels, because I don't feel like doing it otherwise.
990 // Using the red channel. 990 // Using the red channel.
991 991
992 F32 Csum = 0.0; 992 F32 Csum = 0.0;
993 S32 Ccount = 0; 993 S32 Ccount = 0;
994 for (i = 0; i < 256; i++) 994 for (i = 0; i < 256; i++)
995 { 995 {
996 if (i != 0 && mPrevGammaRamp[i] != 0 && mPrevGammaRamp[i] != 65536) 996 if (i != 0 && mPrevGammaRamp[i] != 0 && mPrevGammaRamp[i] != 65536)
997 { 997 {
998 F64 B = (i % 256) / 256.0; 998 F64 B = (i % 256) / 256.0;
999 F64 A = mPrevGammaRamp[i] / 65536.0; 999 F64 A = mPrevGammaRamp[i] / 65536.0;
1000 F32 C = (F32) ( log(A) / log(B) ); 1000 F32 C = (F32) ( log(A) / log(B) );
1001 Csum += C; 1001 Csum += C;
1002 Ccount++; 1002 Ccount++;
1003 } 1003 }
1004 } 1004 }
1005 mCurrentGamma = Csum / Ccount; 1005 mCurrentGamma = Csum / Ccount;
1006 1006
1007 llinfos << "Previous gamma: " << mCurrentGamma << llendl; 1007 llinfos << "Previous gamma: " << mCurrentGamma << llendl;
1008 } 1008 }
@@ -1027,7 +1027,7 @@ void LLWindowWin32::initInputDevices()
1027 // Direct Input 1027 // Direct Input
1028 HRESULT hr; 1028 HRESULT hr;
1029 1029
1030 if( FAILED( hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, 1030 if( FAILED( hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION,
1031 IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) ) 1031 IID_IDirectInput8, (VOID**)&g_pDI, NULL ) ) )
1032 { 1032 {
1033 llwarns << "Direct8InputCreate failed!" << llendl; 1033 llwarns << "Direct8InputCreate failed!" << llendl;
@@ -1037,7 +1037,7 @@ void LLWindowWin32::initInputDevices()
1037 while(1) 1037 while(1)
1038 { 1038 {
1039 // Look for a simple joystick we can use for this sample program. 1039 // Look for a simple joystick we can use for this sample program.
1040 if (FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, 1040 if (FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL,
1041 EnumJoysticksCallback, 1041 EnumJoysticksCallback,
1042 NULL, DIEDFL_ATTACHEDONLY ) ) ) 1042 NULL, DIEDFL_ATTACHEDONLY ) ) )
1043 break; 1043 break;
@@ -1045,7 +1045,7 @@ void LLWindowWin32::initInputDevices()
1045 break; 1045 break;
1046 if( FAILED( hr = g_pJoystick->SetDataFormat( &c_dfDIJoystick ) ) ) 1046 if( FAILED( hr = g_pJoystick->SetDataFormat( &c_dfDIJoystick ) ) )
1047 break; 1047 break;
1048 if( FAILED( hr = g_pJoystick->EnumObjects( EnumObjectsCallback, 1048 if( FAILED( hr = g_pJoystick->EnumObjects( EnumObjectsCallback,
1049 (VOID*)mWindowHandle, DIDFT_ALL ) ) ) 1049 (VOID*)mWindowHandle, DIDFT_ALL ) ) )
1050 break; 1050 break;
1051 g_pJoystick->Acquire(); 1051 g_pJoystick->Acquire();
@@ -1149,7 +1149,7 @@ void LLWindowWin32::close()
1149 } 1149 }
1150 1150
1151 llinfos << "Destroying Window" << llendl; 1151 llinfos << "Destroying Window" << llendl;
1152 1152
1153 // Don't process events in our mainWindowProc any longer. 1153 // Don't process events in our mainWindowProc any longer.
1154 SetWindowLong(mWindowHandle, GWL_USERDATA, NULL); 1154 SetWindowLong(mWindowHandle, GWL_USERDATA, NULL);
1155 1155
@@ -1360,7 +1360,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disa
1360 success = setDisplayResolution(width, height, BITS_PER_PIXEL, closest_refresh); 1360 success = setDisplayResolution(width, height, BITS_PER_PIXEL, closest_refresh);
1361 } 1361 }
1362 1362
1363 // Keep a copy of the actual current device mode in case we minimize 1363 // Keep a copy of the actual current device mode in case we minimize
1364 // and change the screen resolution. JC 1364 // and change the screen resolution. JC
1365 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode); 1365 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode);
1366 1366
@@ -1437,9 +1437,9 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disa
1437 //----------------------------------------------------------------------- 1437 //-----------------------------------------------------------------------
1438 static PIXELFORMATDESCRIPTOR pfd = 1438 static PIXELFORMATDESCRIPTOR pfd =
1439 { 1439 {
1440 sizeof(PIXELFORMATDESCRIPTOR), 1440 sizeof(PIXELFORMATDESCRIPTOR),
1441 1, 1441 1,
1442 PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, 1442 PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
1443 PFD_TYPE_RGBA, 1443 PFD_TYPE_RGBA,
1444 BITS_PER_PIXEL, 1444 BITS_PER_PIXEL,
1445 0, 0, 0, 0, 0, 0, // RGB bits and shift, unused 1445 0, 0, 0, 0, 0, 0, // RGB bits and shift, unused
@@ -1668,7 +1668,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disa
1668 llinfos << "Swap Method: Unknown" << llendl; 1668 llinfos << "Swap Method: Unknown" << llendl;
1669 break; 1669 break;
1670 } 1670 }
1671 } 1671 }
1672 } 1672 }
1673 else 1673 else
1674 { 1674 {
@@ -1684,9 +1684,9 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disa
1684 return FALSE; 1684 return FALSE;
1685 } 1685 }
1686 1686
1687 llinfos << "GL buffer: Color Bits " << S32(pfd.cColorBits) 1687 llinfos << "GL buffer: Color Bits " << S32(pfd.cColorBits)
1688 << " Alpha Bits " << S32(pfd.cAlphaBits) 1688 << " Alpha Bits " << S32(pfd.cAlphaBits)
1689 << " Depth Bits " << S32(pfd.cDepthBits) 1689 << " Depth Bits " << S32(pfd.cDepthBits)
1690 << llendl; 1690 << llendl;
1691 1691
1692 if (pfd.cColorBits < 32) 1692 if (pfd.cColorBits < 32)
@@ -1884,10 +1884,10 @@ void LLWindowWin32::initCursors()
1884 mCursor[ UI_CURSOR_CROSS ] = LoadCursor(NULL, IDC_CROSS); 1884 mCursor[ UI_CURSOR_CROSS ] = LoadCursor(NULL, IDC_CROSS);
1885 mCursor[ UI_CURSOR_SIZENWSE ] = LoadCursor(NULL, IDC_SIZENWSE); 1885 mCursor[ UI_CURSOR_SIZENWSE ] = LoadCursor(NULL, IDC_SIZENWSE);
1886 mCursor[ UI_CURSOR_SIZENESW ] = LoadCursor(NULL, IDC_SIZENESW); 1886 mCursor[ UI_CURSOR_SIZENESW ] = LoadCursor(NULL, IDC_SIZENESW);
1887 mCursor[ UI_CURSOR_SIZEWE ] = LoadCursor(NULL, IDC_SIZEWE); 1887 mCursor[ UI_CURSOR_SIZEWE ] = LoadCursor(NULL, IDC_SIZEWE);
1888 mCursor[ UI_CURSOR_SIZENS ] = LoadCursor(NULL, IDC_SIZENS); 1888 mCursor[ UI_CURSOR_SIZENS ] = LoadCursor(NULL, IDC_SIZENS);
1889 mCursor[ UI_CURSOR_NO ] = LoadCursor(NULL, IDC_NO); 1889 mCursor[ UI_CURSOR_NO ] = LoadCursor(NULL, IDC_NO);
1890 mCursor[ UI_CURSOR_WORKING ] = LoadCursor(NULL, IDC_APPSTARTING); 1890 mCursor[ UI_CURSOR_WORKING ] = LoadCursor(NULL, IDC_APPSTARTING);
1891 1891
1892 HMODULE module = GetModuleHandle(NULL); 1892 HMODULE module = GetModuleHandle(NULL);
1893 mCursor[ UI_CURSOR_TOOLGRAB ] = LoadCursor(module, TEXT("TOOLGRAB")); 1893 mCursor[ UI_CURSOR_TOOLGRAB ] = LoadCursor(module, TEXT("TOOLGRAB"));
@@ -1902,7 +1902,7 @@ void LLWindowWin32::initCursors()
1902 mCursor[ UI_CURSOR_ARROWLOCKED ]= LoadCursor(module, TEXT("ARROWLOCKED")); 1902 mCursor[ UI_CURSOR_ARROWLOCKED ]= LoadCursor(module, TEXT("ARROWLOCKED"));
1903 mCursor[ UI_CURSOR_GRABLOCKED ] = LoadCursor(module, TEXT("GRABLOCKED")); 1903 mCursor[ UI_CURSOR_GRABLOCKED ] = LoadCursor(module, TEXT("GRABLOCKED"));
1904 mCursor[ UI_CURSOR_TOOLTRANSLATE ] = LoadCursor(module, TEXT("TOOLTRANSLATE")); 1904 mCursor[ UI_CURSOR_TOOLTRANSLATE ] = LoadCursor(module, TEXT("TOOLTRANSLATE"));
1905 mCursor[ UI_CURSOR_TOOLROTATE ] = LoadCursor(module, TEXT("TOOLROTATE")); 1905 mCursor[ UI_CURSOR_TOOLROTATE ] = LoadCursor(module, TEXT("TOOLROTATE"));
1906 mCursor[ UI_CURSOR_TOOLSCALE ] = LoadCursor(module, TEXT("TOOLSCALE")); 1906 mCursor[ UI_CURSOR_TOOLSCALE ] = LoadCursor(module, TEXT("TOOLSCALE"));
1907 mCursor[ UI_CURSOR_TOOLCAMERA ] = LoadCursor(module, TEXT("TOOLCAMERA")); 1907 mCursor[ UI_CURSOR_TOOLCAMERA ] = LoadCursor(module, TEXT("TOOLCAMERA"));
1908 mCursor[ UI_CURSOR_TOOLPAN ] = LoadCursor(module, TEXT("TOOLPAN")); 1908 mCursor[ UI_CURSOR_TOOLPAN ] = LoadCursor(module, TEXT("TOOLPAN"));
@@ -2103,7 +2103,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2103 2103
2104 if (window_imp->mFullscreen) 2104 if (window_imp->mFullscreen)
2105 { 2105 {
2106 // When we run fullscreen, restoring or minimizing the app needs 2106 // When we run fullscreen, restoring or minimizing the app needs
2107 // to switch the screen resolution 2107 // to switch the screen resolution
2108 if (activating) 2108 if (activating)
2109 { 2109 {
@@ -2131,13 +2131,13 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2131 window_imp->interruptLanguageTextInput(); 2131 window_imp->interruptLanguageTextInput();
2132 } 2132 }
2133 2133
2134 // JC - I'm not sure why, but if we don't report that we handled the 2134 // JC - I'm not sure why, but if we don't report that we handled the
2135 // WM_ACTIVATE message, the WM_ACTIVATEAPP messages don't work 2135 // WM_ACTIVATE message, the WM_ACTIVATEAPP messages don't work
2136 // properly when we run fullscreen. 2136 // properly when we run fullscreen.
2137 if (gDebugWindowProc) 2137 if (gDebugWindowProc)
2138 { 2138 {
2139 llinfos << "WINDOWPROC Activate " 2139 llinfos << "WINDOWPROC Activate "
2140 << " activating " << S32(activating) 2140 << " activating " << S32(activating)
2141 << " minimized " << S32(minimized) 2141 << " minimized " << S32(minimized)
2142 << llendl; 2142 << llendl;
2143 } 2143 }
@@ -2153,9 +2153,9 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2153 case WM_SYSCOMMAND: 2153 case WM_SYSCOMMAND:
2154 switch(w_param) 2154 switch(w_param)
2155 { 2155 {
2156 case SC_KEYMENU: 2156 case SC_KEYMENU:
2157 // Disallow the ALT key from triggering the default system menu. 2157 // Disallow the ALT key from triggering the default system menu.
2158 return 0; 2158 return 0;
2159 2159
2160 case SC_SCREENSAVE: 2160 case SC_SCREENSAVE:
2161 case SC_MONITORPOWER: 2161 case SC_MONITORPOWER:
@@ -2196,7 +2196,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2196 if (gDebugWindowProc) 2196 if (gDebugWindowProc)
2197 { 2197 {
2198 llinfos << "Debug WindowProc WM_KEYDOWN " 2198 llinfos << "Debug WindowProc WM_KEYDOWN "
2199 << " key " << S32(w_param) 2199 << " key " << S32(w_param)
2200 << llendl; 2200 << llendl;
2201 } 2201 }
2202 if(gKeyboard->handleKeyDown(w_param, mask) && eat_keystroke) 2202 if(gKeyboard->handleKeyDown(w_param, mask) && eat_keystroke)
@@ -2215,7 +2215,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2215 if (gDebugWindowProc) 2215 if (gDebugWindowProc)
2216 { 2216 {
2217 llinfos << "Debug WindowProc WM_KEYUP " 2217 llinfos << "Debug WindowProc WM_KEYUP "
2218 << " key " << S32(w_param) 2218 << " key " << S32(w_param)
2219 << llendl; 2219 << llendl;
2220 } 2220 }
2221 if (gKeyboard->handleKeyUp(w_param, mask) && eat_keystroke) 2221 if (gKeyboard->handleKeyUp(w_param, mask) && eat_keystroke)
@@ -2284,7 +2284,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2284 if (gDebugWindowProc) 2284 if (gDebugWindowProc)
2285 { 2285 {
2286 llinfos << "Debug WindowProc WM_CHAR " 2286 llinfos << "Debug WindowProc WM_CHAR "
2287 << " key " << S32(w_param) 2287 << " key " << S32(w_param)
2288 << llendl; 2288 << llendl;
2289 } 2289 }
2290 // Even if LLWindowCallbacks::handleUnicodeChar(llwchar, BOOL) returned FALSE, 2290 // Even if LLWindowCallbacks::handleUnicodeChar(llwchar, BOOL) returned FALSE,
@@ -2527,7 +2527,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2527 // track_mouse_event.dwFlags = TME_LEAVE; 2527 // track_mouse_event.dwFlags = TME_LEAVE;
2528 // track_mouse_event.hwndTrack = h_wnd; 2528 // track_mouse_event.hwndTrack = h_wnd;
2529 // track_mouse_event.dwHoverTime = HOVER_DEFAULT; 2529 // track_mouse_event.dwHoverTime = HOVER_DEFAULT;
2530 // TrackMouseEvent( &track_mouse_event ); 2530 // TrackMouseEvent( &track_mouse_event );
2531 return 0; 2531 return 0;
2532 } 2532 }
2533 */ 2533 */
@@ -2559,12 +2559,12 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2559 << llendl; 2559 << llendl;
2560 } 2560 }
2561 2561
2562 // There's an odd behavior with WM_SIZE that I would call a bug. If 2562 // There's an odd behavior with WM_SIZE that I would call a bug. If
2563 // the window is maximized, and you call MoveWindow() with a size smaller 2563 // the window is maximized, and you call MoveWindow() with a size smaller
2564 // than a maximized window, it ends up sending WM_SIZE with w_param set 2564 // than a maximized window, it ends up sending WM_SIZE with w_param set
2565 // to SIZE_MAXIMIZED -- which isn't true. So the logic below doesn't work. 2565 // to SIZE_MAXIMIZED -- which isn't true. So the logic below doesn't work.
2566 // (SL-44655). Fixed it by calling ShowWindow(SW_RESTORE) first (see 2566 // (SL-44655). Fixed it by calling ShowWindow(SW_RESTORE) first (see
2567 // LLWindowWin32::moveWindow in this file). 2567 // LLWindowWin32::moveWindow in this file).
2568 2568
2569 // If we are now restored, but we weren't before, this 2569 // If we are now restored, but we weren't before, this
2570 // means that the window was un-minimized. 2570 // means that the window was un-minimized.
@@ -2589,8 +2589,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2589 if (w_param != SIZE_MINIMIZED) 2589 if (w_param != SIZE_MINIMIZED)
2590 { 2590 {
2591 // Ignore updates for minimizing and minimized "windows" 2591 // Ignore updates for minimizing and minimized "windows"
2592 window_imp->mCallbacks->handleResize( window_imp, 2592 window_imp->mCallbacks->handleResize( window_imp,
2593 LOWORD(l_param), 2593 LOWORD(l_param),
2594 HIWORD(l_param) ); 2594 HIWORD(l_param) );
2595 } 2595 }
2596 2596
@@ -2619,7 +2619,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
2619 // received a URL 2619 // received a URL
2620 PCOPYDATASTRUCT myCDS = (PCOPYDATASTRUCT) l_param; 2620 PCOPYDATASTRUCT myCDS = (PCOPYDATASTRUCT) l_param;
2621 window_imp->mCallbacks->handleDataCopy(window_imp, myCDS->dwData, myCDS->lpData); 2621 window_imp->mCallbacks->handleDataCopy(window_imp, myCDS->dwData, myCDS->lpData);
2622 return 0; 2622 return 0;
2623 } 2623 }
2624 } 2624 }
2625 2625
@@ -2667,7 +2667,7 @@ BOOL LLWindowWin32::convertCoords(LLCoordWindow from, LLCoordGL* to)
2667} 2667}
2668 2668
2669BOOL LLWindowWin32::convertCoords(LLCoordScreen from, LLCoordWindow* to) 2669BOOL LLWindowWin32::convertCoords(LLCoordScreen from, LLCoordWindow* to)
2670{ 2670{
2671 POINT mouse_point; 2671 POINT mouse_point;
2672 2672
2673 mouse_point.x = from.mX; 2673 mouse_point.x = from.mX;
@@ -2778,7 +2778,7 @@ BOOL LLWindowWin32::copyTextToClipboard(const LLWString& wstr)
2778 const size_t size_utf16 = (out_utf16.length() + 1) * sizeof(WCHAR); 2778 const size_t size_utf16 = (out_utf16.length() + 1) * sizeof(WCHAR);
2779 2779
2780 // Memory is allocated and then ownership of it is transfered to the system. 2780 // Memory is allocated and then ownership of it is transfered to the system.
2781 HGLOBAL hglobal_copy_utf16 = GlobalAlloc(GMEM_MOVEABLE, size_utf16); 2781 HGLOBAL hglobal_copy_utf16 = GlobalAlloc(GMEM_MOVEABLE, size_utf16);
2782 if (hglobal_copy_utf16) 2782 if (hglobal_copy_utf16)
2783 { 2783 {
2784 WCHAR* copy_utf16 = (WCHAR*) GlobalLock(hglobal_copy_utf16); 2784 WCHAR* copy_utf16 = (WCHAR*) GlobalLock(hglobal_copy_utf16);
@@ -2841,12 +2841,12 @@ BOOL LLWindowWin32::getClientRectInScreenSpace( RECT* rectp )
2841 POINT top_left; 2841 POINT top_left;
2842 top_left.x = client_rect.left; 2842 top_left.x = client_rect.left;
2843 top_left.y = client_rect.top; 2843 top_left.y = client_rect.top;
2844 ClientToScreen(mWindowHandle, &top_left); 2844 ClientToScreen(mWindowHandle, &top_left);
2845 2845
2846 POINT bottom_right; 2846 POINT bottom_right;
2847 bottom_right.x = client_rect.right; 2847 bottom_right.x = client_rect.right;
2848 bottom_right.y = client_rect.bottom; 2848 bottom_right.y = client_rect.bottom;
2849 ClientToScreen(mWindowHandle, &bottom_right); 2849 ClientToScreen(mWindowHandle, &bottom_right);
2850 2850
2851 SetRect( rectp, 2851 SetRect( rectp,
2852 top_left.x, 2852 top_left.x,
@@ -2977,8 +2977,8 @@ BOOL LLWindowWin32::setGamma(const F32 gamma)
2977 if ( value > 0xffff ) 2977 if ( value > 0xffff )
2978 value = 0xffff; 2978 value = 0xffff;
2979 2979
2980 mCurrentGammaRamp [ 0 * 256 + i ] = 2980 mCurrentGammaRamp [ 0 * 256 + i ] =
2981 mCurrentGammaRamp [ 1 * 256 + i ] = 2981 mCurrentGammaRamp [ 1 * 256 + i ] =
2982 mCurrentGammaRamp [ 2 * 256 + i ] = ( WORD )value; 2982 mCurrentGammaRamp [ 2 * 256 + i ] = ( WORD )value;
2983 }; 2983 };
2984 2984
@@ -3152,7 +3152,7 @@ BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance,
3152 3152
3153 // If it failed, then we can't use this joystick. (Maybe the user unplugged 3153 // If it failed, then we can't use this joystick. (Maybe the user unplugged
3154 // it while we were in the middle of enumerating it.) 3154 // it while we were in the middle of enumerating it.)
3155 if( FAILED(hr) ) 3155 if( FAILED(hr) )
3156 return DIENUM_CONTINUE; 3156 return DIENUM_CONTINUE;
3157 3157
3158 // Stop enumeration. Note: we're just taking the first joystick we get. You 3158 // Stop enumeration. Note: we're just taking the first joystick we get. You
@@ -3165,16 +3165,16 @@ BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
3165{ 3165{
3166 if( pdidoi->dwType & DIDFT_AXIS ) 3166 if( pdidoi->dwType & DIDFT_AXIS )
3167 { 3167 {
3168 DIPROPRANGE diprg; 3168 DIPROPRANGE diprg;
3169 diprg.diph.dwSize = sizeof(DIPROPRANGE); 3169 diprg.diph.dwSize = sizeof(DIPROPRANGE);
3170 diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); 3170 diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
3171 diprg.diph.dwHow = DIPH_BYID; 3171 diprg.diph.dwHow = DIPH_BYID;
3172 diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis 3172 diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis
3173 diprg.lMin = -1000; 3173 diprg.lMin = -1000;
3174 diprg.lMax = +1000; 3174 diprg.lMax = +1000;
3175 3175
3176 // Set the range for the axis 3176 // Set the range for the axis
3177 if( FAILED( g_pJoystick->SetProperty( DIPROP_RANGE, &diprg.diph ) ) ) 3177 if( FAILED( g_pJoystick->SetProperty( DIPROP_RANGE, &diprg.diph ) ) )
3178 return DIENUM_STOP; 3178 return DIENUM_STOP;
3179 3179
3180 } 3180 }
@@ -3234,10 +3234,10 @@ void LLSplashScreenWin32::showImpl()
3234 // This appears to work. ??? 3234 // This appears to work. ???
3235 HINSTANCE hinst = GetModuleHandle(NULL); 3235 HINSTANCE hinst = GetModuleHandle(NULL);
3236 3236
3237 mWindow = CreateDialog(hinst, 3237 mWindow = CreateDialog(hinst,
3238 TEXT("SPLASHSCREEN"), 3238 TEXT("SPLASHSCREEN"),
3239 NULL, // no parent 3239 NULL, // no parent
3240 (DLGPROC) LLSplashScreenWin32::windowProc); 3240 (DLGPROC) LLSplashScreenWin32::windowProc);
3241 ShowWindow(mWindow, SW_SHOW); 3241 ShowWindow(mWindow, SW_SHOW);
3242} 3242}
3243 3243
@@ -3262,7 +3262,7 @@ void LLSplashScreenWin32::hideImpl()
3262 if (mWindow) 3262 if (mWindow)
3263 { 3263 {
3264 DestroyWindow(mWindow); 3264 DestroyWindow(mWindow);
3265 mWindow = NULL; 3265 mWindow = NULL;
3266 } 3266 }
3267} 3267}
3268 3268
@@ -3349,74 +3349,92 @@ void spawn_web_browser(const char* escaped_url )
3349 3349
3350 llinfos << "Opening URL " << escaped_url << llendl; 3350 llinfos << "Opening URL " << escaped_url << llendl;
3351 3351
3352 // Figure out the user's default web browser 3352 // replaced ShellExecute code with ShellExecuteEx since ShellExecute doesn't work
3353 // HKEY_CLASSES_ROOT\http\shell\open\command 3353 // reliablly on Vista.
3354 char reg_path_str[256]; /* Flawfinder: ignore */ 3354
3355 snprintf(reg_path_str, sizeof(reg_path_str), "%s\\shell\\open\\command", gURLProtocolWhitelistHandler[i]); /* Flawfinder: ignore */ 3355 // this is madness.. no, this is..
3356 WCHAR reg_path_wstr[256]; 3356 LLWString url_wstring = utf8str_to_wstring( escaped_url );
3357 mbstowcs(reg_path_wstr, reg_path_str, sizeof(reg_path_wstr)/sizeof(reg_path_wstr[0])); 3357 llutf16string url_utf16 = wstring_to_utf16str( url_wstring );
3358 3358
3359 HKEY key; 3359 // let the OS decide what to use to open the URL
3360 WCHAR browser_open_wstr[1024]; 3360 SHELLEXECUTEINFO sei = { sizeof( sei ) };
3361 DWORD buffer_length = 1024; 3361 sei.fMask = SEE_MASK_FLAG_DDEWAIT;
3362 RegOpenKeyEx(HKEY_CLASSES_ROOT, reg_path_wstr, 0, KEY_QUERY_VALUE, &key); 3362 sei.nShow = SW_SHOWNORMAL;
3363 RegQueryValueEx(key, NULL, NULL, NULL, (LPBYTE)browser_open_wstr, &buffer_length); 3363 sei.lpVerb = L"open";
3364 RegCloseKey(key); 3364 sei.lpFile = url_utf16.c_str();
3365 3365 ShellExecuteEx( &sei );
3366 // Convert to STL string 3366
3367 LLWString browser_open_wstring = utf16str_to_wstring(browser_open_wstr); 3367 ////// TODO: LEAVING OLD CODE HERE SO I DON'T BONE OTHER MERGES
3368 3368 ////// DELETE THIS ONCE THE MERGES ARE DONE
3369 if (browser_open_wstring.length() < 2) 3369
3370 { 3370 //// Figure out the user's default web browser
3371 llwarns << "Invalid browser executable in registry " << browser_open_wstring << llendl; 3371 //// HKEY_CLASSES_ROOT\http\shell\open\command
3372 return; 3372 //char reg_path_str[256]; /* Flawfinder: ignore */
3373 } 3373 //snprintf(reg_path_str, sizeof(reg_path_str), "%s\\shell\\open\\command", gURLProtocolWhitelistHandler[i]); /* Flawfinder: ignore */
3374 3374 //WCHAR reg_path_wstr[256];
3375 // Extract the process that's supposed to be launched 3375 //mbstowcs(reg_path_wstr, reg_path_str, sizeof(reg_path_wstr)/sizeof(reg_path_wstr[0]));
3376 LLWString browser_executable; 3376
3377 if (browser_open_wstring[0] == '"') 3377 //HKEY key;
3378 { 3378 //WCHAR browser_open_wstr[1024];
3379 // executable is quoted, find the matching quote 3379 //DWORD buffer_length = 1024;
3380 size_t quote_pos = browser_open_wstring.find('"', 1); 3380 //RegOpenKeyEx(HKEY_CLASSES_ROOT, reg_path_wstr, 0, KEY_QUERY_VALUE, &key);
3381 // copy out the string including both quotes 3381 //RegQueryValueEx(key, NULL, NULL, NULL, (LPBYTE)browser_open_wstr, &buffer_length);
3382 browser_executable = browser_open_wstring.substr(0, quote_pos+1); 3382 //RegCloseKey(key);
3383 } 3383
3384 else 3384 //// Convert to STL string
3385 { 3385 //LLWString browser_open_wstring = utf16str_to_wstring(browser_open_wstr);
3386 // executable not quoted, find a space 3386
3387 size_t space_pos = browser_open_wstring.find(' ', 1); 3387 //if (browser_open_wstring.length() < 2)
3388 browser_executable = browser_open_wstring.substr(0, space_pos); 3388 //{
3389 } 3389 // llwarns << "Invalid browser executable in registry " << browser_open_wstring << llendl;
3390 3390 // return;
3391 llinfos << "Browser reg key: " << wstring_to_utf8str(browser_open_wstring) << llendl; 3391 //}
3392 llinfos << "Browser executable: " << wstring_to_utf8str(browser_executable) << llendl; 3392
3393 3393 //// Extract the process that's supposed to be launched
3394 // Convert URL to wide string for Windows API 3394 //LLWString browser_executable;
3395 // Assume URL is UTF8, as can come from scripts 3395 //if (browser_open_wstring[0] == '"')
3396 LLWString url_wstring = utf8str_to_wstring(escaped_url); 3396 //{
3397 llutf16string url_utf16 = wstring_to_utf16str(url_wstring); 3397 // // executable is quoted, find the matching quote
3398 3398 // size_t quote_pos = browser_open_wstring.find('"', 1);
3399 // Convert executable and path to wide string for Windows API 3399 // // copy out the string including both quotes
3400 llutf16string browser_exec_utf16 = wstring_to_utf16str(browser_executable); 3400 // browser_executable = browser_open_wstring.substr(0, quote_pos+1);
3401 3401 //}
3402 // ShellExecute returns HINSTANCE for backwards compatiblity. 3402 //else
3403 // MS docs say to cast to int and compare to 32. 3403 //{
3404 HWND our_window = NULL; 3404 // // executable not quoted, find a space
3405 LPCWSTR directory_wstr = NULL; 3405 // size_t space_pos = browser_open_wstring.find(' ', 1);
3406 int retval = (int) ShellExecute(our_window, /* Flawfinder: ignore */ 3406 // browser_executable = browser_open_wstring.substr(0, space_pos);
3407 L"open", 3407 //}
3408 browser_exec_utf16.c_str(), 3408
3409 url_utf16.c_str(), 3409 //llinfos << "Browser reg key: " << wstring_to_utf8str(browser_open_wstring) << llendl;
3410 directory_wstr, 3410 //llinfos << "Browser executable: " << wstring_to_utf8str(browser_executable) << llendl;
3411 SW_SHOWNORMAL); 3411
3412 if (retval > 32) 3412 //// Convert URL to wide string for Windows API
3413 { 3413 //// Assume URL is UTF8, as can come from scripts
3414 llinfos << "load_url success with " << retval << llendl; 3414 //LLWString url_wstring = utf8str_to_wstring(escaped_url);
3415 } 3415 //llutf16string url_utf16 = wstring_to_utf16str(url_wstring);
3416 else 3416
3417 { 3417 //// Convert executable and path to wide string for Windows API
3418 llinfos << "load_url failure with " << retval << llendl; 3418 //llutf16string browser_exec_utf16 = wstring_to_utf16str(browser_executable);
3419 } 3419
3420 //// ShellExecute returns HINSTANCE for backwards compatiblity.
3421 //// MS docs say to cast to int and compare to 32.
3422 //HWND our_window = NULL;
3423 //LPCWSTR directory_wstr = NULL;
3424 //int retval = (int) ShellExecute(our_window, /* Flawfinder: ignore */
3425 // L"open",
3426 // browser_exec_utf16.c_str(),
3427 // url_utf16.c_str(),
3428 // directory_wstr,
3429 // SW_SHOWNORMAL);
3430 //if (retval > 32)
3431 //{
3432 // llinfos << "load_url success with " << retval << llendl;
3433 //}
3434 //else
3435 //{
3436 // llinfos << "load_url failure with " << retval << llendl;
3437 //}
3420} 3438}
3421 3439
3422 3440
@@ -3430,13 +3448,13 @@ BOOL LLWindowWin32::dialog_color_picker ( F32 *r, F32 *g, F32 *b )
3430 cc.hwndOwner = mWindowHandle; 3448 cc.hwndOwner = mWindowHandle;
3431 cc.hInstance = NULL; 3449 cc.hInstance = NULL;
3432 cc.rgbResult = RGB ((*r * 255.f),(*g *255.f),(*b * 255.f)); 3450 cc.rgbResult = RGB ((*r * 255.f),(*g *255.f),(*b * 255.f));
3433 //cc.rgbResult = RGB (0x80,0x80,0x80); 3451 //cc.rgbResult = RGB (0x80,0x80,0x80);
3434 cc.lpCustColors = crCustColors; 3452 cc.lpCustColors = crCustColors;
3435 cc.Flags = CC_RGBINIT | CC_FULLOPEN; 3453 cc.Flags = CC_RGBINIT | CC_FULLOPEN;
3436 cc.lCustData = 0; 3454 cc.lCustData = 0;
3437 cc.lpfnHook = NULL; 3455 cc.lpfnHook = NULL;
3438 cc.lpTemplateName = NULL; 3456 cc.lpTemplateName = NULL;
3439 3457
3440 // This call is modal, so pause agent 3458 // This call is modal, so pause agent
3441 //send_agent_pause(); // this is in newview and we don't want to set up a dependency 3459 //send_agent_pause(); // this is in newview and we don't want to set up a dependency
3442 { 3460 {
@@ -3447,7 +3465,7 @@ BOOL LLWindowWin32::dialog_color_picker ( F32 *r, F32 *g, F32 *b )
3447 *b = ((F32)((cc.rgbResult >> 16) & 0xff)) / 255.f; 3465 *b = ((F32)((cc.rgbResult >> 16) & 0xff)) / 255.f;
3448 3466
3449 *g = ((F32)((cc.rgbResult >> 8) & 0xff)) / 255.f; 3467 *g = ((F32)((cc.rgbResult >> 8) & 0xff)) / 255.f;
3450 3468
3451 *r = ((F32)(cc.rgbResult & 0xff)) / 255.f; 3469 *r = ((F32)(cc.rgbResult & 0xff)) / 255.f;
3452 3470
3453 return (retval); 3471 return (retval);
@@ -3501,8 +3519,8 @@ void LLWindowWin32::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b)
3501 3519
3502 if ( sLanguageTextInputAllowed ) 3520 if ( sLanguageTextInputAllowed )
3503 { 3521 {
3504 // Allowing: Restore the previous IME status, so that the user has a feeling that the previous 3522 // Allowing: Restore the previous IME status, so that the user has a feeling that the previous
3505 // text input continues naturally. Be careful, however, the IME status is meaningful only during the user keeps 3523 // text input continues naturally. Be careful, however, the IME status is meaningful only during the user keeps
3506 // using same Input Locale (aka Keyboard Layout). 3524 // using same Input Locale (aka Keyboard Layout).
3507 if (sWinIMEOpened && GetKeyboardLayout(0) == sWinInputLocale) 3525 if (sWinIMEOpened && GetKeyboardLayout(0) == sWinInputLocale)
3508 { 3526 {
@@ -3527,7 +3545,7 @@ void LLWindowWin32::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b)
3527 { 3545 {
3528 LLWinImm::getConversionStatus(himc, &sWinIMEConversionMode, &sWinIMESentenceMode); 3546 LLWinImm::getConversionStatus(himc, &sWinIMEConversionMode, &sWinIMESentenceMode);
3529 3547
3530 // We need both ImmSetConversionStatus and ImmSetOpenStatus here to surely disable IME's 3548 // We need both ImmSetConversionStatus and ImmSetOpenStatus here to surely disable IME's
3531 // keyboard hooking, because Some IME reacts only on the former and some other on the latter... 3549 // keyboard hooking, because Some IME reacts only on the former and some other on the latter...
3532 LLWinImm::setConversionStatus(himc, IME_CMODE_NOCONVERSION, sWinIMESentenceMode); 3550 LLWinImm::setConversionStatus(himc, IME_CMODE_NOCONVERSION, sWinIMESentenceMode);
3533 LLWinImm::setOpenStatus(himc, FALSE); 3551 LLWinImm::setOpenStatus(himc, FALSE);
@@ -3537,7 +3555,7 @@ void LLWindowWin32::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b)
3537 } 3555 }
3538} 3556}
3539 3557
3540void LLWindowWin32::fillCandidateForm(const LLCoordGL& caret, const LLRect& bounds, 3558void LLWindowWin32::fillCandidateForm(const LLCoordGL& caret, const LLRect& bounds,
3541 CANDIDATEFORM *form) 3559 CANDIDATEFORM *form)
3542{ 3560{
3543 LLCoordWindow caret_coord, top_left, bottom_right; 3561 LLCoordWindow caret_coord, top_left, bottom_right;
@@ -3566,7 +3584,7 @@ void LLWindowWin32::setLanguageTextInput( const LLCoordGL & position )
3566 LLCoordWindow win_pos; 3584 LLCoordWindow win_pos;
3567 convertCoords( position, &win_pos ); 3585 convertCoords( position, &win_pos );
3568 3586
3569 if ( win_pos.mX >= 0 && win_pos.mY >= 0 && 3587 if ( win_pos.mX >= 0 && win_pos.mY >= 0 &&
3570 (win_pos.mX != sWinIMEWindowPosition.mX) || (win_pos.mY != sWinIMEWindowPosition.mY) ) 3588 (win_pos.mX != sWinIMEWindowPosition.mX) || (win_pos.mY != sWinIMEWindowPosition.mY) )
3571 { 3589 {
3572 COMPOSITIONFORM ime_form; 3590 COMPOSITIONFORM ime_form;
@@ -3631,13 +3649,13 @@ void LLWindowWin32::fillCompositionLogfont(LOGFONT *logfont)
3631 default: 3649 default:
3632 logfont->lfCharSet = CHINESEBIG5_CHARSET; 3650 logfont->lfCharSet = CHINESEBIG5_CHARSET;
3633 lstrcpy(logfont->lfFaceName, TEXT("MingLiU")); 3651 lstrcpy(logfont->lfFaceName, TEXT("MingLiU"));
3634 break; 3652 break;
3635 } 3653 }
3636 break; 3654 break;
3637 case LANG_JAPANESE: 3655 case LANG_JAPANESE:
3638 logfont->lfCharSet = SHIFTJIS_CHARSET; 3656 logfont->lfCharSet = SHIFTJIS_CHARSET;
3639 lstrcpy(logfont->lfFaceName, TEXT("MS Gothic")); 3657 lstrcpy(logfont->lfFaceName, TEXT("MS Gothic"));
3640 break; 3658 break;
3641 case LANG_KOREAN: 3659 case LANG_KOREAN:
3642 logfont->lfCharSet = HANGUL_CHARSET; 3660 logfont->lfCharSet = HANGUL_CHARSET;
3643 lstrcpy(logfont->lfFaceName, TEXT("Gulim")); 3661 lstrcpy(logfont->lfFaceName, TEXT("Gulim"));
@@ -3647,10 +3665,10 @@ void LLWindowWin32::fillCompositionLogfont(LOGFONT *logfont)
3647 lstrcpy(logfont->lfFaceName, TEXT("Tahoma")); 3665 lstrcpy(logfont->lfFaceName, TEXT("Tahoma"));
3648 break; 3666 break;
3649 } 3667 }
3650 3668
3651 logfont->lfHeight = mPreeditor->getPreeditFontSize(); 3669 logfont->lfHeight = mPreeditor->getPreeditFontSize();
3652 logfont->lfWeight = FW_NORMAL; 3670 logfont->lfWeight = FW_NORMAL;
3653} 3671}
3654 3672
3655U32 LLWindowWin32::fillReconvertString(const LLWString &text, 3673U32 LLWindowWin32::fillReconvertString(const LLWString &text,
3656 S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string) 3674 S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string)
@@ -3764,7 +3782,7 @@ void LLWindowWin32::handleCompositionMessage(const U32 indexes)
3764 needs_update = TRUE; 3782 needs_update = TRUE;
3765 } 3783 }
3766 } 3784 }
3767 3785
3768 if (indexes & GCS_COMPSTR) 3786 if (indexes & GCS_COMPSTR)
3769 { 3787 {
3770 LONG size = LLWinImm::getCompositionString(himc, GCS_COMPSTR, NULL, 0); 3788 LONG size = LLWinImm::getCompositionString(himc, GCS_COMPSTR, NULL, 0);
@@ -3930,7 +3948,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
3930 LLCoordGL caret_coord; 3948 LLCoordGL caret_coord;
3931 LLRect preedit_bounds; 3949 LLRect preedit_bounds;
3932 mPreeditor->getPreeditLocation(-1, &caret_coord, &preedit_bounds, NULL); 3950 mPreeditor->getPreeditLocation(-1, &caret_coord, &preedit_bounds, NULL);
3933 3951
3934 CANDIDATEFORM *const form = (CANDIDATEFORM *)param; 3952 CANDIDATEFORM *const form = (CANDIDATEFORM *)param;
3935 DWORD const dwIndex = form->dwIndex; 3953 DWORD const dwIndex = form->dwIndex;
3936 fillCandidateForm(caret_coord, preedit_bounds, form); 3954 fillCandidateForm(caret_coord, preedit_bounds, form);
@@ -3945,7 +3963,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
3945 3963
3946 // char_position->dwCharPos counts in number of 3964 // char_position->dwCharPos counts in number of
3947 // WCHARs, i.e., UTF-16 encoding units, so we can't simply pass the 3965 // WCHARs, i.e., UTF-16 encoding units, so we can't simply pass the
3948 // number to getPreeditLocation. 3966 // number to getPreeditLocation.
3949 3967
3950 const LLWString & wtext = mPreeditor->getWText(); 3968 const LLWString & wtext = mPreeditor->getWText();
3951 S32 preedit, preedit_length; 3969 S32 preedit, preedit_length;
@@ -4019,7 +4037,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
4019 const LLWString & wtext = mPreeditor->getWText(); 4037 const LLWString & wtext = mPreeditor->getWText();
4020 S32 preedit, preedit_length; 4038 S32 preedit, preedit_length;
4021 mPreeditor->getPreeditRange(&preedit, &preedit_length); 4039 mPreeditor->getPreeditRange(&preedit, &preedit_length);
4022 4040
4023 S32 context_offset; 4041 S32 context_offset;
4024 LLWString context = find_context(wtext, preedit, preedit_length, &context_offset); 4042 LLWString context = find_context(wtext, preedit, preedit_length, &context_offset);
4025 preedit -= context_offset; 4043 preedit -= context_offset;
@@ -4030,7 +4048,7 @@ BOOL LLWindowWin32::handleImeRequests(U32 request, U32 param, LRESULT *result)
4030 // Otherwise, some IME are confused. 4048 // Otherwise, some IME are confused.
4031 context.erase(preedit, preedit_length); 4049 context.erase(preedit, preedit_length);
4032 } 4050 }
4033 4051
4034 RECONVERTSTRING *reconvert_string = (RECONVERTSTRING *)param; 4052 RECONVERTSTRING *reconvert_string = (RECONVERTSTRING *)param;
4035 *result = fillReconvertString(context, preedit, 0, reconvert_string); 4053 *result = fillReconvertString(context, preedit, 0, reconvert_string);
4036 return TRUE; 4054 return TRUE;