diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llwindow/lldxhardware.cpp | 8 | ||||
-rw-r--r-- | linden/indra/llwindow/llgl.cpp | 155 | ||||
-rw-r--r-- | linden/indra/llwindow/llgl.h | 6 | ||||
-rw-r--r-- | linden/indra/llwindow/llglheaders.h | 10 | ||||
-rw-r--r-- | linden/indra/llwindow/llgltypes.h | 42 | ||||
-rw-r--r-- | linden/indra/llwindow/llkeyboard.cpp | 2 | ||||
-rw-r--r-- | linden/indra/llwindow/llkeyboardwin32.cpp | 16 | ||||
-rw-r--r-- | linden/indra/llwindow/llmousehandler.h | 4 | ||||
-rw-r--r-- | linden/indra/llwindow/llwindow.h | 1 | ||||
-rw-r--r-- | linden/indra/llwindow/llwindow_vc8.vcproj | 392 | ||||
-rw-r--r-- | linden/indra/llwindow/llwindowmacosx.cpp | 31 | ||||
-rw-r--r-- | linden/indra/llwindow/llwindowsdl.cpp | 376 | ||||
-rw-r--r-- | linden/indra/llwindow/llwindowsdl.h | 26 | ||||
-rw-r--r-- | linden/indra/llwindow/llwindowwin32.cpp | 117 | ||||
-rw-r--r-- | linden/indra/llwindow/llwindowwin32.h | 1 |
15 files changed, 883 insertions, 304 deletions
diff --git a/linden/indra/llwindow/lldxhardware.cpp b/linden/indra/llwindow/lldxhardware.cpp index 5dd632b..b2e1b04 100644 --- a/linden/indra/llwindow/lldxhardware.cpp +++ b/linden/indra/llwindow/lldxhardware.cpp | |||
@@ -66,16 +66,16 @@ std::string get_string(IDxDiagContainer *containerp, WCHAR *wszPropName) | |||
66 | switch( var.vt ) | 66 | switch( var.vt ) |
67 | { | 67 | { |
68 | case VT_UI4: | 68 | case VT_UI4: |
69 | swprintf( wszPropValue, L"%d", var.ulVal ); | 69 | swprintf( wszPropValue, L"%d", var.ulVal ); /* Flawfinder: ignore */ |
70 | break; | 70 | break; |
71 | case VT_I4: | 71 | case VT_I4: |
72 | swprintf( wszPropValue, L"%d", var.lVal ); | 72 | swprintf( wszPropValue, L"%d", var.lVal ); /* Flawfinder: ignore */ |
73 | break; | 73 | break; |
74 | case VT_BOOL: | 74 | case VT_BOOL: |
75 | wcscpy( wszPropValue, (var.boolVal) ? L"true" : L"false" ); | 75 | wcscpy( wszPropValue, (var.boolVal) ? L"true" : L"false" ); /* Flawfinder: ignore */ |
76 | break; | 76 | break; |
77 | case VT_BSTR: | 77 | case VT_BSTR: |
78 | wcsncpy( wszPropValue, var.bstrVal, 255 ); | 78 | wcsncpy( wszPropValue, var.bstrVal, 255 ); /* Flawfinder: ignore */ |
79 | wszPropValue[255] = 0; | 79 | wszPropValue[255] = 0; |
80 | break; | 80 | break; |
81 | } | 81 | } |
diff --git a/linden/indra/llwindow/llgl.cpp b/linden/indra/llwindow/llgl.cpp index ec22907..aabe9da 100644 --- a/linden/indra/llwindow/llgl.cpp +++ b/linden/indra/llwindow/llgl.cpp | |||
@@ -44,6 +44,7 @@ | |||
44 | 44 | ||
45 | #include "llglheaders.h" | 45 | #include "llglheaders.h" |
46 | 46 | ||
47 | #define LL_DEBUG_GL 1 | ||
47 | 48 | ||
48 | #if LL_LINUX && !LL_MESA_HEADLESS | 49 | #if LL_LINUX && !LL_MESA_HEADLESS |
49 | // The __APPLE__ hack is to make glh_extensions.h not symbol-clash horribly | 50 | // The __APPLE__ hack is to make glh_extensions.h not symbol-clash horribly |
@@ -118,6 +119,10 @@ PFNGLGETQUERYIVARBPROC glGetQueryivARB = NULL; | |||
118 | PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB = NULL; | 119 | PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB = NULL; |
119 | PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB = NULL; | 120 | PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB = NULL; |
120 | 121 | ||
122 | // GL_ARB_point_parameters | ||
123 | PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB = NULL; | ||
124 | PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB = NULL; | ||
125 | |||
121 | //shader object prototypes | 126 | //shader object prototypes |
122 | PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = NULL; | 127 | PFNGLDELETEOBJECTARBPROC glDeleteObjectARB = NULL; |
123 | PFNGLGETHANDLEARBPROC glGetHandleARB = NULL; | 128 | PFNGLGETHANDLEARBPROC glGetHandleARB = NULL; |
@@ -267,6 +272,7 @@ LLGLManager::LLGLManager() | |||
267 | mHasVertexShader = FALSE; | 272 | mHasVertexShader = FALSE; |
268 | mHasFragmentShader = FALSE; | 273 | mHasFragmentShader = FALSE; |
269 | mHasShaderObjects = FALSE; | 274 | mHasShaderObjects = FALSE; |
275 | mHasPointParameters = FALSE; | ||
270 | 276 | ||
271 | #if LL_WINDOWS | 277 | #if LL_WINDOWS |
272 | mHasWGLARBPixelFormat = FALSE; | 278 | mHasWGLARBPixelFormat = FALSE; |
@@ -290,7 +296,6 @@ LLGLManager::LLGLManager() | |||
290 | mVRAM = 0; | 296 | mVRAM = 0; |
291 | mGLMaxVertexRange = 0; | 297 | mGLMaxVertexRange = 0; |
292 | mGLMaxIndexRange = 0; | 298 | mGLMaxIndexRange = 0; |
293 | mSoftwareBlendSSE = TRUE; | ||
294 | } | 299 | } |
295 | 300 | ||
296 | //--------------------------------------------------------------------- | 301 | //--------------------------------------------------------------------- |
@@ -506,8 +511,6 @@ extern LLCPUInfo gSysCPU; | |||
506 | 511 | ||
507 | void LLGLManager::initExtensions() | 512 | void LLGLManager::initExtensions() |
508 | { | 513 | { |
509 | mSoftwareBlendSSE = gSysCPU.hasSSE(); | ||
510 | |||
511 | #if LL_MESA_HEADLESS | 514 | #if LL_MESA_HEADLESS |
512 | # if GL_ARB_multitexture | 515 | # if GL_ARB_multitexture |
513 | mHasMultitexture = TRUE; | 516 | mHasMultitexture = TRUE; |
@@ -538,6 +541,7 @@ void LLGLManager::initExtensions() | |||
538 | mHasCubeMap = FALSE; | 541 | mHasCubeMap = FALSE; |
539 | mHasATIVAO = FALSE; | 542 | mHasATIVAO = FALSE; |
540 | mHasOcclusionQuery = FALSE; | 543 | mHasOcclusionQuery = FALSE; |
544 | mHasPointParameters = FALSE; | ||
541 | mHasShaderObjects = FALSE; | 545 | mHasShaderObjects = FALSE; |
542 | mHasVertexShader = FALSE; | 546 | mHasVertexShader = FALSE; |
543 | mHasFragmentShader = FALSE; | 547 | mHasFragmentShader = FALSE; |
@@ -553,9 +557,12 @@ void LLGLManager::initExtensions() | |||
553 | mHasCubeMap = ExtensionExists("GL_ARB_texture_cube_map", gGLHExts.mSysExts); | 557 | mHasCubeMap = ExtensionExists("GL_ARB_texture_cube_map", gGLHExts.mSysExts); |
554 | mHasARBEnvCombine = ExtensionExists("GL_ARB_texture_env_combine", gGLHExts.mSysExts); | 558 | mHasARBEnvCombine = ExtensionExists("GL_ARB_texture_env_combine", gGLHExts.mSysExts); |
555 | mHasCompressedTextures = glh_init_extensions("GL_ARB_texture_compression"); | 559 | mHasCompressedTextures = glh_init_extensions("GL_ARB_texture_compression"); |
556 | mHasVertexBufferObject = ExtensionExists("GL_ARB_vertex_buffer_object", gGLHExts.mSysExts); | ||
557 | mHasATIVAO = ExtensionExists("GL_ATI_vertex_array_object", gGLHExts.mSysExts); | 560 | mHasATIVAO = ExtensionExists("GL_ATI_vertex_array_object", gGLHExts.mSysExts); |
558 | mHasOcclusionQuery = ExtensionExists("GL_ARB_occlusion_query", gGLHExts.mSysExts); | 561 | mHasOcclusionQuery = ExtensionExists("GL_ARB_occlusion_query", gGLHExts.mSysExts); |
562 | mHasVertexBufferObject = ExtensionExists("GL_ARB_vertex_buffer_object", gGLHExts.mSysExts); | ||
563 | #if !LL_DARWIN | ||
564 | mHasPointParameters = !mIsATI && ExtensionExists("GL_ARB_point_parameters", gGLHExts.mSysExts); | ||
565 | #endif | ||
559 | mHasShaderObjects = ExtensionExists("GL_ARB_shader_objects", gGLHExts.mSysExts) && ExtensionExists("GL_ARB_shading_language_100", gGLHExts.mSysExts); | 566 | mHasShaderObjects = ExtensionExists("GL_ARB_shader_objects", gGLHExts.mSysExts) && ExtensionExists("GL_ARB_shading_language_100", gGLHExts.mSysExts); |
560 | mHasVertexShader = ExtensionExists("GL_ARB_vertex_program", gGLHExts.mSysExts) && ExtensionExists("GL_ARB_vertex_shader", gGLHExts.mSysExts) | 567 | mHasVertexShader = ExtensionExists("GL_ARB_vertex_program", gGLHExts.mSysExts) && ExtensionExists("GL_ARB_vertex_shader", gGLHExts.mSysExts) |
561 | && ExtensionExists("GL_ARB_shading_language_100", gGLHExts.mSysExts); | 568 | && ExtensionExists("GL_ARB_shading_language_100", gGLHExts.mSysExts); |
@@ -565,7 +572,7 @@ void LLGLManager::initExtensions() | |||
565 | #if LL_LINUX | 572 | #if LL_LINUX |
566 | // Our extension support for the Linux Client is very young with some | 573 | // Our extension support for the Linux Client is very young with some |
567 | // potential driver gotchas, so offer a semi-secret way to turn it off. | 574 | // potential driver gotchas, so offer a semi-secret way to turn it off. |
568 | if (getenv("LL_GL_NOEXT")) | 575 | if (getenv("LL_GL_NOEXT")) /* Flawfinder: ignore */ |
569 | { | 576 | { |
570 | //mHasMultitexture = FALSE; // NEEDED! | 577 | //mHasMultitexture = FALSE; // NEEDED! |
571 | mHasARBEnvCombine = FALSE; | 578 | mHasARBEnvCombine = FALSE; |
@@ -580,13 +587,14 @@ void LLGLManager::initExtensions() | |||
580 | mHasCubeMap = FALSE; | 587 | mHasCubeMap = FALSE; |
581 | mHasATIVAO = FALSE; | 588 | mHasATIVAO = FALSE; |
582 | mHasOcclusionQuery = FALSE; | 589 | mHasOcclusionQuery = FALSE; |
590 | mHasPointParameters = FALSE; | ||
583 | mHasShaderObjects = FALSE; | 591 | mHasShaderObjects = FALSE; |
584 | mHasVertexShader = FALSE; | 592 | mHasVertexShader = FALSE; |
585 | mHasFragmentShader = FALSE; | 593 | mHasFragmentShader = FALSE; |
586 | llwarns << "GL extension support DISABLED via LL_GL_NOEXT" << | 594 | llwarns << "GL extension support DISABLED via LL_GL_NOEXT" << |
587 | llendl; | 595 | llendl; |
588 | } | 596 | } |
589 | else if (getenv("LL_GL_BASICEXT")) | 597 | else if (getenv("LL_GL_BASICEXT")) /* Flawfinder: ignore */ |
590 | { | 598 | { |
591 | // This switch attempts to turn off all support for exotic | 599 | // This switch attempts to turn off all support for exotic |
592 | // extensions which I believe correspond to fatal driver | 600 | // extensions which I believe correspond to fatal driver |
@@ -597,6 +605,7 @@ void LLGLManager::initExtensions() | |||
597 | mHasNVVertexArrayRange = FALSE; | 605 | mHasNVVertexArrayRange = FALSE; |
598 | mHasNVFence = FALSE; | 606 | mHasNVFence = FALSE; |
599 | mHasAnisotropic = FALSE; | 607 | mHasAnisotropic = FALSE; |
608 | mHasCubeMap = FALSE; // apparently fatal on Intel 915 & similar | ||
600 | mHasATIVAO = FALSE; | 609 | mHasATIVAO = FALSE; |
601 | mHasOcclusionQuery = FALSE; // source of many ATI system hangs | 610 | mHasOcclusionQuery = FALSE; // source of many ATI system hangs |
602 | mHasShaderObjects = FALSE; | 611 | mHasShaderObjects = FALSE; |
@@ -605,12 +614,12 @@ void LLGLManager::initExtensions() | |||
605 | llwarns << "GL extension support forced to SIMPLE level via LL_GL_BASICEXT" << | 614 | llwarns << "GL extension support forced to SIMPLE level via LL_GL_BASICEXT" << |
606 | llendl; | 615 | llendl; |
607 | } | 616 | } |
608 | if (getenv("LL_GL_BLACKLIST")) | 617 | if (getenv("LL_GL_BLACKLIST")) /* Flawfinder: ignore */ |
609 | { | 618 | { |
610 | // This lets advanced troubleshooters disable specific | 619 | // This lets advanced troubleshooters disable specific |
611 | // GL extensions to isolate problems with their hardware. | 620 | // GL extensions to isolate problems with their hardware. |
612 | // SL-28126 | 621 | // SL-28126 |
613 | const char *const blacklist = getenv("LL_GL_BLACKLIST"); | 622 | const char *const blacklist = getenv("LL_GL_BLACKLIST"); /* Flawfinder: ignore */ |
614 | llwarns << "GL extension support partially disabled via LL_GL_BLACKLIST: " << blacklist << llendl; | 623 | llwarns << "GL extension support partially disabled via LL_GL_BLACKLIST: " << blacklist << llendl; |
615 | if (strchr(blacklist,'a')) mHasARBEnvCombine = FALSE; | 624 | if (strchr(blacklist,'a')) mHasARBEnvCombine = FALSE; |
616 | if (strchr(blacklist,'b')) mHasCompressedTextures = FALSE; | 625 | if (strchr(blacklist,'b')) mHasCompressedTextures = FALSE; |
@@ -621,12 +630,13 @@ void LLGLManager::initExtensions() | |||
621 | if (strchr(blacklist,'g')) mHasNVFence = FALSE;//S | 630 | if (strchr(blacklist,'g')) mHasNVFence = FALSE;//S |
622 | if (strchr(blacklist,'h')) mHasSeparateSpecularColor = FALSE; | 631 | if (strchr(blacklist,'h')) mHasSeparateSpecularColor = FALSE; |
623 | if (strchr(blacklist,'i')) mHasAnisotropic = FALSE;//S | 632 | if (strchr(blacklist,'i')) mHasAnisotropic = FALSE;//S |
624 | if (strchr(blacklist,'j')) mHasCubeMap = FALSE; | 633 | if (strchr(blacklist,'j')) mHasCubeMap = FALSE;//S |
625 | if (strchr(blacklist,'k')) mHasATIVAO = FALSE;//S | 634 | if (strchr(blacklist,'k')) mHasATIVAO = FALSE;//S |
626 | if (strchr(blacklist,'l')) mHasOcclusionQuery = FALSE; | 635 | if (strchr(blacklist,'l')) mHasOcclusionQuery = FALSE; |
627 | if (strchr(blacklist,'m')) mHasShaderObjects = FALSE;//S | 636 | if (strchr(blacklist,'m')) mHasShaderObjects = FALSE;//S |
628 | if (strchr(blacklist,'n')) mHasVertexShader = FALSE;//S | 637 | if (strchr(blacklist,'n')) mHasVertexShader = FALSE;//S |
629 | if (strchr(blacklist,'o')) mHasFragmentShader = FALSE;//S | 638 | if (strchr(blacklist,'o')) mHasFragmentShader = FALSE;//S |
639 | if (strchr(blacklist,'p')) mHasPointParameters = FALSE;//S | ||
630 | } | 640 | } |
631 | #endif // LL_LINUX | 641 | #endif // LL_LINUX |
632 | 642 | ||
@@ -677,6 +687,10 @@ void LLGLManager::initExtensions() | |||
677 | { | 687 | { |
678 | llinfos << "Couldn't initialize GL_ARB_occlusion_query" << llendl; | 688 | llinfos << "Couldn't initialize GL_ARB_occlusion_query" << llendl; |
679 | } | 689 | } |
690 | if (!mHasPointParameters) | ||
691 | { | ||
692 | llinfos << "Couldn't initialize GL_ARB_point_parameters" << llendl; | ||
693 | } | ||
680 | if (!mHasShaderObjects) | 694 | if (!mHasShaderObjects) |
681 | { | 695 | { |
682 | llinfos << "Couldn't initialize GL_ARB_shader_objects" << llendl; | 696 | llinfos << "Couldn't initialize GL_ARB_shader_objects" << llendl; |
@@ -741,16 +755,23 @@ void LLGLManager::initExtensions() | |||
741 | if (mHasVertexBufferObject) | 755 | if (mHasVertexBufferObject) |
742 | { | 756 | { |
743 | glBindBufferARB = (PFNGLBINDBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("glBindBufferARB"); | 757 | glBindBufferARB = (PFNGLBINDBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("glBindBufferARB"); |
744 | glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)GLH_EXT_GET_PROC_ADDRESS("glDeleteBuffersARB"); | 758 | if (glBindBufferARB) |
745 | glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGenBuffersARB"); | 759 | { |
746 | glIsBufferARB = (PFNGLISBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("glIsBufferARB"); | 760 | glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)GLH_EXT_GET_PROC_ADDRESS("glDeleteBuffersARB"); |
747 | glBufferDataARB = (PFNGLBUFFERDATAARBPROC)GLH_EXT_GET_PROC_ADDRESS("glBufferDataARB"); | 761 | glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGenBuffersARB"); |
748 | glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)GLH_EXT_GET_PROC_ADDRESS("glBufferSubDataARB"); | 762 | glIsBufferARB = (PFNGLISBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("glIsBufferARB"); |
749 | glGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetBufferSubDataARB"); | 763 | glBufferDataARB = (PFNGLBUFFERDATAARBPROC)GLH_EXT_GET_PROC_ADDRESS("glBufferDataARB"); |
750 | glMapBufferARB = (PFNGLMAPBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMapBufferARB"); | 764 | glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)GLH_EXT_GET_PROC_ADDRESS("glBufferSubDataARB"); |
751 | glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("glUnmapBufferARB"); | 765 | glGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetBufferSubDataARB"); |
752 | glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetBufferParameterivARB"); | 766 | glMapBufferARB = (PFNGLMAPBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("glMapBufferARB"); |
753 | glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetBufferPointervARB"); | 767 | glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)GLH_EXT_GET_PROC_ADDRESS("glUnmapBufferARB"); |
768 | glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetBufferParameterivARB"); | ||
769 | glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetBufferPointervARB"); | ||
770 | } | ||
771 | else | ||
772 | { | ||
773 | mHasVertexBufferObject = FALSE; | ||
774 | } | ||
754 | } | 775 | } |
755 | if (mHasATIVAO) | 776 | if (mHasATIVAO) |
756 | { | 777 | { |
@@ -797,6 +818,11 @@ void LLGLManager::initExtensions() | |||
797 | glGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjectivARB"); | 818 | glGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjectivARB"); |
798 | glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjectuivARB"); | 819 | glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glGetQueryObjectuivARB"); |
799 | } | 820 | } |
821 | if (mHasPointParameters) | ||
822 | { | ||
823 | glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)GLH_EXT_GET_PROC_ADDRESS("glPointParameterfARB"); | ||
824 | glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glPointParameterfvARB"); | ||
825 | } | ||
800 | if (mHasShaderObjects) | 826 | if (mHasShaderObjects) |
801 | { | 827 | { |
802 | glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteObjectARB"); | 828 | glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteObjectARB"); |
@@ -991,6 +1017,7 @@ void LLGLState::dumpStates() | |||
991 | 1017 | ||
992 | void LLGLState::checkStates() | 1018 | void LLGLState::checkStates() |
993 | { | 1019 | { |
1020 | #if LL_DEBUG_GL | ||
994 | stop_glerror(); | 1021 | stop_glerror(); |
995 | 1022 | ||
996 | GLint activeTexture; | 1023 | GLint activeTexture; |
@@ -1025,10 +1052,12 @@ void LLGLState::checkStates() | |||
1025 | } | 1052 | } |
1026 | 1053 | ||
1027 | stop_glerror(); | 1054 | stop_glerror(); |
1055 | #endif | ||
1028 | } | 1056 | } |
1029 | 1057 | ||
1030 | void LLGLState::checkTextureChannels() | 1058 | void LLGLState::checkTextureChannels() |
1031 | { | 1059 | { |
1060 | #if LL_DEBUG_GL | ||
1032 | GLint activeTexture; | 1061 | GLint activeTexture; |
1033 | glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture); | 1062 | glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &activeTexture); |
1034 | 1063 | ||
@@ -1109,42 +1138,103 @@ void LLGLState::checkTextureChannels() | |||
1109 | { | 1138 | { |
1110 | LL_GL_ERRS << "GL texture state corruption detected." << llendl; | 1139 | LL_GL_ERRS << "GL texture state corruption detected." << llendl; |
1111 | } | 1140 | } |
1141 | #endif | ||
1112 | } | 1142 | } |
1113 | 1143 | ||
1114 | void LLGLState::checkClientArrays() | 1144 | void LLGLState::checkClientArrays(U32 data_mask) |
1115 | { | 1145 | { |
1146 | #if LL_DEBUG_GL | ||
1147 | stop_glerror(); | ||
1116 | BOOL error = FALSE; | 1148 | BOOL error = FALSE; |
1117 | static const char* label[] = | 1149 | static const char* label[] = |
1118 | { | 1150 | { |
1119 | //"GL_INDEX_ARRAY", | 1151 | "GL_VERTEX_ARRAY", |
1120 | "GL_NORMAL_ARRAY", | 1152 | "GL_NORMAL_ARRAY", |
1121 | //"GL_VERTEX_ARRAY", | ||
1122 | "GL_COLOR_ARRAY", | 1153 | "GL_COLOR_ARRAY", |
1123 | "GL_TEXTURE_COORD_ARRAY" | 1154 | "GL_TEXTURE_COORD_ARRAY" |
1124 | }; | 1155 | }; |
1125 | 1156 | ||
1126 | static GLint value[] = | 1157 | static GLint value[] = |
1127 | { | 1158 | { |
1128 | //GL_INDEX_ARRAY, | 1159 | GL_VERTEX_ARRAY, |
1129 | GL_NORMAL_ARRAY, | 1160 | GL_NORMAL_ARRAY, |
1130 | //GL_VERTEX_ARRAY, | ||
1131 | GL_COLOR_ARRAY, | 1161 | GL_COLOR_ARRAY, |
1132 | GL_TEXTURE_COORD_ARRAY | 1162 | GL_TEXTURE_COORD_ARRAY |
1163 | }; | ||
1164 | |||
1165 | U32 mask[] = | ||
1166 | { //copied from llvertexbuffer.h | ||
1167 | 0x0001, //MAP_VERTEX, | ||
1168 | 0x0002, //MAP_NORMAL, | ||
1169 | 0x0010, //MAP_COLOR, | ||
1170 | 0x0004, //MAP_TEXCOORD | ||
1133 | }; | 1171 | }; |
1134 | 1172 | ||
1135 | for (S32 j = 0; j < 3; j++) | 1173 | |
1174 | for (S32 j = 0; j < 4; j++) | ||
1136 | { | 1175 | { |
1137 | if (glIsEnabled(value[j])) | 1176 | if (glIsEnabled(value[j])) |
1138 | { | 1177 | { |
1178 | if (!(mask[j] & data_mask)) | ||
1179 | { | ||
1180 | error = TRUE; | ||
1181 | llwarns << "GL still has " << label[j] << " enabled." << llendl; | ||
1182 | } | ||
1183 | } | ||
1184 | else | ||
1185 | { | ||
1186 | if (mask[j] & data_mask) | ||
1187 | { | ||
1188 | error = TRUE; | ||
1189 | llwarns << "GL does not have " << label[j] << " enabled." << llendl; | ||
1190 | } | ||
1191 | } | ||
1192 | } | ||
1193 | |||
1194 | glClientActiveTextureARB(GL_TEXTURE1_ARB); | ||
1195 | glActiveTextureARB(GL_TEXTURE1_ARB); | ||
1196 | if (glIsEnabled(GL_TEXTURE_COORD_ARRAY)) | ||
1197 | { | ||
1198 | if (!(data_mask & 0x0008)) | ||
1199 | { | ||
1200 | error = TRUE; | ||
1201 | llwarns << "GL still has GL_TEXTURE_COORD_ARRAY enabled on channel 1." << llendl; | ||
1202 | } | ||
1203 | } | ||
1204 | else | ||
1205 | { | ||
1206 | if (data_mask & 0x0008) | ||
1207 | { | ||
1139 | error = TRUE; | 1208 | error = TRUE; |
1140 | llwarns << "GL still has " << label[j] << " enabled." << llendl; | 1209 | llwarns << "GL does not have GL_TEXTURE_COORD_ARRAY enabled on channel 1." << llendl; |
1141 | } | 1210 | } |
1142 | } | 1211 | } |
1143 | 1212 | ||
1213 | if (glIsEnabled(GL_TEXTURE_2D)) | ||
1214 | { | ||
1215 | if (!(data_mask & 0x0008)) | ||
1216 | { | ||
1217 | error = TRUE; | ||
1218 | llwarns << "GL still has GL_TEXTURE_2D enabled on channel 1." << llendl; | ||
1219 | } | ||
1220 | } | ||
1221 | else | ||
1222 | { | ||
1223 | if (data_mask & 0x0008) | ||
1224 | { | ||
1225 | error = TRUE; | ||
1226 | llwarns << "GL does not have GL_TEXTURE_2D enabled on channel 1." << llendl; | ||
1227 | } | ||
1228 | } | ||
1229 | |||
1230 | glClientActiveTextureARB(GL_TEXTURE0_ARB); | ||
1231 | glActiveTextureARB(GL_TEXTURE0_ARB); | ||
1232 | |||
1144 | if (error) | 1233 | if (error) |
1145 | { | 1234 | { |
1146 | LL_GL_ERRS << "GL client array corruption detected." << llendl; | 1235 | LL_GL_ERRS << "GL client array corruption detected." << llendl; |
1147 | } | 1236 | } |
1237 | #endif | ||
1148 | } | 1238 | } |
1149 | 1239 | ||
1150 | //============================================================================ | 1240 | //============================================================================ |
@@ -1190,9 +1280,8 @@ LLGLState::~LLGLState() | |||
1190 | stop_glerror(); | 1280 | stop_glerror(); |
1191 | if (mState) | 1281 | if (mState) |
1192 | { | 1282 | { |
1193 | #if LL_DEBUG | 1283 | #if LL_DEBUG_GL |
1194 | LLGLboolean cur_state = sStateMap[mState]; | 1284 | llassert(sStateMap[mState] == glIsEnabled(mState)); |
1195 | llassert(cur_state == glIsEnabled(mState)); | ||
1196 | #endif | 1285 | #endif |
1197 | if (mIsEnabled != mWasEnabled) | 1286 | if (mIsEnabled != mWasEnabled) |
1198 | { | 1287 | { |
@@ -1270,10 +1359,10 @@ void disable_cloth_weights(const S32 index) | |||
1270 | #endif | 1359 | #endif |
1271 | } | 1360 | } |
1272 | 1361 | ||
1273 | void set_vertex_weights(const S32 index, const F32 *weights) | 1362 | void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights) |
1274 | { | 1363 | { |
1275 | #if GL_ARB_vertex_program | 1364 | #if GL_ARB_vertex_program |
1276 | if (index > 0) glVertexAttribPointerARB(index, 1, GL_FLOAT, FALSE, 0, weights); | 1365 | if (index > 0) glVertexAttribPointerARB(index, 1, GL_FLOAT, FALSE, stride, weights); |
1277 | stop_glerror(); | 1366 | stop_glerror(); |
1278 | #endif | 1367 | #endif |
1279 | } | 1368 | } |
@@ -1321,7 +1410,7 @@ void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_sp | |||
1321 | } | 1410 | } |
1322 | 1411 | ||
1323 | LLString ver_copy( version ); | 1412 | LLString ver_copy( version ); |
1324 | S32 len = (S32)strlen( version ); | 1413 | S32 len = (S32)strlen( version ); /* Flawfinder: ignore */ |
1325 | S32 i = 0; | 1414 | S32 i = 0; |
1326 | S32 start; | 1415 | S32 start; |
1327 | // Find the major version | 1416 | // Find the major version |
diff --git a/linden/indra/llwindow/llgl.h b/linden/indra/llwindow/llgl.h index c0668ca..34bf400 100644 --- a/linden/indra/llwindow/llgl.h +++ b/linden/indra/llwindow/llgl.h | |||
@@ -73,6 +73,7 @@ public: | |||
73 | BOOL mHasVertexShader; | 73 | BOOL mHasVertexShader; |
74 | BOOL mHasFragmentShader; | 74 | BOOL mHasFragmentShader; |
75 | BOOL mHasOcclusionQuery; | 75 | BOOL mHasOcclusionQuery; |
76 | BOOL mHasPointParameters; | ||
76 | 77 | ||
77 | // nVidia extensions. | 78 | // nVidia extensions. |
78 | BOOL mHasAnisotropic; | 79 | BOOL mHasAnisotropic; |
@@ -117,7 +118,6 @@ public: | |||
117 | S32 mVRAM; // VRAM in MB | 118 | S32 mVRAM; // VRAM in MB |
118 | S32 mGLMaxVertexRange; | 119 | S32 mGLMaxVertexRange; |
119 | S32 mGLMaxIndexRange; | 120 | S32 mGLMaxIndexRange; |
120 | BOOL mSoftwareBlendSSE; | ||
121 | 121 | ||
122 | void getPixelFormat(); // Get the best pixel format | 122 | void getPixelFormat(); // Get the best pixel format |
123 | 123 | ||
@@ -223,7 +223,7 @@ public: | |||
223 | static void dumpStates(); | 223 | static void dumpStates(); |
224 | static void checkStates(); | 224 | static void checkStates(); |
225 | static void checkTextureChannels(); | 225 | static void checkTextureChannels(); |
226 | static void checkClientArrays(); | 226 | static void checkClientArrays(U32 data_mask = 0x0001); |
227 | 227 | ||
228 | protected: | 228 | protected: |
229 | static std::map<LLGLenum, LLGLboolean> sStateMap; | 229 | static std::map<LLGLenum, LLGLboolean> sStateMap; |
@@ -262,7 +262,7 @@ void enable_binormals(const S32 index); | |||
262 | void disable_binormals(const S32 index); | 262 | void disable_binormals(const S32 index); |
263 | void enable_cloth_weights(const S32 index); | 263 | void enable_cloth_weights(const S32 index); |
264 | void disable_cloth_weights(const S32 index); | 264 | void disable_cloth_weights(const S32 index); |
265 | void set_vertex_weights(const S32 index, const F32 *weights); | 265 | void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights); |
266 | void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights); | 266 | void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights); |
267 | void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals); | 267 | void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals); |
268 | void set_palette(U8* palette_data); | 268 | void set_palette(U8* palette_data); |
diff --git a/linden/indra/llwindow/llglheaders.h b/linden/indra/llwindow/llglheaders.h index e67b6c7..7c4d8fd 100644 --- a/linden/indra/llwindow/llglheaders.h +++ b/linden/indra/llwindow/llglheaders.h | |||
@@ -92,6 +92,10 @@ extern PFNGLGETQUERYIVARBPROC glGetQueryivARB; | |||
92 | extern PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB; | 92 | extern PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB; |
93 | extern PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB; | 93 | extern PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB; |
94 | 94 | ||
95 | // GL_ARB_point_parameters | ||
96 | extern PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB; | ||
97 | extern PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB; | ||
98 | |||
95 | // GL_ARB_shader_objects | 99 | // GL_ARB_shader_objects |
96 | extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; | 100 | extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; |
97 | extern PFNGLGETHANDLEARBPROC glGetHandleARB; | 101 | extern PFNGLGETHANDLEARBPROC glGetHandleARB; |
@@ -255,6 +259,10 @@ extern PFNGLGETQUERYIVARBPROC glGetQueryivARB; | |||
255 | extern PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB; | 259 | extern PFNGLGETQUERYOBJECTIVARBPROC glGetQueryObjectivARB; |
256 | extern PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB; | 260 | extern PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuivARB; |
257 | 261 | ||
262 | // GL_ARB_point_parameters | ||
263 | extern PFNGLPOINTPARAMETERFARBPROC glPointParameterfARB; | ||
264 | extern PFNGLPOINTPARAMETERFVARBPROC glPointParameterfvARB; | ||
265 | |||
258 | // GL_ARB_shader_objects | 266 | // GL_ARB_shader_objects |
259 | extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; | 267 | extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; |
260 | extern PFNGLGETHANDLEARBPROC glGetHandleARB; | 268 | extern PFNGLGETHANDLEARBPROC glGetHandleARB; |
@@ -435,7 +443,7 @@ typedef GLboolean (* glIsBufferARBProcPtr) (GLuint buffer); | |||
435 | typedef void (* glBufferDataARBProcPtr) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); | 443 | typedef void (* glBufferDataARBProcPtr) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); |
436 | typedef void (* glBufferSubDataARBProcPtr) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); | 444 | typedef void (* glBufferSubDataARBProcPtr) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); |
437 | typedef void (* glGetBufferSubDataARBProcPtr) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); | 445 | typedef void (* glGetBufferSubDataARBProcPtr) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); |
438 | typedef GLvoid* (* glMapBufferARBProcPtr) (GLenum target, GLenum access); | 446 | typedef GLvoid* (* glMapBufferARBProcPtr) (GLenum target, GLenum access); /* Flawfinder: ignore */ |
439 | typedef GLboolean (* glUnmapBufferARBProcPtr) (GLenum target); | 447 | typedef GLboolean (* glUnmapBufferARBProcPtr) (GLenum target); |
440 | typedef void (* glGetBufferParameterivARBProcPtr) (GLenum target, GLenum pname, GLint *params); | 448 | typedef void (* glGetBufferParameterivARBProcPtr) (GLenum target, GLenum pname, GLint *params); |
441 | typedef void (* glGetBufferPointervARBProcPtr) (GLenum target, GLenum pname, GLvoid* *params); | 449 | typedef void (* glGetBufferPointervARBProcPtr) (GLenum target, GLenum pname, GLvoid* *params); |
diff --git a/linden/indra/llwindow/llgltypes.h b/linden/indra/llwindow/llgltypes.h index 52a58b5..fffa979 100644 --- a/linden/indra/llwindow/llgltypes.h +++ b/linden/indra/llwindow/llgltypes.h | |||
@@ -1,8 +1,8 @@ | |||
1 | /** | 1 | /** |
2 | * @file llgltypes.h | 2 | * @file llgltypes.h |
3 | * @brief LLGL definition | 3 | * @brief LLGL definition |
4 | * | 4 | * |
5 | * Copyright (c) 2006-2007, Linden Research, Inc. | 5 | * Copyright (c) 2006-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 7 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 8 | * to you under the terms of the GNU General Public License, version 2.0 |
@@ -22,19 +22,19 @@ | |||
22 | * | 22 | * |
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
25 | * COMPLETENESS OR PERFORMANCE. | 25 | * COMPLETENESS OR PERFORMANCE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef LLGLTYPES_H | 28 | #ifndef LLGLTYPES_H |
29 | #define LLGLTYPES_H | 29 | #define LLGLTYPES_H |
30 | 30 | ||
31 | #define MAX_GL_TEXTURE_UNITS 16 | 31 | #define MAX_GL_TEXTURE_UNITS 16 |
32 | 32 | ||
33 | typedef U32 LLGLenum; | 33 | typedef U32 LLGLenum; |
34 | typedef U32 LLGLuint; | 34 | typedef U32 LLGLuint; |
35 | typedef S32 LLGLint; | 35 | typedef S32 LLGLint; |
36 | typedef F32 LLGLfloat; | 36 | typedef F32 LLGLfloat; |
37 | typedef F64 LLGLdouble; | 37 | typedef F64 LLGLdouble; |
38 | typedef U8 LLGLboolean; | 38 | typedef U8 LLGLboolean; |
39 | 39 | ||
40 | #endif | 40 | #endif |
diff --git a/linden/indra/llwindow/llkeyboard.cpp b/linden/indra/llwindow/llkeyboard.cpp index 409bb13..0da1644 100644 --- a/linden/indra/llwindow/llkeyboard.cpp +++ b/linden/indra/llwindow/llkeyboard.cpp | |||
@@ -330,7 +330,7 @@ LLString LLKeyboard::stringFromKey(KEY key) | |||
330 | LLString res = get_if_there(sKeysToNames, key, LLString::null); | 330 | LLString res = get_if_there(sKeysToNames, key, LLString::null); |
331 | if (res.empty()) | 331 | if (res.empty()) |
332 | { | 332 | { |
333 | char buffer[2]; | 333 | char buffer[2]; /* Flawfinder: ignore */ |
334 | buffer[0] = key; | 334 | buffer[0] = key; |
335 | buffer[1] = '\0'; | 335 | buffer[1] = '\0'; |
336 | res = LLString(buffer); | 336 | res = LLString(buffer); |
diff --git a/linden/indra/llwindow/llkeyboardwin32.cpp b/linden/indra/llwindow/llkeyboardwin32.cpp index e166ec2..33664b9 100644 --- a/linden/indra/llwindow/llkeyboardwin32.cpp +++ b/linden/indra/llwindow/llkeyboardwin32.cpp | |||
@@ -187,10 +187,7 @@ MASK LLKeyboardWin32::updateModifiers() | |||
187 | 187 | ||
188 | // Scan the modifier keys as of the last Windows key message | 188 | // Scan the modifier keys as of the last Windows key message |
189 | // (keydown encoded in high order bit of short) | 189 | // (keydown encoded in high order bit of short) |
190 | //setModifierKeyLevel( KEY_SHIFT, GetKeyState(VK_SHIFT) & 0x8000 ); | 190 | mKeyLevel[KEY_CAPSLOCK] = (GetKeyState(VK_CAPITAL) & 0x0001) != 0; // Low order bit carries the toggle state. |
191 | //setModifierKeyLevel( KEY_CONTROL, GetKeyState(VK_CONTROL) & 0x8000 ); | ||
192 | //setModifierKeyLevel( KEY_ALT, GetKeyState(VK_MENU) & 0x8000 ); | ||
193 | //setModifierKeyLevel( KEY_CAPSLOCK, GetKeyState(VK_CAPITAL) & 0x0001); // Low order bit carries the toggle state. | ||
194 | // Get mask for keyboard events | 191 | // Get mask for keyboard events |
195 | MASK mask = currentMask(FALSE); | 192 | MASK mask = currentMask(FALSE); |
196 | return mask; | 193 | return mask; |
@@ -214,7 +211,6 @@ BOOL LLKeyboardWin32::handleKeyDown(const U16 key, MASK mask) | |||
214 | return handled; | 211 | return handled; |
215 | } | 212 | } |
216 | 213 | ||
217 | |||
218 | // mask is ignored, except for extended flag -- we poll the modifier keys for the other flags | 214 | // mask is ignored, except for extended flag -- we poll the modifier keys for the other flags |
219 | BOOL LLKeyboardWin32::handleKeyUp(const U16 key, MASK mask) | 215 | BOOL LLKeyboardWin32::handleKeyUp(const U16 key, MASK mask) |
220 | { | 216 | { |
@@ -248,10 +244,14 @@ MASK LLKeyboardWin32::currentMask(BOOL) | |||
248 | void LLKeyboardWin32::scanKeyboard() | 244 | void LLKeyboardWin32::scanKeyboard() |
249 | { | 245 | { |
250 | S32 key; | 246 | S32 key; |
247 | MSG msg; | ||
248 | BOOL pending_key_events = PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE | PM_NOYIELD); | ||
251 | for (key = 0; key < KEY_COUNT; key++) | 249 | for (key = 0; key < KEY_COUNT; key++) |
252 | { | 250 | { |
253 | // On Windows, verify key down state. JC | 251 | // On Windows, verify key down state. JC |
254 | if (mKeyLevel[key]) | 252 | // RN: only do this if we don't have further key events in the queue |
253 | // as otherwise there might be key repeat events still waiting for this key we are now dumping | ||
254 | if (!pending_key_events && mKeyLevel[key]) | ||
255 | { | 255 | { |
256 | // *TODO: I KNOW there must be a better way of | 256 | // *TODO: I KNOW there must be a better way of |
257 | // interrogating the key state than this, using async key | 257 | // interrogating the key state than this, using async key |
@@ -262,9 +262,9 @@ void LLKeyboardWin32::scanKeyboard() | |||
262 | // ...translate back to windows key | 262 | // ...translate back to windows key |
263 | U16 virtual_key = inverseTranslateExtendedKey(key); | 263 | U16 virtual_key = inverseTranslateExtendedKey(key); |
264 | // keydown in highest bit | 264 | // keydown in highest bit |
265 | if (!(GetAsyncKeyState(virtual_key) & 0x8000)) | 265 | if (!pending_key_events && !(GetAsyncKeyState(virtual_key) & 0x8000)) |
266 | { | 266 | { |
267 | //llinfos << "Key up event missed, resetting" << llendl; | 267 | //llinfos << "Key up event missed, resetting" << llendl; |
268 | mKeyLevel[key] = FALSE; | 268 | mKeyLevel[key] = FALSE; |
269 | } | 269 | } |
270 | } | 270 | } |
diff --git a/linden/indra/llwindow/llmousehandler.h b/linden/indra/llwindow/llmousehandler.h index b907b55..4e9b882 100644 --- a/linden/indra/llwindow/llmousehandler.h +++ b/linden/indra/llwindow/llmousehandler.h | |||
@@ -28,10 +28,14 @@ | |||
28 | #ifndef LL_MOUSEHANDLER_H | 28 | #ifndef LL_MOUSEHANDLER_H |
29 | #define LL_MOUSEHANDLER_H | 29 | #define LL_MOUSEHANDLER_H |
30 | 30 | ||
31 | #include "llstring.h" | ||
32 | |||
31 | // Abstract interface. | 33 | // Abstract interface. |
32 | // Intended for use via multiple inheritance. | 34 | // Intended for use via multiple inheritance. |
33 | // A class may have as many interfaces as it likes, but never needs to inherit one more than once. | 35 | // A class may have as many interfaces as it likes, but never needs to inherit one more than once. |
34 | 36 | ||
37 | #include "llstring.h" | ||
38 | |||
35 | class LLMouseHandler | 39 | class LLMouseHandler |
36 | { | 40 | { |
37 | public: | 41 | public: |
diff --git a/linden/indra/llwindow/llwindow.h b/linden/indra/llwindow/llwindow.h index ac427f1..f4bb147 100644 --- a/linden/indra/llwindow/llwindow.h +++ b/linden/indra/llwindow/llwindow.h | |||
@@ -317,6 +317,7 @@ public: | |||
317 | // | 317 | // |
318 | // helper funcs | 318 | // helper funcs |
319 | // | 319 | // |
320 | extern BOOL gDebugWindowProc; | ||
320 | 321 | ||
321 | // Protocols, like "http" and "https" we support in URLs | 322 | // Protocols, like "http" and "https" we support in URLs |
322 | extern const S32 gURLProtocolWhitelistCount; | 323 | extern const S32 gURLProtocolWhitelistCount; |
diff --git a/linden/indra/llwindow/llwindow_vc8.vcproj b/linden/indra/llwindow/llwindow_vc8.vcproj new file mode 100644 index 0000000..b04477f --- /dev/null +++ b/linden/indra/llwindow/llwindow_vc8.vcproj | |||
@@ -0,0 +1,392 @@ | |||
1 | <?xml version="1.0" encoding="Windows-1252"?> | ||
2 | <VisualStudioProject | ||
3 | ProjectType="Visual C++" | ||
4 | Version="8.00" | ||
5 | Name="llwindow" | ||
6 | ProjectGUID="{B5B53617-416F-404A-BF10-22EBCCA0E4FB}" | ||
7 | Keyword="Win32Proj" | ||
8 | > | ||
9 | <Platforms> | ||
10 | <Platform | ||
11 | Name="Win32" | ||
12 | /> | ||
13 | </Platforms> | ||
14 | <ToolFiles> | ||
15 | </ToolFiles> | ||
16 | <Configurations> | ||
17 | <Configuration | ||
18 | Name="Debug|Win32" | ||
19 | OutputDirectory="../lib_$(ConfigurationName)/i686-win32" | ||
20 | IntermediateDirectory="Debug" | ||
21 | ConfigurationType="4" | ||
22 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" | ||
23 | CharacterSet="1" | ||
24 | > | ||
25 | <Tool | ||
26 | Name="VCPreBuildEventTool" | ||
27 | /> | ||
28 | <Tool | ||
29 | Name="VCCustomBuildTool" | ||
30 | /> | ||
31 | <Tool | ||
32 | Name="VCXMLDataGeneratorTool" | ||
33 | /> | ||
34 | <Tool | ||
35 | Name="VCWebServiceProxyGeneratorTool" | ||
36 | /> | ||
37 | <Tool | ||
38 | Name="VCMIDLTool" | ||
39 | /> | ||
40 | <Tool | ||
41 | Name="VCCLCompilerTool" | ||
42 | Optimization="0" | ||
43 | AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llxml;..\llvfs;..\llmessage;..\llscene;..\llimage;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
44 | PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG" | ||
45 | MinimalRebuild="true" | ||
46 | BasicRuntimeChecks="3" | ||
47 | RuntimeLibrary="1" | ||
48 | StructMemberAlignment="4" | ||
49 | TreatWChar_tAsBuiltInType="false" | ||
50 | ForceConformanceInForLoopScope="true" | ||
51 | UsePrecompiledHeader="0" | ||
52 | WarningLevel="3" | ||
53 | WarnAsError="true" | ||
54 | Detect64BitPortabilityProblems="false" | ||
55 | DebugInformationFormat="4" | ||
56 | /> | ||
57 | <Tool | ||
58 | Name="VCManagedResourceCompilerTool" | ||
59 | /> | ||
60 | <Tool | ||
61 | Name="VCResourceCompilerTool" | ||
62 | /> | ||
63 | <Tool | ||
64 | Name="VCPreLinkEventTool" | ||
65 | /> | ||
66 | <Tool | ||
67 | Name="VCLibrarianTool" | ||
68 | OutputFile="$(OutDir)/llwindow.lib" | ||
69 | /> | ||
70 | <Tool | ||
71 | Name="VCALinkTool" | ||
72 | /> | ||
73 | <Tool | ||
74 | Name="VCXDCMakeTool" | ||
75 | /> | ||
76 | <Tool | ||
77 | Name="VCBscMakeTool" | ||
78 | /> | ||
79 | <Tool | ||
80 | Name="VCFxCopTool" | ||
81 | /> | ||
82 | <Tool | ||
83 | Name="VCPostBuildEventTool" | ||
84 | /> | ||
85 | </Configuration> | ||
86 | <Configuration | ||
87 | Name="Release|Win32" | ||
88 | OutputDirectory="../lib_$(ConfigurationName)/i686-win32" | ||
89 | IntermediateDirectory="Release" | ||
90 | ConfigurationType="4" | ||
91 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" | ||
92 | CharacterSet="1" | ||
93 | > | ||
94 | <Tool | ||
95 | Name="VCPreBuildEventTool" | ||
96 | /> | ||
97 | <Tool | ||
98 | Name="VCCustomBuildTool" | ||
99 | /> | ||
100 | <Tool | ||
101 | Name="VCXMLDataGeneratorTool" | ||
102 | /> | ||
103 | <Tool | ||
104 | Name="VCWebServiceProxyGeneratorTool" | ||
105 | /> | ||
106 | <Tool | ||
107 | Name="VCMIDLTool" | ||
108 | /> | ||
109 | <Tool | ||
110 | Name="VCCLCompilerTool" | ||
111 | AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llxml;..\llvfs;..\llmessage;..\llscene;..\llimage;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
112 | PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" | ||
113 | RuntimeLibrary="0" | ||
114 | StructMemberAlignment="0" | ||
115 | TreatWChar_tAsBuiltInType="false" | ||
116 | ForceConformanceInForLoopScope="true" | ||
117 | UsePrecompiledHeader="0" | ||
118 | WarningLevel="3" | ||
119 | WarnAsError="true" | ||
120 | Detect64BitPortabilityProblems="false" | ||
121 | DebugInformationFormat="3" | ||
122 | /> | ||
123 | <Tool | ||
124 | Name="VCManagedResourceCompilerTool" | ||
125 | /> | ||
126 | <Tool | ||
127 | Name="VCResourceCompilerTool" | ||
128 | /> | ||
129 | <Tool | ||
130 | Name="VCPreLinkEventTool" | ||
131 | /> | ||
132 | <Tool | ||
133 | Name="VCLibrarianTool" | ||
134 | OutputFile="$(OutDir)/llwindow.lib" | ||
135 | /> | ||
136 | <Tool | ||
137 | Name="VCALinkTool" | ||
138 | /> | ||
139 | <Tool | ||
140 | Name="VCXDCMakeTool" | ||
141 | /> | ||
142 | <Tool | ||
143 | Name="VCBscMakeTool" | ||
144 | /> | ||
145 | <Tool | ||
146 | Name="VCFxCopTool" | ||
147 | /> | ||
148 | <Tool | ||
149 | Name="VCPostBuildEventTool" | ||
150 | /> | ||
151 | </Configuration> | ||
152 | <Configuration | ||
153 | Name="DebugMesaHeadless|Win32" | ||
154 | OutputDirectory="../lib_debug/i686-win32" | ||
155 | IntermediateDirectory="$(ConfigurationName)" | ||
156 | ConfigurationType="4" | ||
157 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" | ||
158 | CharacterSet="1" | ||
159 | > | ||
160 | <Tool | ||
161 | Name="VCPreBuildEventTool" | ||
162 | /> | ||
163 | <Tool | ||
164 | Name="VCCustomBuildTool" | ||
165 | /> | ||
166 | <Tool | ||
167 | Name="VCXMLDataGeneratorTool" | ||
168 | /> | ||
169 | <Tool | ||
170 | Name="VCWebServiceProxyGeneratorTool" | ||
171 | /> | ||
172 | <Tool | ||
173 | Name="VCMIDLTool" | ||
174 | /> | ||
175 | <Tool | ||
176 | Name="VCCLCompilerTool" | ||
177 | Optimization="0" | ||
178 | AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llxml;..\llvfs;..\llmessage;..\llscene;..\llimage;..\..\libraries\i686-win32\include;..\..\libraries\include\GLMESA;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
179 | PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG;LL_MESA;LL_MESA_HEADLESS" | ||
180 | MinimalRebuild="true" | ||
181 | BasicRuntimeChecks="3" | ||
182 | RuntimeLibrary="1" | ||
183 | StructMemberAlignment="4" | ||
184 | ForceConformanceInForLoopScope="true" | ||
185 | UsePrecompiledHeader="0" | ||
186 | WarningLevel="3" | ||
187 | WarnAsError="true" | ||
188 | Detect64BitPortabilityProblems="false" | ||
189 | DebugInformationFormat="4" | ||
190 | /> | ||
191 | <Tool | ||
192 | Name="VCManagedResourceCompilerTool" | ||
193 | /> | ||
194 | <Tool | ||
195 | Name="VCResourceCompilerTool" | ||
196 | /> | ||
197 | <Tool | ||
198 | Name="VCPreLinkEventTool" | ||
199 | /> | ||
200 | <Tool | ||
201 | Name="VCLibrarianTool" | ||
202 | OutputFile="$(OutDir)/llwindow_mesaheadless.lib" | ||
203 | /> | ||
204 | <Tool | ||
205 | Name="VCALinkTool" | ||
206 | /> | ||
207 | <Tool | ||
208 | Name="VCXDCMakeTool" | ||
209 | /> | ||
210 | <Tool | ||
211 | Name="VCBscMakeTool" | ||
212 | /> | ||
213 | <Tool | ||
214 | Name="VCFxCopTool" | ||
215 | /> | ||
216 | <Tool | ||
217 | Name="VCPostBuildEventTool" | ||
218 | /> | ||
219 | </Configuration> | ||
220 | <Configuration | ||
221 | Name="ReleaseNoOpt|Win32" | ||
222 | OutputDirectory="../lib_$(ConfigurationName)/i686-win32" | ||
223 | IntermediateDirectory="$(ConfigurationName)" | ||
224 | ConfigurationType="4" | ||
225 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" | ||
226 | CharacterSet="1" | ||
227 | > | ||
228 | <Tool | ||
229 | Name="VCPreBuildEventTool" | ||
230 | /> | ||
231 | <Tool | ||
232 | Name="VCCustomBuildTool" | ||
233 | /> | ||
234 | <Tool | ||
235 | Name="VCXMLDataGeneratorTool" | ||
236 | /> | ||
237 | <Tool | ||
238 | Name="VCWebServiceProxyGeneratorTool" | ||
239 | /> | ||
240 | <Tool | ||
241 | Name="VCMIDLTool" | ||
242 | /> | ||
243 | <Tool | ||
244 | Name="VCCLCompilerTool" | ||
245 | Optimization="0" | ||
246 | AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llxml;..\llvfs;..\llmessage;..\llscene;..\llimage;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
247 | PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" | ||
248 | RuntimeLibrary="0" | ||
249 | StructMemberAlignment="0" | ||
250 | TreatWChar_tAsBuiltInType="false" | ||
251 | ForceConformanceInForLoopScope="true" | ||
252 | UsePrecompiledHeader="0" | ||
253 | WarningLevel="3" | ||
254 | WarnAsError="true" | ||
255 | Detect64BitPortabilityProblems="false" | ||
256 | DebugInformationFormat="3" | ||
257 | /> | ||
258 | <Tool | ||
259 | Name="VCManagedResourceCompilerTool" | ||
260 | /> | ||
261 | <Tool | ||
262 | Name="VCResourceCompilerTool" | ||
263 | /> | ||
264 | <Tool | ||
265 | Name="VCPreLinkEventTool" | ||
266 | /> | ||
267 | <Tool | ||
268 | Name="VCLibrarianTool" | ||
269 | OutputFile="$(OutDir)/llwindow.lib" | ||
270 | /> | ||
271 | <Tool | ||
272 | Name="VCALinkTool" | ||
273 | /> | ||
274 | <Tool | ||
275 | Name="VCXDCMakeTool" | ||
276 | /> | ||
277 | <Tool | ||
278 | Name="VCBscMakeTool" | ||
279 | /> | ||
280 | <Tool | ||
281 | Name="VCFxCopTool" | ||
282 | /> | ||
283 | <Tool | ||
284 | Name="VCPostBuildEventTool" | ||
285 | /> | ||
286 | </Configuration> | ||
287 | </Configurations> | ||
288 | <References> | ||
289 | </References> | ||
290 | <Files> | ||
291 | <Filter | ||
292 | Name="Source Files" | ||
293 | Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" | ||
294 | UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" | ||
295 | > | ||
296 | <File | ||
297 | RelativePath=".\lldxhardware.cpp" | ||
298 | > | ||
299 | </File> | ||
300 | <File | ||
301 | RelativePath=".\llgl.cpp" | ||
302 | > | ||
303 | </File> | ||
304 | <File | ||
305 | RelativePath=".\llkeyboard.cpp" | ||
306 | > | ||
307 | </File> | ||
308 | <File | ||
309 | RelativePath=".\llkeyboardwin32.cpp" | ||
310 | > | ||
311 | </File> | ||
312 | <File | ||
313 | RelativePath=".\llwindow.cpp" | ||
314 | > | ||
315 | </File> | ||
316 | <File | ||
317 | RelativePath=".\llwindowheadless.cpp" | ||
318 | > | ||
319 | </File> | ||
320 | <File | ||
321 | RelativePath=".\llwindowmesaheadless.cpp" | ||
322 | > | ||
323 | </File> | ||
324 | <File | ||
325 | RelativePath=".\llwindowwin32.cpp" | ||
326 | > | ||
327 | </File> | ||
328 | </Filter> | ||
329 | <Filter | ||
330 | Name="Header Files" | ||
331 | Filter="h;hpp;hxx;hm;inl;inc;xsd" | ||
332 | UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" | ||
333 | > | ||
334 | <File | ||
335 | RelativePath=".\lldxhardware.h" | ||
336 | > | ||
337 | </File> | ||
338 | <File | ||
339 | RelativePath=".\llgl.h" | ||
340 | > | ||
341 | </File> | ||
342 | <File | ||
343 | RelativePath=".\llglheaders.h" | ||
344 | > | ||
345 | </File> | ||
346 | <File | ||
347 | RelativePath=".\llglstates.h" | ||
348 | > | ||
349 | </File> | ||
350 | <File | ||
351 | RelativePath=".\llgltypes.h" | ||
352 | > | ||
353 | </File> | ||
354 | <File | ||
355 | RelativePath=".\llkeyboard.h" | ||
356 | > | ||
357 | </File> | ||
358 | <File | ||
359 | RelativePath=".\llkeyboardwin32.h" | ||
360 | > | ||
361 | </File> | ||
362 | <File | ||
363 | RelativePath=".\llmousehandler.h" | ||
364 | > | ||
365 | </File> | ||
366 | <File | ||
367 | RelativePath=".\llwindow.h" | ||
368 | > | ||
369 | </File> | ||
370 | <File | ||
371 | RelativePath=".\llwindowheadless.h" | ||
372 | > | ||
373 | </File> | ||
374 | <File | ||
375 | RelativePath=".\llwindowmesaheadless.h" | ||
376 | > | ||
377 | </File> | ||
378 | <File | ||
379 | RelativePath=".\llwindowwin32.h" | ||
380 | > | ||
381 | </File> | ||
382 | </Filter> | ||
383 | <Filter | ||
384 | Name="Resource Files" | ||
385 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" | ||
386 | UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" | ||
387 | > | ||
388 | </Filter> | ||
389 | </Files> | ||
390 | <Globals> | ||
391 | </Globals> | ||
392 | </VisualStudioProject> | ||
diff --git a/linden/indra/llwindow/llwindowmacosx.cpp b/linden/indra/llwindow/llwindowmacosx.cpp index d990bb5..7313fd3 100644 --- a/linden/indra/llwindow/llwindowmacosx.cpp +++ b/linden/indra/llwindow/llwindowmacosx.cpp | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "linden_common.h" | 30 | #include "linden_common.h" |
31 | 31 | ||
32 | #include <Carbon/Carbon.h> | 32 | #include <Carbon/Carbon.h> |
33 | #include <OpenGL/OpenGL.h> | ||
33 | 34 | ||
34 | #include "llwindowmacosx.h" | 35 | #include "llwindowmacosx.h" |
35 | #include "llkeyboardmacosx.h" | 36 | #include "llkeyboardmacosx.h" |
@@ -89,8 +90,8 @@ BOOL check_for_card(const char* RENDERER, const char* bad_card) | |||
89 | { | 90 | { |
90 | if (!strnicmp(RENDERER, bad_card, strlen(bad_card))) | 91 | if (!strnicmp(RENDERER, bad_card, strlen(bad_card))) |
91 | { | 92 | { |
92 | char buffer[1024]; | 93 | char buffer[1024];/* Flawfinder: ignore */ |
93 | sprintf(buffer, | 94 | snprintf(buffer, sizeof(buffer), /* Flawfinder: ignore */ |
94 | "Your video card appears to be a %s, which Second Life does not support.\n" | 95 | "Your video card appears to be a %s, which Second Life does not support.\n" |
95 | "\n" | 96 | "\n" |
96 | "Second Life requires a video card with 32 Mb of memory or more, as well as\n" | 97 | "Second Life requires a video card with 32 Mb of memory or more, as well as\n" |
@@ -246,8 +247,8 @@ LLWindowMacOSX::LLWindowMacOSX(char *title, char *name, S32 x, S32 y, S32 width, | |||
246 | mOriginalAspectRatio = (double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay); | 247 | mOriginalAspectRatio = (double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay); |
247 | 248 | ||
248 | // Stash the window title | 249 | // Stash the window title |
249 | strcpy((char*)mWindowTitle + 1, title); | 250 | strcpy((char*)mWindowTitle + 1, title); /* Flawfinder: ignore */ |
250 | mWindowTitle[0] = strlen(title); | 251 | mWindowTitle[0] = strlen(title); /* Flawfinder: ignore */ |
251 | 252 | ||
252 | mEventHandlerUPP = NewEventHandlerUPP(staticEventHandler); | 253 | mEventHandlerUPP = NewEventHandlerUPP(staticEventHandler); |
253 | mGlobalHandlerRef = NULL; | 254 | mGlobalHandlerRef = NULL; |
@@ -424,8 +425,8 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits | |||
424 | mFullscreenBits = -1; | 425 | mFullscreenBits = -1; |
425 | mFullscreenRefresh = -1; | 426 | mFullscreenRefresh = -1; |
426 | 427 | ||
427 | char error[256]; | 428 | char error[256]; /* Flawfinder: ignore */ |
428 | sprintf(error, "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); | 429 | snprintf(error, sizeof(error), "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); /* Flawfinder: ignore */ |
429 | OSMessageBox(error, "Error", OSMB_OK); | 430 | OSMessageBox(error, "Error", OSMB_OK); |
430 | } | 431 | } |
431 | } | 432 | } |
@@ -738,6 +739,22 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits | |||
738 | } | 739 | } |
739 | aglSetInteger(mContext, AGL_SWAP_INTERVAL, &frames_per_swap); | 740 | aglSetInteger(mContext, AGL_SWAP_INTERVAL, &frames_per_swap); |
740 | 741 | ||
742 | #if 0 // SJB: Got a compile error. Plus I don't want to test this along with everything else ; save it for later | ||
743 | //enable multi-threaded OpenGL | ||
744 | CGLError cgl_err; | ||
745 | CGLContextObj ctx = CGLGetCurrentContext(); | ||
746 | |||
747 | cgl_err = CGLEnable( ctx, kCGLCEMPEngine); | ||
748 | |||
749 | if (cgl_err != kCGLNoError ) | ||
750 | { | ||
751 | llinfos << "Multi-threaded OpenGL not available." << llendl; | ||
752 | } | ||
753 | else | ||
754 | { | ||
755 | llinfos << "Multi-threaded OpenGL enabled." << llendl; | ||
756 | } | ||
757 | #endif | ||
741 | // Don't need to get the current gamma, since there's a call that restores it to the system defaults. | 758 | // Don't need to get the current gamma, since there's a call that restores it to the system defaults. |
742 | return TRUE; | 759 | return TRUE; |
743 | } | 760 | } |
@@ -2738,7 +2755,7 @@ void spawn_web_browser(const char* escaped_url) | |||
2738 | S32 i; | 2755 | S32 i; |
2739 | for (i = 0; i < gURLProtocolWhitelistCount; i++) | 2756 | for (i = 0; i < gURLProtocolWhitelistCount; i++) |
2740 | { | 2757 | { |
2741 | S32 len = strlen(gURLProtocolWhitelist[i]); | 2758 | S32 len = strlen(gURLProtocolWhitelist[i]); /* Flawfinder: ignore */ |
2742 | if (!strncmp(escaped_url, gURLProtocolWhitelist[i], len) | 2759 | if (!strncmp(escaped_url, gURLProtocolWhitelist[i], len) |
2743 | && escaped_url[len] == ':') | 2760 | && escaped_url[len] == ':') |
2744 | { | 2761 | { |
diff --git a/linden/indra/llwindow/llwindowsdl.cpp b/linden/indra/llwindow/llwindowsdl.cpp index a94284e..85836af 100644 --- a/linden/indra/llwindow/llwindowsdl.cpp +++ b/linden/indra/llwindow/llwindowsdl.cpp | |||
@@ -68,20 +68,12 @@ const S32 MAX_NUM_RESOLUTIONS = 32; | |||
68 | 68 | ||
69 | #if LL_X11 | 69 | #if LL_X11 |
70 | # include <X11/Xutil.h> | 70 | # include <X11/Xutil.h> |
71 | // A global! Well, SDL isn't really designed for communicating | ||
72 | // with multiple physical X11 displays. Heck, it's not really | ||
73 | // designed for multiple X11 windows. | ||
74 | // So, we need this for the SDL/X11 event filter callback (which | ||
75 | // doesnt have a userdata parameter) and more. | ||
76 | static Display *SDL_Display = NULL; | ||
77 | static Window SDL_XWindowID = None; | ||
78 | #endif //LL_X11 | 71 | #endif //LL_X11 |
79 | 72 | ||
80 | // TOFU HACK -- (*exactly* the same hack as LLWindowMacOSX for the same reasons) | 73 | // TOFU HACK -- (*exactly* the same hack as LLWindowMacOSX for a similar |
81 | // For SDL, to put up an OS dialog in full screen mode, we must first switch OUT of full screen mode. | 74 | // set of reasons): Stash a pointer to the LLWindowSDL object here and |
82 | // The proper way to do this is to bracket the dialog with calls to beforeDialog() and afterDialog(), but these | 75 | // maintain in the constructor and destructor. This assumes that there will |
83 | // require a pointer to the LLWindowMacSDL object. Stash it here and maintain in the constructor and destructor. | 76 | // be only one object of this class at any time. Hopefully this is true. |
84 | // This assumes that there will be only one object of this class at any time. Hopefully this is true. | ||
85 | static LLWindowSDL *gWindowImplementation = NULL; | 77 | static LLWindowSDL *gWindowImplementation = NULL; |
86 | 78 | ||
87 | static BOOL was_fullscreen = FALSE; | 79 | static BOOL was_fullscreen = FALSE; |
@@ -113,14 +105,51 @@ void show_window_creation_error(const char* title) | |||
113 | } | 105 | } |
114 | 106 | ||
115 | 107 | ||
108 | void maybe_lock_display(void) | ||
109 | { | ||
110 | if (gWindowImplementation) { | ||
111 | gWindowImplementation->Lock_Display(); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | |||
116 | void maybe_unlock_display(void) | ||
117 | { | ||
118 | if (gWindowImplementation) { | ||
119 | gWindowImplementation->Unlock_Display(); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | |||
116 | #if LL_GTK | 124 | #if LL_GTK |
117 | // Check the runtime GTK version for goodness. | 125 | // Lazily initialize and check the runtime GTK version for goodness. |
118 | static BOOL maybe_do_gtk_diagnostics(void) | 126 | BOOL ll_try_gtk_init(void) |
119 | { | 127 | { |
120 | static BOOL done_gtk_diag = FALSE; | 128 | static BOOL done_gtk_diag = FALSE; |
121 | static BOOL is_good = TRUE; | 129 | static BOOL gtk_is_good = FALSE; |
122 | gtk_disable_setlocale(); | 130 | static BOOL done_setlocale = FALSE; |
123 | if ((!done_gtk_diag) && gtk_init_check(NULL, NULL)) | 131 | static BOOL tried_gtk_init = FALSE; |
132 | |||
133 | if (!done_setlocale) | ||
134 | { | ||
135 | llinfos << "Starting GTK Initialization." << llendl; | ||
136 | maybe_lock_display(); | ||
137 | gtk_disable_setlocale(); | ||
138 | maybe_unlock_display(); | ||
139 | done_setlocale = TRUE; | ||
140 | } | ||
141 | |||
142 | if (!tried_gtk_init) | ||
143 | { | ||
144 | tried_gtk_init = TRUE; | ||
145 | maybe_lock_display(); | ||
146 | gtk_is_good = gtk_init_check(NULL, NULL); | ||
147 | maybe_unlock_display(); | ||
148 | if (!gtk_is_good) | ||
149 | llwarns << "GTK Initialization failed." << llendl; | ||
150 | } | ||
151 | |||
152 | if (gtk_is_good && !done_gtk_diag) | ||
124 | { | 153 | { |
125 | llinfos << "GTK Initialized." << llendl; | 154 | llinfos << "GTK Initialized." << llendl; |
126 | llinfos << "- Compiled against GTK version " | 155 | llinfos << "- Compiled against GTK version " |
@@ -132,29 +161,51 @@ static BOOL maybe_do_gtk_diagnostics(void) | |||
132 | << gtk_minor_version << "." | 161 | << gtk_minor_version << "." |
133 | << gtk_micro_version << llendl; | 162 | << gtk_micro_version << llendl; |
134 | gchar *gtk_warning; | 163 | gchar *gtk_warning; |
164 | maybe_lock_display(); | ||
135 | gtk_warning = gtk_check_version(GTK_MAJOR_VERSION, | 165 | gtk_warning = gtk_check_version(GTK_MAJOR_VERSION, |
136 | GTK_MINOR_VERSION, | 166 | GTK_MINOR_VERSION, |
137 | GTK_MICRO_VERSION); | 167 | GTK_MICRO_VERSION); |
168 | maybe_unlock_display(); | ||
138 | if (gtk_warning) | 169 | if (gtk_warning) |
139 | { | 170 | { |
140 | llwarns << "- GTK COMPATIBILITY WARNING: " << | 171 | llwarns << "- GTK COMPATIBILITY WARNING: " << |
141 | gtk_warning << llendl; | 172 | gtk_warning << llendl; |
142 | is_good = FALSE; | 173 | gtk_is_good = FALSE; |
143 | } | 174 | } |
144 | 175 | ||
145 | done_gtk_diag = TRUE; | 176 | done_gtk_diag = TRUE; |
146 | } | 177 | } |
147 | return is_good; | 178 | |
179 | return gtk_is_good; | ||
148 | } | 180 | } |
149 | #endif // LL_GTK | 181 | #endif // LL_GTK |
150 | 182 | ||
151 | 183 | ||
184 | #if LL_X11 | ||
185 | Window get_SDL_XWindowID(void) | ||
186 | { | ||
187 | if (gWindowImplementation) { | ||
188 | return gWindowImplementation->mSDL_XWindowID; | ||
189 | } | ||
190 | return None; | ||
191 | } | ||
192 | |||
193 | Display* get_SDL_Display(void) | ||
194 | { | ||
195 | if (gWindowImplementation) { | ||
196 | return gWindowImplementation->mSDL_Display; | ||
197 | } | ||
198 | return NULL; | ||
199 | } | ||
200 | #endif // LL_X11 | ||
201 | |||
202 | |||
152 | BOOL check_for_card(const char* RENDERER, const char* bad_card) | 203 | BOOL check_for_card(const char* RENDERER, const char* bad_card) |
153 | { | 204 | { |
154 | if (!strncasecmp(RENDERER, bad_card, strlen(bad_card))) | 205 | if (!strncasecmp(RENDERER, bad_card, strlen(bad_card))) |
155 | { | 206 | { |
156 | char buffer[1024]; | 207 | char buffer[1024]; /* Flawfinder: ignore */ |
157 | sprintf(buffer, | 208 | snprintf(buffer, sizeof(buffer), /* Flawfinder: ignore */ |
158 | "Your video card appears to be a %s, which Second Life does not support.\n" | 209 | "Your video card appears to be a %s, which Second Life does not support.\n" |
159 | "\n" | 210 | "\n" |
160 | "Second Life requires a video card with 32 Mb of memory or more, as well as\n" | 211 | "Second Life requires a video card with 32 Mb of memory or more, as well as\n" |
@@ -209,6 +260,19 @@ LLWindowSDL::LLWindowSDL(char *title, S32 x, S32 y, S32 width, | |||
209 | mHaveInputFocus = -1; | 260 | mHaveInputFocus = -1; |
210 | mIsMinimized = -1; | 261 | mIsMinimized = -1; |
211 | 262 | ||
263 | #if LL_X11 | ||
264 | mSDL_XWindowID = None; | ||
265 | mSDL_Display = NULL; | ||
266 | #endif // LL_X11 | ||
267 | |||
268 | #if LL_GTK | ||
269 | // We MUST be the first to initialize GTK, i.e. we have to beat | ||
270 | // our embedded Mozilla to the punch so that GTK doesn't get badly | ||
271 | // initialized with a non-C locale and cause lots of serious random | ||
272 | // weirdness. | ||
273 | ll_try_gtk_init(); | ||
274 | #endif // LL_GTK | ||
275 | |||
212 | // Get the original aspect ratio of the main device. | 276 | // Get the original aspect ratio of the main device. |
213 | mOriginalAspectRatio = 1024.0 / 768.0; // !!! FIXME //(double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay); | 277 | mOriginalAspectRatio = 1024.0 / 768.0; // !!! FIXME //(double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay); |
214 | 278 | ||
@@ -216,9 +280,14 @@ LLWindowSDL::LLWindowSDL(char *title, S32 x, S32 y, S32 width, | |||
216 | title = "SDL Window"; // *FIX: (???) | 280 | title = "SDL Window"; // *FIX: (???) |
217 | 281 | ||
218 | // Stash the window title | 282 | // Stash the window title |
219 | mWindowTitle = new char[strlen(title) + 1]; | 283 | mWindowTitle = new char[strlen(title) + 1]; /* Flawfinder: ignore */ |
220 | strcpy(mWindowTitle, title); | 284 | if(mWindowTitle == NULL) |
285 | { | ||
286 | llerrs << "Memory allocation failure" << llendl; | ||
287 | return; | ||
288 | } | ||
221 | 289 | ||
290 | strcpy(mWindowTitle, title); /* Flawfinder: ignore */ | ||
222 | // Create the GL context and set it up for windowed or fullscreen, as appropriate. | 291 | // Create the GL context and set it up for windowed or fullscreen, as appropriate. |
223 | if(createContext(x, y, width, height, 32, fullscreen, disable_vsync)) | 292 | if(createContext(x, y, width, height, 32, fullscreen, disable_vsync)) |
224 | { | 293 | { |
@@ -242,10 +311,10 @@ LLWindowSDL::LLWindowSDL(char *title, S32 x, S32 y, S32 width, | |||
242 | static SDL_Surface *Load_BMP_Resource(const char *basename) | 311 | static SDL_Surface *Load_BMP_Resource(const char *basename) |
243 | { | 312 | { |
244 | const int PATH_BUFFER_SIZE=1000; | 313 | const int PATH_BUFFER_SIZE=1000; |
245 | char path_buffer[PATH_BUFFER_SIZE]; | 314 | char path_buffer[PATH_BUFFER_SIZE]; /* Flawfinder: ignore */ |
246 | 315 | ||
247 | // Figure out where our BMP is living on the disk | 316 | // Figure out where our BMP is living on the disk |
248 | snprintf(path_buffer, PATH_BUFFER_SIZE-1, "%s%sres-sdl%s%s", | 317 | snprintf(path_buffer, PATH_BUFFER_SIZE-1, "%s%sres-sdl%s%s", /* Flawfinder: ignore */ |
249 | gDirUtilp->getAppRODataDir().c_str(), | 318 | gDirUtilp->getAppRODataDir().c_str(), |
250 | gDirUtilp->getDirDelimiter().c_str(), | 319 | gDirUtilp->getDirDelimiter().c_str(), |
251 | gDirUtilp->getDirDelimiter().c_str(), | 320 | gDirUtilp->getDirDelimiter().c_str(), |
@@ -271,7 +340,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B | |||
271 | { | 340 | { |
272 | llinfos << "sdl_init() failed! " << SDL_GetError() << llendl; | 341 | llinfos << "sdl_init() failed! " << SDL_GetError() << llendl; |
273 | setupFailure("window creation error", "error", OSMB_OK); | 342 | setupFailure("window creation error", "error", OSMB_OK); |
274 | return false; | 343 | return false; |
275 | } | 344 | } |
276 | 345 | ||
277 | SDL_version c_sdl_version; | 346 | SDL_version c_sdl_version; |
@@ -415,8 +484,8 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B | |||
415 | mFullscreenBits = -1; | 484 | mFullscreenBits = -1; |
416 | mFullscreenRefresh = -1; | 485 | mFullscreenRefresh = -1; |
417 | 486 | ||
418 | char error[256]; | 487 | char error[256]; /* Flawfinder: ignore */ |
419 | sprintf(error, "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); | 488 | snprintf(error, sizeof(error), "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); /* Flawfinder: ignore */ |
420 | OSMessageBox(error, "Error", OSMB_OK); | 489 | OSMessageBox(error, "Error", OSMB_OK); |
421 | } | 490 | } |
422 | } | 491 | } |
@@ -948,24 +1017,29 @@ void LLWindowSDL::beforeDialog() | |||
948 | } | 1017 | } |
949 | 1018 | ||
950 | #if LL_X11 | 1019 | #if LL_X11 |
951 | if (SDL_Display) | 1020 | if (mSDL_Display) |
952 | { | 1021 | { |
953 | // Everything that we/SDL asked for should happen before we | 1022 | // Everything that we/SDL asked for should happen before we |
954 | // potentially hand control over to GTK. | 1023 | // potentially hand control over to GTK. |
955 | XSync(SDL_Display, False); | 1024 | XSync(mSDL_Display, False); |
956 | } | 1025 | } |
957 | #endif // LL_X11 | 1026 | #endif // LL_X11 |
958 | 1027 | ||
959 | #if LL_GTK | 1028 | #if LL_GTK |
960 | // this is a good time to grab some GTK version information for | 1029 | // this is a good time to grab some GTK version information for |
961 | // diagnostics | 1030 | // diagnostics, if not already done. |
962 | maybe_do_gtk_diagnostics(); | 1031 | ll_try_gtk_init(); |
963 | #endif // LL_GTK | 1032 | #endif // LL_GTK |
1033 | |||
1034 | maybe_lock_display(); | ||
964 | } | 1035 | } |
965 | 1036 | ||
966 | void LLWindowSDL::afterDialog() | 1037 | void LLWindowSDL::afterDialog() |
967 | { | 1038 | { |
968 | llinfos << "LLWindowSDL::afterDialog()" << llendl; | 1039 | llinfos << "LLWindowSDL::afterDialog()" << llendl; |
1040 | |||
1041 | maybe_unlock_display(); | ||
1042 | |||
969 | if (old_fullscreen && !was_fullscreen) | 1043 | if (old_fullscreen && !was_fullscreen) |
970 | { | 1044 | { |
971 | // *FIX: NOT YET WORKING (see below) | 1045 | // *FIX: NOT YET WORKING (see below) |
@@ -985,13 +1059,13 @@ S32 LLWindowSDL::stat(const char* file_name, struct stat* stat_info) | |||
985 | // set/reset the XWMHints flag for 'urgency' that usually makes the icon flash | 1059 | // set/reset the XWMHints flag for 'urgency' that usually makes the icon flash |
986 | void LLWindowSDL::x11_set_urgent(BOOL urgent) | 1060 | void LLWindowSDL::x11_set_urgent(BOOL urgent) |
987 | { | 1061 | { |
988 | if (SDL_Display && !mFullscreen) | 1062 | if (mSDL_Display && !mFullscreen) |
989 | { | 1063 | { |
990 | XWMHints *wm_hints; | 1064 | XWMHints *wm_hints; |
991 | 1065 | ||
992 | llinfos << "X11 hint for urgency, " << urgent << llendl; | 1066 | llinfos << "X11 hint for urgency, " << urgent << llendl; |
993 | 1067 | ||
994 | wm_hints = XGetWMHints(SDL_Display, mSDL_XWindowID); | 1068 | wm_hints = XGetWMHints(mSDL_Display, mSDL_XWindowID); |
995 | if (!wm_hints) | 1069 | if (!wm_hints) |
996 | wm_hints = XAllocWMHints(); | 1070 | wm_hints = XAllocWMHints(); |
997 | 1071 | ||
@@ -1000,9 +1074,9 @@ void LLWindowSDL::x11_set_urgent(BOOL urgent) | |||
1000 | else | 1074 | else |
1001 | wm_hints->flags &= ~XUrgencyHint; | 1075 | wm_hints->flags &= ~XUrgencyHint; |
1002 | 1076 | ||
1003 | XSetWMHints(SDL_Display, mSDL_XWindowID, wm_hints); | 1077 | XSetWMHints(mSDL_Display, mSDL_XWindowID, wm_hints); |
1004 | XFree(wm_hints); | 1078 | XFree(wm_hints); |
1005 | XSync(SDL_Display, False); | 1079 | XSync(mSDL_Display, False); |
1006 | } | 1080 | } |
1007 | } | 1081 | } |
1008 | #endif // LL_X11 | 1082 | #endif // LL_X11 |
@@ -1035,6 +1109,8 @@ void LLWindowSDL::flashIcon(F32 seconds) | |||
1035 | right now it has the rare and desirable trait of being | 1109 | right now it has the rare and desirable trait of being |
1036 | generally stable and working. */ | 1110 | generally stable and working. */ |
1037 | 1111 | ||
1112 | typedef Atom x11clipboard_type; | ||
1113 | |||
1038 | /* PRIMARY and CLIPBOARD are the two main kinds of | 1114 | /* PRIMARY and CLIPBOARD are the two main kinds of |
1039 | X11 clipboard. A third are the CUT_BUFFERs which an | 1115 | X11 clipboard. A third are the CUT_BUFFERs which an |
1040 | obsolete holdover from X10 days and use a quite orthogonal | 1116 | obsolete holdover from X10 days and use a quite orthogonal |
@@ -1047,26 +1123,52 @@ void LLWindowSDL::flashIcon(F32 seconds) | |||
1047 | we support (to as full an extent as the clipboard content type | 1123 | we support (to as full an extent as the clipboard content type |
1048 | allows) CLIPBOARD, PRIMARY, and CUT_BUFFER0. | 1124 | allows) CLIPBOARD, PRIMARY, and CUT_BUFFER0. |
1049 | */ | 1125 | */ |
1050 | #define SL_READWRITE_XCLIPBOARD_TYPE XInternAtom(SDL_Display, "CLIPBOARD", False) | 1126 | static x11clipboard_type get_x11_readwrite_clipboard_type(void) |
1051 | #define SL_WRITE_XCLIPBOARD_TYPE XA_PRIMARY | 1127 | { |
1128 | return XInternAtom(get_SDL_Display(), "CLIPBOARD", False); | ||
1129 | } | ||
1130 | |||
1131 | static x11clipboard_type get_x11_write_clipboard_type(void) | ||
1132 | { | ||
1133 | return XA_PRIMARY; | ||
1134 | } | ||
1052 | 1135 | ||
1053 | /* This is where our own private cutbuffer goes - we don't use | 1136 | /* This is where our own private cutbuffer goes - we don't use |
1054 | a regular cutbuffer (XA_CUT_BUFFER0 etc) for intermediate | 1137 | a regular cutbuffer (XA_CUT_BUFFER0 etc) for intermediate |
1055 | storage because their use isn't really defined for holding UTF8. */ | 1138 | storage because their use isn't really defined for holding UTF8. */ |
1056 | #define SL_CUTBUFFER_TYPE XInternAtom(SDL_Display, "SECONDLIFE_CUTBUFFER", False) | 1139 | static x11clipboard_type get_x11_cutbuffer_clipboard_type(void) |
1140 | { | ||
1141 | return XInternAtom(get_SDL_Display(), "SECONDLIFE_CUTBUFFER", False); | ||
1142 | } | ||
1143 | |||
1144 | /* Some X11 atom-generators */ | ||
1145 | static Atom get_x11_targets_atom(void) | ||
1146 | { | ||
1147 | return XInternAtom(get_SDL_Display(), "TARGETS", False); | ||
1148 | } | ||
1149 | |||
1150 | static Atom get_x11_text_atom(void) | ||
1151 | { | ||
1152 | return XInternAtom(get_SDL_Display(), "TEXT", False); | ||
1153 | } | ||
1057 | 1154 | ||
1058 | /* These defines, and convert_data/convert_x11clipboard, | 1155 | /* These defines, and convert_data/convert_x11clipboard, |
1059 | mostly exist to support non-text or unusually-encoded | 1156 | mostly exist to support non-text or unusually-encoded |
1060 | clipboard data, which we don't really have a need for at | 1157 | clipboard data, which we don't really have a need for at |
1061 | the moment. */ | 1158 | the moment. */ |
1062 | #define SDLCLIPTYPE(A, B, C, D) (int)((A<<24)|(B<<16)|(C<<8)|(D<<0)) | 1159 | #define SDLCLIPTYPE(A, B, C, D) (int)(((A)<<24)|((B)<<16)|((C)<<8)|((D)<<0)) |
1063 | #define FORMAT_PREFIX "SECONDLIFE_x11clipboard_0x" | 1160 | #define FORMAT_PREFIX "SECONDLIFE_x11clipboard_0x" |
1064 | 1161 | ||
1065 | typedef Atom x11clipboard_type; | ||
1066 | |||
1067 | static | 1162 | static |
1068 | x11clipboard_type convert_format(int type) | 1163 | x11clipboard_type convert_format(int type) |
1069 | { | 1164 | { |
1165 | if (!gWindowImplementation) | ||
1166 | { | ||
1167 | llwarns << "!gWindowImplementation in convert_format()" | ||
1168 | << llendl; | ||
1169 | return XA_STRING; | ||
1170 | } | ||
1171 | |||
1070 | switch (type) | 1172 | switch (type) |
1071 | { | 1173 | { |
1072 | case SDLCLIPTYPE('T', 'E', 'X', 'T'): | 1174 | case SDLCLIPTYPE('T', 'E', 'X', 'T'): |
@@ -1074,15 +1176,17 @@ x11clipboard_type convert_format(int type) | |||
1074 | return XA_STRING; | 1176 | return XA_STRING; |
1075 | case SDLCLIPTYPE('U', 'T', 'F', '8'): | 1177 | case SDLCLIPTYPE('U', 'T', 'F', '8'): |
1076 | // newer de-facto UTF8 clipboard atom | 1178 | // newer de-facto UTF8 clipboard atom |
1077 | return XInternAtom(SDL_Display, "UTF8_STRING", False); | 1179 | return XInternAtom(gWindowImplementation->mSDL_Display, |
1180 | "UTF8_STRING", False); | ||
1078 | default: | 1181 | default: |
1079 | { | 1182 | { |
1080 | /* completely arbitrary clipboard types... we don't actually use | 1183 | /* completely arbitrary clipboard types... we don't actually use |
1081 | these right now, and support is skeletal. */ | 1184 | these right now, and support is skeletal. */ |
1082 | char format[sizeof(FORMAT_PREFIX)+8+1]; | 1185 | char format[sizeof(FORMAT_PREFIX)+8+1]; /* Flawfinder: ignore */ |
1083 | 1186 | ||
1084 | sprintf(format, "%s%08lx", FORMAT_PREFIX, (unsigned long)type); | 1187 | snprintf(format, sizeof(format), "%s%08lx", FORMAT_PREFIX, (unsigned long)type); /* Flawfinder: ignore */ |
1085 | return XInternAtom(SDL_Display, format, False); | 1188 | return XInternAtom(gWindowImplementation->mSDL_Display, |
1189 | format, False); | ||
1086 | } | 1190 | } |
1087 | } | 1191 | } |
1088 | } | 1192 | } |
@@ -1099,14 +1203,18 @@ convert_data(int type, char *dst, const char *src, int srclen) | |||
1099 | { | 1203 | { |
1100 | case SDLCLIPTYPE('T', 'E', 'X', 'T'): | 1204 | case SDLCLIPTYPE('T', 'E', 'X', 'T'): |
1101 | case SDLCLIPTYPE('U', 'T', 'F', '8'): | 1205 | case SDLCLIPTYPE('U', 'T', 'F', '8'): |
1206 | if (src == NULL) | ||
1207 | { | ||
1208 | break; | ||
1209 | } | ||
1102 | if ( srclen == 0 ) | 1210 | if ( srclen == 0 ) |
1103 | srclen = strlen(src); | 1211 | srclen = strlen(src); /* Flawfinder: ignore */ |
1104 | 1212 | ||
1105 | dstlen = srclen + 1; | 1213 | dstlen = srclen + 1; |
1106 | 1214 | ||
1107 | if ( dst ) // assume caller made it big enough by asking us | 1215 | if ( dst ) // assume caller made it big enough by asking us |
1108 | { | 1216 | { |
1109 | memcpy(dst, src, srclen); | 1217 | memcpy(dst, src, srclen); /* Flawfinder: ignore */ |
1110 | dst[srclen] = '\0'; | 1218 | dst[srclen] = '\0'; |
1111 | } | 1219 | } |
1112 | break; | 1220 | break; |
@@ -1131,14 +1239,18 @@ convert_x11clipboard(int type, char *dst, const char *src, int srclen) | |||
1131 | { | 1239 | { |
1132 | case SDLCLIPTYPE('U', 'T', 'F', '8'): | 1240 | case SDLCLIPTYPE('U', 'T', 'F', '8'): |
1133 | case SDLCLIPTYPE('T', 'E', 'X', 'T'): | 1241 | case SDLCLIPTYPE('T', 'E', 'X', 'T'): |
1242 | if (src == NULL) | ||
1243 | { | ||
1244 | break; | ||
1245 | } | ||
1134 | if ( srclen == 0 ) | 1246 | if ( srclen == 0 ) |
1135 | srclen = strlen(src); | 1247 | srclen = strlen(src); /* Flawfinder: ignore */ |
1136 | 1248 | ||
1137 | dstlen = srclen + 1; | 1249 | dstlen = srclen + 1; |
1138 | 1250 | ||
1139 | if ( dst ) // assume caller made it big enough by asking us | 1251 | if ( dst ) // assume caller made it big enough by asking us |
1140 | { | 1252 | { |
1141 | memcpy(dst, src, srclen); | 1253 | memcpy(dst, src, srclen); /* Flawfinder: ignore */ |
1142 | dst[srclen] = '\0'; | 1254 | dst[srclen] = '\0'; |
1143 | } | 1255 | } |
1144 | break; | 1256 | break; |
@@ -1155,9 +1267,9 @@ LLWindowSDL::is_empty_x11clipboard(void) | |||
1155 | { | 1267 | { |
1156 | int retval; | 1268 | int retval; |
1157 | 1269 | ||
1158 | Lock_Display(); | 1270 | maybe_lock_display(); |
1159 | retval = ( XGetSelectionOwner(SDL_Display, SL_READWRITE_XCLIPBOARD_TYPE) == None ); | 1271 | retval = ( XGetSelectionOwner(mSDL_Display, get_x11_readwrite_clipboard_type()) == None ); |
1160 | Unlock_Display(); | 1272 | maybe_unlock_display(); |
1161 | 1273 | ||
1162 | return(retval); | 1274 | return(retval); |
1163 | } | 1275 | } |
@@ -1175,8 +1287,8 @@ LLWindowSDL::put_x11clipboard(int type, int srclen, const char *src) | |||
1175 | dst = (char *)malloc(dstlen); | 1287 | dst = (char *)malloc(dstlen); |
1176 | if ( dst != NULL ) | 1288 | if ( dst != NULL ) |
1177 | { | 1289 | { |
1178 | Window root = DefaultRootWindow(SDL_Display); | 1290 | maybe_lock_display(); |
1179 | Lock_Display(); | 1291 | Window root = DefaultRootWindow(mSDL_Display); |
1180 | convert_data(type, dst, src, srclen); | 1292 | convert_data(type, dst, src, srclen); |
1181 | // Cutbuffers are only allowed to have STRING atom types, | 1293 | // Cutbuffers are only allowed to have STRING atom types, |
1182 | // but Emacs puts UTF8 inside them anyway. We cautiously | 1294 | // but Emacs puts UTF8 inside them anyway. We cautiously |
@@ -1185,7 +1297,7 @@ LLWindowSDL::put_x11clipboard(int type, int srclen, const char *src) | |||
1185 | { | 1297 | { |
1186 | // dstlen-1 so we don't include the trailing \0 | 1298 | // dstlen-1 so we don't include the trailing \0 |
1187 | llinfos << "X11: Populating cutbuffer." <<llendl; | 1299 | llinfos << "X11: Populating cutbuffer." <<llendl; |
1188 | XChangeProperty(SDL_Display, root, | 1300 | XChangeProperty(mSDL_Display, root, |
1189 | XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, | 1301 | XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, |
1190 | (unsigned char*)dst, dstlen-1); | 1302 | (unsigned char*)dst, dstlen-1); |
1191 | } else { | 1303 | } else { |
@@ -1194,18 +1306,18 @@ LLWindowSDL::put_x11clipboard(int type, int srclen, const char *src) | |||
1194 | //XDeleteProperty(SDL_Display, root, XA_CUT_BUFFER0); | 1306 | //XDeleteProperty(SDL_Display, root, XA_CUT_BUFFER0); |
1195 | } | 1307 | } |
1196 | // Private cutbuffer of an appropriate type. | 1308 | // Private cutbuffer of an appropriate type. |
1197 | XChangeProperty(SDL_Display, root, | 1309 | XChangeProperty(mSDL_Display, root, |
1198 | SL_CUTBUFFER_TYPE, format, 8, PropModeReplace, | 1310 | get_x11_cutbuffer_clipboard_type(), format, 8, PropModeReplace, |
1199 | (unsigned char*)dst, dstlen-1); | 1311 | (unsigned char*)dst, dstlen-1); |
1200 | free(dst); | 1312 | free(dst); |
1201 | 1313 | ||
1202 | /* Claim ownership of both PRIMARY and CLIPBOARD */ | 1314 | /* Claim ownership of both PRIMARY and CLIPBOARD */ |
1203 | XSetSelectionOwner(SDL_Display, SL_READWRITE_XCLIPBOARD_TYPE, | 1315 | XSetSelectionOwner(mSDL_Display, get_x11_readwrite_clipboard_type(), |
1204 | mSDL_XWindowID, CurrentTime); | 1316 | mSDL_XWindowID, CurrentTime); |
1205 | XSetSelectionOwner(SDL_Display, SL_WRITE_XCLIPBOARD_TYPE, | 1317 | XSetSelectionOwner(mSDL_Display, get_x11_write_clipboard_type(), |
1206 | mSDL_XWindowID, CurrentTime); | 1318 | mSDL_XWindowID, CurrentTime); |
1207 | 1319 | ||
1208 | Unlock_Display(); | 1320 | maybe_unlock_display(); |
1209 | } | 1321 | } |
1210 | } | 1322 | } |
1211 | 1323 | ||
@@ -1225,19 +1337,19 @@ LLWindowSDL::get_x11clipboard(int type, int *dstlen, char **dst) | |||
1225 | unsigned long overflow; | 1337 | unsigned long overflow; |
1226 | char *src; | 1338 | char *src; |
1227 | 1339 | ||
1228 | Lock_Display(); | 1340 | maybe_lock_display(); |
1229 | owner = XGetSelectionOwner(SDL_Display, SL_READWRITE_XCLIPBOARD_TYPE); | 1341 | owner = XGetSelectionOwner(mSDL_Display, get_x11_readwrite_clipboard_type()); |
1230 | Unlock_Display(); | 1342 | maybe_unlock_display(); |
1231 | if (owner == None) | 1343 | if (owner == None) |
1232 | { | 1344 | { |
1233 | // Fall right back to ancient X10 cut-buffers | 1345 | // Fall right back to ancient X10 cut-buffers |
1234 | owner = DefaultRootWindow(SDL_Display); | 1346 | owner = DefaultRootWindow(mSDL_Display); |
1235 | selection = XA_CUT_BUFFER0; | 1347 | selection = XA_CUT_BUFFER0; |
1236 | } else if (owner == mSDL_XWindowID) | 1348 | } else if (owner == mSDL_XWindowID) |
1237 | { | 1349 | { |
1238 | // Use our own uncooked opaque string property | 1350 | // Use our own uncooked opaque string property |
1239 | owner = DefaultRootWindow(SDL_Display); | 1351 | owner = DefaultRootWindow(mSDL_Display); |
1240 | selection = SL_CUTBUFFER_TYPE; | 1352 | selection = get_x11_cutbuffer_clipboard_type(); |
1241 | } | 1353 | } |
1242 | else | 1354 | else |
1243 | { | 1355 | { |
@@ -1246,11 +1358,11 @@ LLWindowSDL::get_x11clipboard(int type, int *dstlen, char **dst) | |||
1246 | SDL_Event event; | 1358 | SDL_Event event; |
1247 | 1359 | ||
1248 | owner = mSDL_XWindowID; | 1360 | owner = mSDL_XWindowID; |
1249 | Lock_Display(); | 1361 | maybe_lock_display(); |
1250 | selection = XInternAtom(SDL_Display, "SDL_SELECTION", False); | 1362 | selection = XInternAtom(mSDL_Display, "SDL_SELECTION", False); |
1251 | XConvertSelection(SDL_Display, SL_READWRITE_XCLIPBOARD_TYPE, format, | 1363 | XConvertSelection(mSDL_Display, get_x11_readwrite_clipboard_type(), format, |
1252 | selection, owner, CurrentTime); | 1364 | selection, owner, CurrentTime); |
1253 | Unlock_Display(); | 1365 | maybe_unlock_display(); |
1254 | llinfos << "X11: Waiting for clipboard to arrive." <<llendl; | 1366 | llinfos << "X11: Waiting for clipboard to arrive." <<llendl; |
1255 | while ( ! selection_response ) | 1367 | while ( ! selection_response ) |
1256 | { | 1368 | { |
@@ -1276,8 +1388,8 @@ LLWindowSDL::get_x11clipboard(int type, int *dstlen, char **dst) | |||
1276 | llinfos << "X11: Clipboard arrived." <<llendl; | 1388 | llinfos << "X11: Clipboard arrived." <<llendl; |
1277 | } | 1389 | } |
1278 | 1390 | ||
1279 | Lock_Display(); | 1391 | maybe_lock_display(); |
1280 | if ( XGetWindowProperty(SDL_Display, owner, selection, 0, INT_MAX/4, | 1392 | if ( XGetWindowProperty(mSDL_Display, owner, selection, 0, INT_MAX/4, |
1281 | False, format, &seln_type, &seln_format, | 1393 | False, format, &seln_type, &seln_format, |
1282 | &nbytes, &overflow, (unsigned char **)&src) == Success ) | 1394 | &nbytes, &overflow, (unsigned char **)&src) == Success ) |
1283 | { | 1395 | { |
@@ -1292,8 +1404,7 @@ LLWindowSDL::get_x11clipboard(int type, int *dstlen, char **dst) | |||
1292 | } | 1404 | } |
1293 | XFree(src); | 1405 | XFree(src); |
1294 | } | 1406 | } |
1295 | 1407 | maybe_unlock_display(); | |
1296 | Unlock_Display(); | ||
1297 | } | 1408 | } |
1298 | 1409 | ||
1299 | int clipboard_filter_callback(const SDL_Event *event) | 1410 | int clipboard_filter_callback(const SDL_Event *event) |
@@ -1306,7 +1417,7 @@ int clipboard_filter_callback(const SDL_Event *event) | |||
1306 | 1417 | ||
1307 | /* Handle window-manager specific clipboard events */ | 1418 | /* Handle window-manager specific clipboard events */ |
1308 | switch (event->syswm.msg->event.xevent.type) { | 1419 | switch (event->syswm.msg->event.xevent.type) { |
1309 | /* Copy the selection from SL_CUTBUFFER_TYPE to the requested property */ | 1420 | /* Copy the selection from SECONDLIFE_CUTBUFFER to the requested property */ |
1310 | case SelectionRequest: { | 1421 | case SelectionRequest: { |
1311 | XSelectionRequestEvent *req; | 1422 | XSelectionRequestEvent *req; |
1312 | XEvent sevent; | 1423 | XEvent sevent; |
@@ -1323,8 +1434,8 @@ int clipboard_filter_callback(const SDL_Event *event) | |||
1323 | sevent.xselection.property = None; | 1434 | sevent.xselection.property = None; |
1324 | sevent.xselection.requestor = req->requestor; | 1435 | sevent.xselection.requestor = req->requestor; |
1325 | sevent.xselection.time = req->time; | 1436 | sevent.xselection.time = req->time; |
1326 | if ( XGetWindowProperty(SDL_Display, DefaultRootWindow(SDL_Display), | 1437 | if ( XGetWindowProperty(get_SDL_Display(), DefaultRootWindow(get_SDL_Display()), |
1327 | SL_CUTBUFFER_TYPE, 0, INT_MAX/4, False, req->target, | 1438 | get_x11_cutbuffer_clipboard_type(), 0, INT_MAX/4, False, req->target, |
1328 | &sevent.xselection.target, &seln_format, | 1439 | &sevent.xselection.target, &seln_format, |
1329 | &nbytes, &overflow, &seln_data) == Success ) | 1440 | &nbytes, &overflow, &seln_data) == Success ) |
1330 | { | 1441 | { |
@@ -1337,21 +1448,20 @@ int clipboard_filter_callback(const SDL_Event *event) | |||
1337 | if ( seln_data[nbytes-1] == '\0' ) | 1448 | if ( seln_data[nbytes-1] == '\0' ) |
1338 | --nbytes; | 1449 | --nbytes; |
1339 | } | 1450 | } |
1340 | XChangeProperty(SDL_Display, req->requestor, req->property, | 1451 | XChangeProperty(get_SDL_Display(), req->requestor, req->property, |
1341 | req->target, seln_format, PropModeReplace, | 1452 | req->target, seln_format, PropModeReplace, |
1342 | seln_data, nbytes); | 1453 | seln_data, nbytes); |
1343 | sevent.xselection.property = req->property; | 1454 | sevent.xselection.property = req->property; |
1344 | #define XA_TARGETS XInternAtom(SDL_Display, "TARGETS", False) | 1455 | } else if (get_x11_targets_atom() == req->target) { |
1345 | } else if (XA_TARGETS == req->target) { | ||
1346 | /* only advertise what we currently support */ | 1456 | /* only advertise what we currently support */ |
1347 | const int num_supported = 3; | 1457 | const int num_supported = 3; |
1348 | Atom supported[num_supported] = { | 1458 | Atom supported[num_supported] = { |
1349 | XA_STRING, // will be over-written below | 1459 | XA_STRING, // will be over-written below |
1350 | XInternAtom(SDL_Display, "TEXT",False), | 1460 | get_x11_text_atom(), |
1351 | XA_TARGETS | 1461 | get_x11_targets_atom() |
1352 | }; | 1462 | }; |
1353 | supported[0] = sevent.xselection.target; | 1463 | supported[0] = sevent.xselection.target; |
1354 | XChangeProperty(SDL_Display, req->requestor, | 1464 | XChangeProperty(get_SDL_Display(), req->requestor, |
1355 | req->property, XA_ATOM, 32, PropModeReplace, | 1465 | req->property, XA_ATOM, 32, PropModeReplace, |
1356 | (unsigned char*)supported, | 1466 | (unsigned char*)supported, |
1357 | num_supported); | 1467 | num_supported); |
@@ -1364,10 +1474,10 @@ int clipboard_filter_callback(const SDL_Event *event) | |||
1364 | XFree(seln_data); | 1474 | XFree(seln_data); |
1365 | } | 1475 | } |
1366 | int sendret = | 1476 | int sendret = |
1367 | XSendEvent(SDL_Display,req->requestor,False,0,&sevent); | 1477 | XSendEvent(get_SDL_Display(),req->requestor,False,0,&sevent); |
1368 | if ((sendret==BadValue) || (sendret==BadWindow)) | 1478 | if ((sendret==BadValue) || (sendret==BadWindow)) |
1369 | llwarns << "Clipboard SendEvent failed" << llendl; | 1479 | llwarns << "Clipboard SendEvent failed" << llendl; |
1370 | XSync(SDL_Display, False); | 1480 | XSync(get_SDL_Display(), False); |
1371 | } | 1481 | } |
1372 | break; | 1482 | break; |
1373 | } | 1483 | } |
@@ -1392,8 +1502,7 @@ LLWindowSDL::init_x11clipboard(void) | |||
1392 | /* Save the information for later use */ | 1502 | /* Save the information for later use */ |
1393 | if ( info.subsystem == SDL_SYSWM_X11 ) | 1503 | if ( info.subsystem == SDL_SYSWM_X11 ) |
1394 | { | 1504 | { |
1395 | SDL_Display = info.info.x11.display; | 1505 | mSDL_Display = info.info.x11.display; |
1396 | SDL_XWindowID = info.info.x11.wmwindow; | ||
1397 | mSDL_XWindowID = info.info.x11.wmwindow; | 1506 | mSDL_XWindowID = info.info.x11.wmwindow; |
1398 | Lock_Display = info.info.x11.lock_func; | 1507 | Lock_Display = info.info.x11.lock_func; |
1399 | Unlock_Display = info.info.x11.unlock_func; | 1508 | Unlock_Display = info.info.x11.unlock_func; |
@@ -1415,8 +1524,7 @@ LLWindowSDL::init_x11clipboard(void) | |||
1415 | void | 1524 | void |
1416 | LLWindowSDL::quit_x11clipboard(void) | 1525 | LLWindowSDL::quit_x11clipboard(void) |
1417 | { | 1526 | { |
1418 | SDL_Display = NULL; | 1527 | mSDL_Display = NULL; |
1419 | SDL_XWindowID = None; | ||
1420 | mSDL_XWindowID = None; | 1528 | mSDL_XWindowID = None; |
1421 | Lock_Display = NULL; | 1529 | Lock_Display = NULL; |
1422 | Unlock_Display = NULL; | 1530 | Unlock_Display = NULL; |
@@ -1470,7 +1578,11 @@ BOOL LLWindowSDL::copyTextToClipboard(const LLWString &s) | |||
1470 | { | 1578 | { |
1471 | std::string utf8text = wstring_to_utf8str(s); | 1579 | std::string utf8text = wstring_to_utf8str(s); |
1472 | const char* cstr = utf8text.c_str(); | 1580 | const char* cstr = utf8text.c_str(); |
1473 | int cstrlen = strlen(cstr); | 1581 | if (cstr == NULL) |
1582 | { | ||
1583 | return FALSE; | ||
1584 | } | ||
1585 | int cstrlen = strlen(cstr); /* Flawfinder: ignore */ | ||
1474 | int i; | 1586 | int i; |
1475 | for (i=0; i<cstrlen; ++i) | 1587 | for (i=0; i<cstrlen; ++i) |
1476 | { | 1588 | { |
@@ -1653,7 +1765,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) | |||
1653 | if (!mFullscreen) /* only bother if we're windowed anyway */ | 1765 | if (!mFullscreen) /* only bother if we're windowed anyway */ |
1654 | { | 1766 | { |
1655 | #if LL_X11 | 1767 | #if LL_X11 |
1656 | if (SDL_Display) | 1768 | if (mSDL_Display) |
1657 | { | 1769 | { |
1658 | /* we dirtily mix raw X11 with SDL so that our pointer | 1770 | /* we dirtily mix raw X11 with SDL so that our pointer |
1659 | isn't (as often) constrained to the limits of the | 1771 | isn't (as often) constrained to the limits of the |
@@ -1669,7 +1781,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) | |||
1669 | { | 1781 | { |
1670 | //llinfos << "X11 POINTER GRABBY" << llendl; | 1782 | //llinfos << "X11 POINTER GRABBY" << llendl; |
1671 | //newmode = SDL_WM_GrabInput(wantmode); | 1783 | //newmode = SDL_WM_GrabInput(wantmode); |
1672 | result = XGrabPointer(SDL_Display, mSDL_XWindowID, | 1784 | result = XGrabPointer(mSDL_Display, mSDL_XWindowID, |
1673 | True, 0, GrabModeAsync, | 1785 | True, 0, GrabModeAsync, |
1674 | GrabModeAsync, | 1786 | GrabModeAsync, |
1675 | None, None, CurrentTime); | 1787 | None, None, CurrentTime); |
@@ -1683,9 +1795,9 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) | |||
1683 | newmode = SDL_GRAB_OFF; | 1795 | newmode = SDL_GRAB_OFF; |
1684 | //newmode = SDL_WM_GrabInput(SDL_GRAB_OFF); | 1796 | //newmode = SDL_WM_GrabInput(SDL_GRAB_OFF); |
1685 | 1797 | ||
1686 | XUngrabPointer(SDL_Display, CurrentTime); | 1798 | XUngrabPointer(mSDL_Display, CurrentTime); |
1687 | // Make sure the ungrab happens RIGHT NOW. | 1799 | // Make sure the ungrab happens RIGHT NOW. |
1688 | XSync(SDL_Display, False); | 1800 | XSync(mSDL_Display, False); |
1689 | } else | 1801 | } else |
1690 | { | 1802 | { |
1691 | newmode = SDL_GRAB_QUERY; // neutral | 1803 | newmode = SDL_GRAB_QUERY; // neutral |
@@ -1751,6 +1863,29 @@ void LLWindowSDL::gatherInput() | |||
1751 | static Uint32 lastRightDown = 0; | 1863 | static Uint32 lastRightDown = 0; |
1752 | SDL_Event event; | 1864 | SDL_Event event; |
1753 | 1865 | ||
1866 | #if LL_GTK && LL_LIBXUL_ENABLED | ||
1867 | // Pump GTK events so embedded Gecko doesn't starve. | ||
1868 | if (ll_try_gtk_init()) | ||
1869 | { | ||
1870 | // Yuck, Mozilla's GTK callbacks play with the locale - push/pop | ||
1871 | // the locale to protect it, as exotic/non-C locales | ||
1872 | // causes our code lots of general critical weirdness | ||
1873 | // and crashness. (SL-35450) | ||
1874 | char *saved_locale = setlocale(LC_ALL, NULL); | ||
1875 | |||
1876 | // Do a limited number of pumps so SL doesn't starve! | ||
1877 | // FIXME - this should ideally be time-limited, not count-limited. | ||
1878 | gtk_main_iteration_do(0); // Always do one non-blocking pump | ||
1879 | for (int iter=0; iter<10; ++iter) | ||
1880 | if (gtk_events_pending()) | ||
1881 | gtk_main_iteration(); | ||
1882 | |||
1883 | if (saved_locale) | ||
1884 | setlocale(LC_ALL, saved_locale); | ||
1885 | } | ||
1886 | #endif // LL_GTK && LL_LIBXUL_ENABLED | ||
1887 | |||
1888 | // Handle all outstanding SDL events | ||
1754 | while (SDL_PollEvent(&event)) | 1889 | while (SDL_PollEvent(&event)) |
1755 | { | 1890 | { |
1756 | switch (event.type) | 1891 | switch (event.type) |
@@ -2237,15 +2372,12 @@ S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type) | |||
2237 | { | 2372 | { |
2238 | S32 rtn = OSBTN_CANCEL; | 2373 | S32 rtn = OSBTN_CANCEL; |
2239 | 2374 | ||
2240 | #if LL_GTK | 2375 | ll_try_gtk_init(); |
2241 | maybe_do_gtk_diagnostics(); | ||
2242 | #endif // LL_GTK | ||
2243 | 2376 | ||
2244 | if(gWindowImplementation != NULL) | 2377 | if(gWindowImplementation != NULL) |
2245 | gWindowImplementation->beforeDialog(); | 2378 | gWindowImplementation->beforeDialog(); |
2246 | 2379 | ||
2247 | gtk_disable_setlocale(); | 2380 | if (ll_try_gtk_init() |
2248 | if (gtk_init_check(NULL, NULL) | ||
2249 | // We can NOT expect to combine GTK and SDL's aggressive fullscreen | 2381 | // We can NOT expect to combine GTK and SDL's aggressive fullscreen |
2250 | && ((NULL==gWindowImplementation) || (!was_fullscreen)) | 2382 | && ((NULL==gWindowImplementation) || (!was_fullscreen)) |
2251 | ) | 2383 | ) |
@@ -2281,10 +2413,11 @@ S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type) | |||
2281 | // Make GTK tell the window manager to associate this | 2413 | // Make GTK tell the window manager to associate this |
2282 | // dialog with our non-GTK SDL window, which should try | 2414 | // dialog with our non-GTK SDL window, which should try |
2283 | // to keep it on top etc. | 2415 | // to keep it on top etc. |
2284 | if (SDL_XWindowID != None) | 2416 | if (gWindowImplementation && |
2417 | gWindowImplementation->mSDL_XWindowID != None) | ||
2285 | { | 2418 | { |
2286 | gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin | 2419 | gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin |
2287 | GdkWindow *gdkwin = gdk_window_foreign_new(SDL_XWindowID); | 2420 | GdkWindow *gdkwin = gdk_window_foreign_new(gWindowImplementation->mSDL_XWindowID); |
2288 | gdk_window_set_transient_for(GTK_WIDGET(win)->window, | 2421 | gdk_window_set_transient_for(GTK_WIDGET(win)->window, |
2289 | gdkwin); | 2422 | gdkwin); |
2290 | } | 2423 | } |
@@ -2353,8 +2486,7 @@ BOOL LLWindowSDL::dialog_color_picker ( F32 *r, F32 *g, F32 *b) | |||
2353 | 2486 | ||
2354 | beforeDialog(); | 2487 | beforeDialog(); |
2355 | 2488 | ||
2356 | gtk_disable_setlocale(); | 2489 | if (ll_try_gtk_init() |
2357 | if (gtk_init_check(NULL, NULL) | ||
2358 | // We can NOT expect to combine GTK and SDL's aggressive fullscreen | 2490 | // We can NOT expect to combine GTK and SDL's aggressive fullscreen |
2359 | && !was_fullscreen | 2491 | && !was_fullscreen |
2360 | ) | 2492 | ) |
@@ -2367,10 +2499,10 @@ BOOL LLWindowSDL::dialog_color_picker ( F32 *r, F32 *g, F32 *b) | |||
2367 | // Get GTK to tell the window manager to associate this | 2499 | // Get GTK to tell the window manager to associate this |
2368 | // dialog with our non-GTK SDL window, which should try | 2500 | // dialog with our non-GTK SDL window, which should try |
2369 | // to keep it on top etc. | 2501 | // to keep it on top etc. |
2370 | if (SDL_XWindowID != None) | 2502 | if (mSDL_XWindowID != None) |
2371 | { | 2503 | { |
2372 | gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin | 2504 | gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin |
2373 | GdkWindow *gdkwin = gdk_window_foreign_new(SDL_XWindowID); | 2505 | GdkWindow *gdkwin = gdk_window_foreign_new(mSDL_XWindowID); |
2374 | gdk_window_set_transient_for(GTK_WIDGET(win)->window, | 2506 | gdk_window_set_transient_for(GTK_WIDGET(win)->window, |
2375 | gdkwin); | 2507 | gdkwin); |
2376 | } | 2508 | } |
@@ -2442,8 +2574,9 @@ void spawn_web_browser(const char* escaped_url) | |||
2442 | 2574 | ||
2443 | #if LL_LINUX | 2575 | #if LL_LINUX |
2444 | # if LL_X11 | 2576 | # if LL_X11 |
2445 | if (SDL_Display) // Just in case - before forking. | 2577 | if (gWindowImplementation && |
2446 | XSync(SDL_Display, False); | 2578 | gWindowImplementation->mSDL_Display) // Just in case - before forking. |
2579 | XSync(gWindowImplementation->mSDL_Display, False); | ||
2447 | # endif // LL_X11 | 2580 | # endif // LL_X11 |
2448 | 2581 | ||
2449 | std::string cmd; | 2582 | std::string cmd; |
@@ -2461,7 +2594,7 @@ void spawn_web_browser(const char* escaped_url) | |||
2461 | close(1); | 2594 | close(1); |
2462 | close(2); | 2595 | close(2); |
2463 | // end ourself by running the command | 2596 | // end ourself by running the command |
2464 | execv(cmd.c_str(), argv); | 2597 | execv(cmd.c_str(), argv); /* Flawfinder: ignore */ |
2465 | // if execv returns at all, there was a problem. | 2598 | // if execv returns at all, there was a problem. |
2466 | llwarns << "execv failure when trying to start " << cmd << llendl; | 2599 | llwarns << "execv failure when trying to start " << cmd << llendl; |
2467 | _exit(1); // _exit because we don't want atexit() clean-up! | 2600 | _exit(1); // _exit because we don't want atexit() clean-up! |
@@ -2488,13 +2621,26 @@ void shell_open( const char* file_path ) | |||
2488 | 2621 | ||
2489 | void *LLWindowSDL::getPlatformWindow() | 2622 | void *LLWindowSDL::getPlatformWindow() |
2490 | { | 2623 | { |
2491 | #if LL_X11 | 2624 | #if LL_GTK && LL_LIBXUL_ENABLED |
2492 | // pointer to our static raw X window | 2625 | if (ll_try_gtk_init()) |
2493 | return (void*)&SDL_XWindowID; | 2626 | { |
2494 | #else | 2627 | GtkWidget *win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
2495 | // doubt we really want to return a high-level SDL structure here. | 2628 | |
2629 | // These hacks were attempts to get Gecko to see the keyboard, | ||
2630 | // but I think they're doomed to fail. | ||
2631 | //GdkWindow *gdkwin = gdk_window_foreign_new(SDL_XWindowID); | ||
2632 | //GTK_WIDGET(win)->window = gdkwin; | ||
2633 | //gtk_widget_set_parent_window(win, gdkwin); | ||
2634 | |||
2635 | // show the hidden-widget while debugging (needs mozlib change) | ||
2636 | //gtk_widget_show_all(GTK_WIDGET(win)); | ||
2637 | |||
2638 | gtk_widget_realize(GTK_WIDGET(win)); | ||
2639 | return win; | ||
2640 | } | ||
2641 | #endif // LL_GTK && LL_LIBXUL_ENABLED | ||
2642 | // Unixoid mozilla really needs GTK. | ||
2496 | return NULL; | 2643 | return NULL; |
2497 | #endif | ||
2498 | } | 2644 | } |
2499 | 2645 | ||
2500 | void LLWindowSDL::bringToFront() | 2646 | void LLWindowSDL::bringToFront() |
diff --git a/linden/indra/llwindow/llwindowsdl.h b/linden/indra/llwindow/llwindowsdl.h index 0528b84..ed529a2 100644 --- a/linden/indra/llwindow/llwindowsdl.h +++ b/linden/indra/llwindow/llwindowsdl.h | |||
@@ -112,7 +112,17 @@ public: | |||
112 | 112 | ||
113 | /*virtual*/ void *getPlatformWindow(); | 113 | /*virtual*/ void *getPlatformWindow(); |
114 | /*virtual*/ void bringToFront(); | 114 | /*virtual*/ void bringToFront(); |
115 | 115 | ||
116 | // Not great that these are public, but they have to be accessible | ||
117 | // by non-class code and it's better than making them global. | ||
118 | #if LL_X11 | ||
119 | // These are set up by the X11 clipboard initialization code | ||
120 | Window mSDL_XWindowID; | ||
121 | Display *mSDL_Display; | ||
122 | #endif | ||
123 | void (*Lock_Display)(void); | ||
124 | void (*Unlock_Display)(void); | ||
125 | |||
116 | protected: | 126 | protected: |
117 | LLWindowSDL( | 127 | LLWindowSDL( |
118 | char *title, int x, int y, int width, int height, U32 flags, | 128 | char *title, int x, int y, int width, int height, U32 flags, |
@@ -179,10 +189,6 @@ protected: | |||
179 | 189 | ||
180 | #if LL_X11 | 190 | #if LL_X11 |
181 | private: | 191 | private: |
182 | // These are set up by the X11 clipboard initialization code | ||
183 | Window mSDL_XWindowID; | ||
184 | void (*Lock_Display)(void); | ||
185 | void (*Unlock_Display)(void); | ||
186 | // more X11 clipboard stuff | 192 | // more X11 clipboard stuff |
187 | int init_x11clipboard(void); | 193 | int init_x11clipboard(void); |
188 | void quit_x11clipboard(void); | 194 | void quit_x11clipboard(void); |
@@ -214,4 +220,14 @@ S32 OSMessageBoxSDL(const char* text, const char* caption, U32 type); | |||
214 | void load_url_external(const char* url); | 220 | void load_url_external(const char* url); |
215 | void shell_open( const char* file_path ); | 221 | void shell_open( const char* file_path ); |
216 | 222 | ||
223 | #if LL_GTK | ||
224 | // Lazily initialize and check the runtime GTK version for goodness. | ||
225 | BOOL ll_try_gtk_init(void); | ||
226 | #endif // LL_GTK | ||
227 | |||
228 | #if LL_X11 | ||
229 | Window get_SDL_XWindowID(void); | ||
230 | Display* get_SDL_Display(void); | ||
231 | #endif // LL_X11 | ||
232 | |||
217 | #endif //LL_LLWINDOWSDL_H | 233 | #endif //LL_LLWINDOWSDL_H |
diff --git a/linden/indra/llwindow/llwindowwin32.cpp b/linden/indra/llwindow/llwindowwin32.cpp index 5929fb5..1d084d2 100644 --- a/linden/indra/llwindow/llwindowwin32.cpp +++ b/linden/indra/llwindow/llwindowwin32.cpp | |||
@@ -74,57 +74,6 @@ void show_window_creation_error(const char* title) | |||
74 | { | 74 | { |
75 | llwarns << title << llendl; | 75 | llwarns << title << llendl; |
76 | shell_open( "help/window_creation_error.html"); | 76 | shell_open( "help/window_creation_error.html"); |
77 | /* | ||
78 | OSMessageBox( | ||
79 | "Second Life is unable to run because it can't set up your display.\n" | ||
80 | "We need to be able to make a 32-bit color window at 1024x768, with\n" | ||
81 | "an 8 bit alpha channel.\n" | ||
82 | "\n" | ||
83 | "First, be sure your monitor is set to True Color (32-bit) in\n" | ||
84 | "Start -> Control Panels -> Display -> Settings.\n" | ||
85 | "\n" | ||
86 | "Otherwise, this may be due to video card driver issues.\n" | ||
87 | "Please make sure you have the latest video card drivers installed.\n" | ||
88 | "ATI drivers are available at http://www.ati.com/\n" | ||
89 | "nVidia drivers are available at http://www.nvidia.com/\n" | ||
90 | "\n" | ||
91 | "If you continue to receive this message, contact customer service.", | ||
92 | title, | ||
93 | OSMB_OK); | ||
94 | */ | ||
95 | } | ||
96 | |||
97 | BOOL check_for_card(const char* RENDERER, const char* bad_card) | ||
98 | { | ||
99 | if (!strnicmp(RENDERER, bad_card, strlen(bad_card))) | ||
100 | { | ||
101 | char buffer[1024]; | ||
102 | sprintf(buffer, | ||
103 | "Your video card appears to be a %s, which Second Life does not support.\n" | ||
104 | "\n" | ||
105 | "Second Life requires a video card with 32 Mb of memory or more, as well as\n" | ||
106 | "multitexture support. We explicitly support nVidia GeForce 2 or better, \n" | ||
107 | "and ATI Radeon 8500 or better.\n" | ||
108 | "\n" | ||
109 | "If you own a supported card and continue to receive this message, try \n" | ||
110 | "updating to the latest video card drivers. Otherwise look in the\n" | ||
111 | "secondlife.com support section or e-mail technical support\n" | ||
112 | "\n" | ||
113 | "You can try to run Second Life, but it will probably crash or run\n" | ||
114 | "very slowly. Try anyway?", | ||
115 | bad_card); | ||
116 | S32 button = OSMessageBox(buffer, "Unsupported video card", OSMB_YESNO); | ||
117 | if (OSBTN_YES == button) | ||
118 | { | ||
119 | return FALSE; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | return TRUE; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | return FALSE; | ||
128 | } | 77 | } |
129 | 78 | ||
130 | //static | 79 | //static |
@@ -147,6 +96,7 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width, | |||
147 | BOOL ignore_pixel_depth) | 96 | BOOL ignore_pixel_depth) |
148 | : LLWindow(fullscreen, flags) | 97 | : LLWindow(fullscreen, flags) |
149 | { | 98 | { |
99 | S32 i = 0; | ||
150 | mIconResource = gIconResource; | 100 | mIconResource = gIconResource; |
151 | mOverrideAspectRatio = 0.f; | 101 | mOverrideAspectRatio = 0.f; |
152 | mNativeAspectRatio = 0.f; | 102 | mNativeAspectRatio = 0.f; |
@@ -348,8 +298,8 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width, | |||
348 | mFullscreenBits = -1; | 298 | mFullscreenBits = -1; |
349 | mFullscreenRefresh = -1; | 299 | mFullscreenRefresh = -1; |
350 | 300 | ||
351 | char error[256]; | 301 | char error[256]; /* Flawfinder: ignore */ |
352 | sprintf(error, "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); | 302 | snprintf(error, sizeof(error), "Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); /* Flawfinder: ignore */ |
353 | OSMessageBox(error, "Error", OSMB_OK); | 303 | OSMessageBox(error, "Error", OSMB_OK); |
354 | } | 304 | } |
355 | } | 305 | } |
@@ -515,37 +465,6 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width, | |||
515 | return; | 465 | return; |
516 | } | 466 | } |
517 | 467 | ||
518 | // Check for some explicitly unsupported cards. | ||
519 | const char* RENDERER = (const char*) glGetString(GL_RENDERER); | ||
520 | |||
521 | const char* CARD_LIST[] = | ||
522 | { "RAGE 128", | ||
523 | "RIVA TNT2", | ||
524 | "Intel 810", | ||
525 | "3Dfx/Voodoo3", | ||
526 | "Radeon 7000", | ||
527 | "Radeon 7200", | ||
528 | "Radeon 7500", | ||
529 | "Radeon DDR", | ||
530 | "Radeon VE", | ||
531 | "GDI Generic" }; | ||
532 | const S32 CARD_COUNT = sizeof(CARD_LIST)/sizeof(char*); | ||
533 | |||
534 | // Future candidates: | ||
535 | // ProSavage/Twister | ||
536 | // SuperSavage | ||
537 | |||
538 | S32 i; | ||
539 | for (i = 0; i < CARD_COUNT; i++) | ||
540 | { | ||
541 | if (check_for_card(RENDERER, CARD_LIST[i])) | ||
542 | { | ||
543 | close(); | ||
544 | shell_open( "help/unsupported_card.html" ); | ||
545 | return; | ||
546 | } | ||
547 | } | ||
548 | |||
549 | gGLManager.initWGL(); | 468 | gGLManager.initWGL(); |
550 | 469 | ||
551 | if (gGLManager.mHasWGLARBPixelFormat && (wglChoosePixelFormatARB != NULL)) | 470 | if (gGLManager.mHasWGLARBPixelFormat && (wglChoosePixelFormatARB != NULL)) |
@@ -1976,20 +1895,6 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ | |||
1976 | << " key " << S32(w_param) | 1895 | << " key " << S32(w_param) |
1977 | << llendl; | 1896 | << llendl; |
1978 | } | 1897 | } |
1979 | // lower 15 bits hold key repeat count | ||
1980 | S32 key_repeat_count = l_param & 0x7fff; | ||
1981 | if (key_repeat_count > 1) | ||
1982 | { | ||
1983 | KEY translated_key; | ||
1984 | gKeyboard->translateKey(w_param, &translated_key); | ||
1985 | if (!gKeyboard->getKeyDown(translated_key)) | ||
1986 | { | ||
1987 | //RN: hack for handling key repeats when we no longer recognize the key as being down | ||
1988 | //This is necessary because we sometimes ignore the message queue and use getAsyncKeyState | ||
1989 | // to clear key level flags before we've processed all key repeat messages | ||
1990 | return 0; | ||
1991 | } | ||
1992 | } | ||
1993 | if(gKeyboard->handleKeyDown(w_param, mask) && eat_keystroke) | 1898 | if(gKeyboard->handleKeyDown(w_param, mask) && eat_keystroke) |
1994 | { | 1899 | { |
1995 | return 0; | 1900 | return 0; |
@@ -2469,7 +2374,7 @@ BOOL LLWindowWin32::copyTextToClipboard(const LLWString& wstr) | |||
2469 | WCHAR* copy_utf16 = (WCHAR*) GlobalLock(hglobal_copy_utf16); | 2374 | WCHAR* copy_utf16 = (WCHAR*) GlobalLock(hglobal_copy_utf16); |
2470 | if (copy_utf16) | 2375 | if (copy_utf16) |
2471 | { | 2376 | { |
2472 | memcpy(copy_utf16, out_utf16.c_str(), size_utf16); | 2377 | memcpy(copy_utf16, out_utf16.c_str(), size_utf16); /* Flawfinder: ignore */ |
2473 | GlobalUnlock(hglobal_copy_utf16); | 2378 | GlobalUnlock(hglobal_copy_utf16); |
2474 | 2379 | ||
2475 | if (SetClipboardData(CF_UNICODETEXT, hglobal_copy_utf16)) | 2380 | if (SetClipboardData(CF_UNICODETEXT, hglobal_copy_utf16)) |
@@ -2493,7 +2398,7 @@ BOOL LLWindowWin32::copyTextToClipboard(const LLWString& wstr) | |||
2493 | char* copy = (char*) GlobalLock(hglobal_copy); | 2398 | char* copy = (char*) GlobalLock(hglobal_copy); |
2494 | if( copy ) | 2399 | if( copy ) |
2495 | { | 2400 | { |
2496 | memcpy(copy, out_s.c_str(), size); | 2401 | memcpy(copy, out_s.c_str(), size); /* Flawfinder: ignore */ |
2497 | GlobalUnlock(hglobal_copy); | 2402 | GlobalUnlock(hglobal_copy); |
2498 | 2403 | ||
2499 | if (SetClipboardData(CF_TEXT, hglobal_copy)) | 2404 | if (SetClipboardData(CF_TEXT, hglobal_copy)) |
@@ -2594,7 +2499,7 @@ BOOL LLWindowWin32::sendEmail(const char* address, const char* subject, const ch | |||
2594 | } | 2499 | } |
2595 | else | 2500 | else |
2596 | { | 2501 | { |
2597 | HINSTANCE hMAPIInst = LoadLibrary(L"MAPI32.DLL"); | 2502 | HINSTANCE hMAPIInst = LoadLibrary(L"MAPI32.DLL"); /* Flawfinder: ignore */ |
2598 | if(!hMAPIInst) | 2503 | if(!hMAPIInst) |
2599 | { | 2504 | { |
2600 | result = LL_EMAIL_MAPILOAD_FAILED; | 2505 | result = LL_EMAIL_MAPILOAD_FAILED; |
@@ -3112,7 +3017,7 @@ void spawn_web_browser(const char* escaped_url ) | |||
3112 | S32 i; | 3017 | S32 i; |
3113 | for (i = 0; i < gURLProtocolWhitelistCount; i++) | 3018 | for (i = 0; i < gURLProtocolWhitelistCount; i++) |
3114 | { | 3019 | { |
3115 | S32 len = strlen(gURLProtocolWhitelist[i]); | 3020 | S32 len = strlen(gURLProtocolWhitelist[i]); /* Flawfinder: ignore */ |
3116 | if (!strncmp(escaped_url, gURLProtocolWhitelist[i], len) | 3021 | if (!strncmp(escaped_url, gURLProtocolWhitelist[i], len) |
3117 | && escaped_url[len] == ':') | 3022 | && escaped_url[len] == ':') |
3118 | { | 3023 | { |
@@ -3131,8 +3036,8 @@ void spawn_web_browser(const char* escaped_url ) | |||
3131 | 3036 | ||
3132 | // Figure out the user's default web browser | 3037 | // Figure out the user's default web browser |
3133 | // HKEY_CLASSES_ROOT\http\shell\open\command | 3038 | // HKEY_CLASSES_ROOT\http\shell\open\command |
3134 | char reg_path_str[256]; | 3039 | char reg_path_str[256]; /* Flawfinder: ignore */ |
3135 | sprintf(reg_path_str, "%s\\shell\\open\\command", gURLProtocolWhitelistHandler[i]); | 3040 | snprintf(reg_path_str, sizeof(reg_path_str), "%s\\shell\\open\\command", gURLProtocolWhitelistHandler[i]); /* Flawfinder: ignore */ |
3136 | WCHAR reg_path_wstr[256]; | 3041 | WCHAR reg_path_wstr[256]; |
3137 | mbstowcs(reg_path_wstr, reg_path_str, 1024); | 3042 | mbstowcs(reg_path_wstr, reg_path_str, 1024); |
3138 | 3043 | ||
@@ -3183,7 +3088,7 @@ void spawn_web_browser(const char* escaped_url ) | |||
3183 | // MS docs say to cast to int and compare to 32. | 3088 | // MS docs say to cast to int and compare to 32. |
3184 | HWND our_window = NULL; | 3089 | HWND our_window = NULL; |
3185 | LPCWSTR directory_wstr = NULL; | 3090 | LPCWSTR directory_wstr = NULL; |
3186 | int retval = (int) ShellExecute(our_window, | 3091 | int retval = (int) ShellExecute(our_window, /* Flawfinder: ignore */ |
3187 | L"open", | 3092 | L"open", |
3188 | browser_exec_utf16.c_str(), | 3093 | browser_exec_utf16.c_str(), |
3189 | url_utf16.c_str(), | 3094 | url_utf16.c_str(), |
@@ -3207,7 +3112,7 @@ void shell_open( const char* file_path ) | |||
3207 | mbstowcs(wstr, file_path, 1024); | 3112 | mbstowcs(wstr, file_path, 1024); |
3208 | 3113 | ||
3209 | HWND our_window = NULL; | 3114 | HWND our_window = NULL; |
3210 | int retval = (int) ShellExecute(our_window, L"open", wstr, NULL, NULL, SW_SHOWNORMAL); | 3115 | int retval = (int) ShellExecute(our_window, L"open", wstr, NULL, NULL, SW_SHOWNORMAL); /* Flawfinder: ignore */ |
3211 | if (retval > 32) | 3116 | if (retval > 32) |
3212 | { | 3117 | { |
3213 | llinfos << "ShellExecute success with " << retval << llendl; | 3118 | llinfos << "ShellExecute success with " << retval << llendl; |
diff --git a/linden/indra/llwindow/llwindowwin32.h b/linden/indra/llwindow/llwindowwin32.h index 77696e6..f6300f6 100644 --- a/linden/indra/llwindow/llwindowwin32.h +++ b/linden/indra/llwindow/llwindowwin32.h | |||
@@ -201,6 +201,7 @@ private: | |||
201 | }; | 201 | }; |
202 | 202 | ||
203 | extern LLW32MsgCallback gAsyncMsgCallback; | 203 | extern LLW32MsgCallback gAsyncMsgCallback; |
204 | extern LPWSTR gIconResource; | ||
204 | 205 | ||
205 | static void handleMessage( const MSG& msg ); | 206 | static void handleMessage( const MSG& msg ); |
206 | 207 | ||