diff --git a/autobuild.xml b/autobuild.xml index 2f98545a84..bcb424112c 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -3,91 +3,7 @@ installables - glib - - copyright - Copyright (C) glib project - license - LGPL - license_file - LICENSES/glib.txt - name - glib - platforms - - linux64 - - archive - - hash - 9c93ba8b8af97fc8379f77de77e1540a - url - http://3p.firestormviewer.org/glib-2.48.0.202301938-linux64-202301938.tar.bz2 - - name - linux - - - version - 2.48.0 - - fltk - - copyright - Copyright (C) fltk project - license - LGPL/fltk - license_file - LICENSES/fltk.txt - name - fltk - platforms - - linux64 - - archive - - hash - 81fe1e927e4fe3c5e5f15ce6219ca883 - url - http://3p.firestormviewer.org/fltk-1.3.5.202282121-linux64-202282121.tar.bz2 - - name - linux - - - version - 1.3.5 - - gstreamer10 - - copyright - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - license - LGPL - license_file - LICENSES/gstreamer.txt - name - gstreamer10 - platforms - - linux - - archive - - hash - 01f39ecf80dae64e30402ac384035b3e - url - http://downloads.phoenixviewer.com/gstreamer10-1.6.3.201605191852-linux-201605191852.tar.bz2 - - name - linux - - - version - 0.10.6.294903 - - jemalloc + jemalloc copyright Copyright (C) 2002-present Jason Evans jasone@canonware.com. @@ -334,9 +250,9 @@ archive hash - 1d4819f2944d572667b6a009bfadd8e0 + 64c1dff0e19792acec7fd32556bf4d7b url - http://3p.firestormviewer.org/SDL-2.0.10-linux64-192791159.tar.bz2 + http://3p.firestormviewer.org/SDL-1.2.15-linux64-181411635.tar.bz2 name linux64 @@ -2893,14 +2809,26 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors open-libndofdev platforms + linux + + archive + + hash + 246ed298944fd5200e4cac3703d6e075 + url + http://3p.firestormviewer.org/open_libndofdev-0.9.183150124-linux-183150124.tar.bz2 + + name + linux + linux64 archive hash - e52e1223fe1603485178ac65d6562a61 + db8a7126178e7230fd6917a28cd67bd7 url - http://3p.firestormviewer.org/open_libndofdev-0.12.193591719-linux64-193591719.tar.bz2 + http://3p.firestormviewer.org/open_libndofdev-0.9.183150121-linux64-183150121.tar.bz2 name linux64 diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 8cf08950a7..ce8b396cc1 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -189,10 +189,6 @@ if (LINUX) -pthread ) - if( FS_KEEP_FRAMEPOINTER ) - add_compile_options(-fno-omit-frame-pointer) - endif() - # force this platform to accept TOS via external browser No, do not. # add_definitions(-DEXTERNAL_TOS) @@ -215,7 +211,6 @@ if (LINUX) set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-keep-memory -Wl,--build-id -Wl,-rpath,'$ORIGIN:$ORIGIN/../lib' -Wl,--exclude-libs,ALL") endif (NOT USESYSTEMLIBS) - set(CMAKE_CXX_LINK_FLAGS "-Wl,--no-keep-memory -Wl,--build-id -Wl,-rpath,'$ORIGIN:$ORIGIN/../lib' -Wl,--exclude-libs,ALL") set(CMAKE_CXX_FLAGS_DEBUG "-fno-inline ${CMAKE_CXX_FLAGS_DEBUG}") if( NOT (CMAKE_CXX_COMPILER MATCHES ".*clang") ) @@ -288,6 +283,17 @@ if (USESYSTEMLIBS) if (LINUX AND ADDRESS_SIZE EQUAL 32) add_definitions(-march=pentiumpro) endif (LINUX AND ADDRESS_SIZE EQUAL 32) + +else (USESYSTEMLIBS) + set(${ARCH}_linux_INCLUDES + atk-1.0 + cairo + freetype + glib-2.0 + gstreamer-0.10 + gtk-2.0 + pango-1.0 + ) endif (USESYSTEMLIBS) endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED) diff --git a/indra/cmake/APR.cmake b/indra/cmake/APR.cmake index 47567ee009..1a01671002 100644 --- a/indra/cmake/APR.cmake +++ b/indra/cmake/APR.cmake @@ -1,4 +1,4 @@ -#include(BerkeleyDB) +include(BerkeleyDB) include(Linking) include(Prebuilt) diff --git a/indra/cmake/Boost.cmake b/indra/cmake/Boost.cmake index c2d5df6c0d..21f9faa410 100644 --- a/indra/cmake/Boost.cmake +++ b/indra/cmake/Boost.cmake @@ -5,21 +5,17 @@ set(Boost_FIND_QUIETLY ON) set(Boost_FIND_REQUIRED ON) if (USESYSTEMLIBS) - SET(BOOST_INCLUDEDIR ${CMAKE_INCLUDE_PATH} ) - SET(BOOST_LIBRARYDIR ${CMAKE_LIBRARY_PATH} ) include(FindBoost) - include_directories( ${BOOST_INCLUDEDIR} ) - - FIND_LIBRARY(BOOST_CONTEXT_LIBRARY boost_context-mt PATHS ${BOOST_LIBRARYDIR} ) - FIND_LIBRARY(BOOST_COROUTINE_LIBRARY boost_coroutine-mt PATHS ${BOOST_LIBRARYDIR} ) - FIND_LIBRARY(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt PATHS ${BOOST_LIBRARYDIR} ) - FIND_LIBRARY(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt PATHS ${BOOST_LIBRARYDIR} ) - FIND_LIBRARY(BOOST_REGEX_LIBRARY boost_regex-mt PATHS ${BOOST_LIBRARYDIR} ) - FIND_LIBRARY(BOOST_SIGNALS_LIBRARY boost_signals-mt PATHS ${BOOST_LIBRARYDIR} ) - FIND_LIBRARY(BOOST_SYSTEM_LIBRARY boost_system-mt PATHS ${BOOST_LIBRARYDIR} ) - FIND_LIBRARY(BOOST_THREAD_LIBRARY boost_thread-mt PATHS ${BOOST_LIBRARYDIR} ) - FIND_LIBRARY(BOOST_WAVE_LIBRARY boost_wave-mt PATHS ${BOOST_LIBRARYDIR} ) + set(BOOST_CONTEXT_LIBRARY boost_context-mt) + set(BOOST_FIBER_LIBRARY boost_fiber-mt) + set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt) + set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt) + set(BOOST_REGEX_LIBRARY boost_regex-mt) + set(BOOST_SIGNALS_LIBRARY boost_signals-mt) + set(BOOST_SYSTEM_LIBRARY boost_system-mt) + set(BOOST_THREAD_LIBRARY boost_thread-mt) + set(BOOST_WAVE_LIBRARY boost_wave-mt) else (USESYSTEMLIBS) use_prebuilt_binary(boost) set(Boost_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include) diff --git a/indra/cmake/BuildPackagesInfo.cmake b/indra/cmake/BuildPackagesInfo.cmake index 313a904471..8f8b6b2330 100644 --- a/indra/cmake/BuildPackagesInfo.cmake +++ b/indra/cmake/BuildPackagesInfo.cmake @@ -3,8 +3,6 @@ include(Python) include(FindAutobuild) -if( NOT USESYSTEMLIBS ) - # packages-formatter.py runs autobuild install --versions, which needs to know # the build_directory, which (on Windows) depends on AUTOBUILD_ADDRSIZE. # Within an autobuild build, AUTOBUILD_ADDRSIZE is already set. But when @@ -20,5 +18,3 @@ add_custom_command(OUTPUT packages-info.txt ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../scripts/packages-formatter.py "${VIEWER_CHANNEL}" "${VIEWER_SHORT_VERSION}.${VIEWER_VERSION_REVISION}" > packages-info.txt ) - -endif() \ No newline at end of file diff --git a/indra/cmake/CEFPlugin.cmake b/indra/cmake/CEFPlugin.cmake index 21a8f441f2..9e7ab912f8 100644 --- a/indra/cmake/CEFPlugin.cmake +++ b/indra/cmake/CEFPlugin.cmake @@ -3,7 +3,7 @@ include(Linking) include(Prebuilt) if (USESYSTEMLIBS) - set(CEFPLUGIN ON CACHE BOOL + set(CEFPLUGIN OFF CACHE BOOL "CEFPLUGIN support for the llplugin/llmedia test apps.") else (USESYSTEMLIBS) use_prebuilt_binary(dullahan) @@ -37,18 +37,9 @@ elseif (DARWIN) ) elseif (LINUX) - - if (USESYSTEMLIBS) - find_library( LIB_DULLAHAN "dullahan" ) - find_library( LIB_CEF "cef" ) - find_library( LIB_CEF_WRAPPER "cef_dll_wrapper" ) - set(CEF_PLUGIN_LIBRARIES ${LIB_DULLAHAN} ${LIB_CEF} ${LIB_CEF_WRAPPER} ) - else() set(CEF_PLUGIN_LIBRARIES - dullahan - cef - cef_dll_wrapper.a - ) -endif() - + dullahan + cef + cef_dll_wrapper.a + ) endif (WINDOWS) diff --git a/indra/cmake/ColladaDom.cmake b/indra/cmake/ColladaDom.cmake index 6409f16557..3999e61045 100644 --- a/indra/cmake/ColladaDom.cmake +++ b/indra/cmake/ColladaDom.cmake @@ -2,20 +2,11 @@ include (Prebuilt) if (USESYSTEMLIBS) - include(FindPkgConfig) - pkg_check_modules( MINIZIP REQUIRED minizip ) - pkg_check_modules( LIBXML2 REQUIRED libxml-2.0 ) - pkg_check_modules( LIBPCRECPP REQUIRED libpcrecpp ) - - find_library( COLLADADOM_LIBRARY collada14dom ) - find_path( COLLADADOM_INCLUDE_DIR colladadom/dae.h ) - - if( COLLADADOM_INCLUDE_DIR STREQUAL "COLLADADOM_INCLUDE_DIR-NOTFOUND" ) - message( FATAL_ERROR "Cannot find colladadom include dir" ) - endif() - - set( COLLADA_INCLUDE_DIRS ${COLLADADOM_INCLUDE_DIR}/colladadom ${COLLADADOM_INCLUDE_DIR}/colladadom/1.4 ) - + find_path(COLLADA_INCLUDE_DIRS 1.4/dom/domConstants.h + PATH_SUFFIXES collada collada-dom2.4) + set(COLLADA_INCLUDE_DIRS + ${COLLADA_INCLUDE_DIRS} ${COLLADA_INCLUDE_DIRS}/1.4 + ) else (USESYSTEMLIBS) set(COLLADA_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/collada diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake index 63f4bc336b..c0652e556c 100644 --- a/indra/cmake/Copy3rdPartyLibs.cmake +++ b/indra/cmake/Copy3rdPartyLibs.cmake @@ -237,11 +237,14 @@ elseif(LINUX) set(release_files #libapr-1.so.0 #libaprutil-1.so.0 + libatk-1.0.so #libdb-5.1.so ${EXPAT_COPY} #libfreetype.so.6.6.2 #libfreetype.so.6 #libGLOD.so + libgmodule-2.0.so + libgobject-2.0.so libhunspell-1.3.so.0.0.0 libopenal.so #libopenjpeg.so @@ -309,9 +312,10 @@ to_staging_dirs( ${release_files} ) -if(NOT USESYSTEMLIBS) +# We need to do this regardless +#if(NOT USESYSTEMLIBS) add_custom_target( stage_third_party_libs ALL DEPENDS ${third_party_targets} ) -endif(NOT USESYSTEMLIBS) +#endif(NOT USESYSTEMLIBS) diff --git a/indra/cmake/DBusGlib.cmake b/indra/cmake/DBusGlib.cmake index d0f6c221cc..5e46b6711a 100644 --- a/indra/cmake/DBusGlib.cmake +++ b/indra/cmake/DBusGlib.cmake @@ -1,8 +1,6 @@ # -*- cmake -*- include(Prebuilt) -include(GLIB) -if( GLIB_FOUND ) if (USESYSTEMLIBS) include(FindPkgConfig) @@ -12,11 +10,14 @@ elseif (LINUX) use_prebuilt_binary(dbus_glib) set(DBUSGLIB_FOUND ON FORCE BOOL) set(DBUSGLIB_INCLUDE_DIRS - ${GLIB_INCLUDE_DIRS} - ${LIBS_PREBUILT_DIR}/include/dbus - ) + ${LIBS_PREBUILT_DIR}/include/dbus + ) # We don't need to explicitly link against dbus-glib itself, because # the viewer probes for the system's copy at runtime. + set(DBUSGLIB_LIBRARIES + gobject-2.0 + glib-2.0 + ) endif (USESYSTEMLIBS) if (DBUSGLIB_FOUND) @@ -26,5 +27,3 @@ endif (DBUSGLIB_FOUND) if (DBUSGLIB) add_definitions(-DLL_DBUS_ENABLED=1) endif (DBUSGLIB) - -endif() diff --git a/indra/cmake/FindAPR.cmake b/indra/cmake/FindAPR.cmake index 993748597a..906b6c9452 100644 --- a/indra/cmake/FindAPR.cmake +++ b/indra/cmake/FindAPR.cmake @@ -1,8 +1,94 @@ # -*- cmake -*- -include(FindPkgConfig) -pkg_check_modules( APR REQUIRED apr-1 ) -set( APR_INCLUDE_DIR ${APR_INCLUDE_DIRS} ) +# - Find Apache Portable Runtime +# Find the APR includes and libraries +# This module defines +# APR_INCLUDE_DIR and APRUTIL_INCLUDE_DIR, where to find apr.h, etc. +# APR_LIBRARIES and APRUTIL_LIBRARIES, the libraries needed to use APR. +# APR_FOUND and APRUTIL_FOUND, If false, do not try to use APR. +# also defined, but not for general use are +# APR_LIBRARY and APRUTIL_LIBRARY, where to find the APR library. -pkg_check_modules( APRUTIL REQUIRED apr-util-1 ) -set( APRUTIL_INCLUDE_DIR ${APRUTIL_INCLUDE_DIRS} ) +# APR first. + +FIND_PATH(APR_INCLUDE_DIR apr.h +/usr/local/include/apr-1 +/usr/local/include/apr-1.0 +/usr/include/apr-1 +/usr/include/apr-1.0 +) + +SET(APR_NAMES ${APR_NAMES} apr-1) +FIND_LIBRARY(APR_LIBRARY + NAMES ${APR_NAMES} + PATHS /usr/lib /usr/local/lib + ) + +IF (APR_LIBRARY AND APR_INCLUDE_DIR) + SET(APR_LIBRARIES ${APR_LIBRARY}) + SET(APR_FOUND "YES") +ELSE (APR_LIBRARY AND APR_INCLUDE_DIR) + SET(APR_FOUND "NO") +ENDIF (APR_LIBRARY AND APR_INCLUDE_DIR) + + +IF (APR_FOUND) + IF (NOT APR_FIND_QUIETLY) + MESSAGE(STATUS "Found APR: ${APR_LIBRARIES}") + ENDIF (NOT APR_FIND_QUIETLY) +ELSE (APR_FOUND) + IF (APR_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find APR library") + ENDIF (APR_FIND_REQUIRED) +ENDIF (APR_FOUND) + +# Deprecated declarations. +SET (NATIVE_APR_INCLUDE_PATH ${APR_INCLUDE_DIR} ) +GET_FILENAME_COMPONENT (NATIVE_APR_LIB_PATH ${APR_LIBRARY} PATH) + +MARK_AS_ADVANCED( + APR_LIBRARY + APR_INCLUDE_DIR + ) + +# Next, APRUTIL. + +FIND_PATH(APRUTIL_INCLUDE_DIR apu.h +/usr/local/include/apr-1 +/usr/local/include/apr-1.0 +/usr/include/apr-1 +/usr/include/apr-1.0 +) + +SET(APRUTIL_NAMES ${APRUTIL_NAMES} aprutil-1) +FIND_LIBRARY(APRUTIL_LIBRARY + NAMES ${APRUTIL_NAMES} + PATHS /usr/lib /usr/local/lib + ) + +IF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR) + SET(APRUTIL_LIBRARIES ${APRUTIL_LIBRARY}) + SET(APRUTIL_FOUND "YES") +ELSE (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR) + SET(APRUTIL_FOUND "NO") +ENDIF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR) + + +IF (APRUTIL_FOUND) + IF (NOT APRUTIL_FIND_QUIETLY) + MESSAGE(STATUS "Found APRUTIL: ${APRUTIL_LIBRARIES}") + ENDIF (NOT APRUTIL_FIND_QUIETLY) +ELSE (APRUTIL_FOUND) + IF (APRUTIL_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find APRUTIL library") + ENDIF (APRUTIL_FIND_REQUIRED) +ENDIF (APRUTIL_FOUND) + +# Deprecated declarations. +SET (NATIVE_APRUTIL_INCLUDE_PATH ${APRUTIL_INCLUDE_DIR} ) +GET_FILENAME_COMPONENT (NATIVE_APRUTIL_LIB_PATH ${APRUTIL_LIBRARY} PATH) + +MARK_AS_ADVANCED( + APRUTIL_LIBRARY + APRUTIL_INCLUDE_DIR + ) diff --git a/indra/cmake/FindFMODSTUDIO.cmake b/indra/cmake/FindFMODSTUDIO.cmake index 902d9a4835..4562b0ae45 100644 --- a/indra/cmake/FindFMODSTUDIO.cmake +++ b/indra/cmake/FindFMODSTUDIO.cmake @@ -9,10 +9,13 @@ # also defined, but not for general use are # FMODSTUDIO_LIBRARY, where to find the FMODSTUDIO library. -FIND_PATH(FMODSTUDIO_INCLUDE_DIR fmod.h PATH_SUFFIXES fmodstudio) +FIND_PATH(FMODSTUDIO_INCLUDE_DIR fmod.h PATH_SUFFIXES fmod) SET(FMODSTUDIO_NAMES ${FMODSTUDIO_NAMES} fmod fmod_vc) -FIND_LIBRARY(FMODSTUDIO_LIBRARY NAMES ${FMODSTUDIO_NAMES} PATH_SUFFIXES fmod ) +FIND_LIBRARY(FMODSTUDIO_LIBRARY + NAMES ${FMODSTUDIO_NAMES} + PATH_SUFFIXES fmod + ) IF (FMODSTUDIO_SDK_DIR OR WINDOWS) if(WINDOWS) @@ -36,14 +39,12 @@ IF (FMODSTUDIO_SDK_DIR OR WINDOWS) ${FMODSTUDIO_SDK_DIR}/api ${FMODSTUDIO_SDK_DIR} ) + IF (FMODSTUDIO_LIBRARY AND FMODSTUDIO_INCLUDE_DIR) + SET(FMODSTUDIO_LIBRARIES ${FMODSTUDIO_LIBRARY}) + SET(FMODSTUDIO_FOUND "YES") + endif (FMODSTUDIO_LIBRARY AND FMODSTUDIO_INCLUDE_DIR) ENDIF (FMODSTUDIO_SDK_DIR OR WINDOWS) -IF (FMODSTUDIO_LIBRARY AND FMODSTUDIO_INCLUDE_DIR) - SET(FMODSTUDIO_LIBRARIES ${FMODSTUDIO_LIBRARY}) - SET(FMODSTUDIO_FOUND "YES") -endif (FMODSTUDIO_LIBRARY AND FMODSTUDIO_INCLUDE_DIR) - - IF (FMODSTUDIO_FOUND) IF (NOT FMODSTUDIO_FIND_QUIETLY) MESSAGE(STATUS "Found FMODSTUDIO: ${FMODSTUDIO_LIBRARIES}") diff --git a/indra/cmake/FindGLH.cmake b/indra/cmake/FindGLH.cmake index 7288eb1d12..3d16adaf03 100644 --- a/indra/cmake/FindGLH.cmake +++ b/indra/cmake/FindGLH.cmake @@ -6,7 +6,9 @@ # GLH_INCLUDE_DIR, where to find glh/glh_linear.h. # GLH_FOUND, If false, do not try to use GLH. -find_path(GLH_INCLUDE_DIR glh/glh_linear.h ) +find_path(GLH_INCLUDE_DIR glh/glh_linear.h + NO_SYSTEM_ENVIRONMENT_PATH + ) if (GLH_INCLUDE_DIR) set(GLH_FOUND "YES") diff --git a/indra/cmake/FindGLOD.cmake b/indra/cmake/FindGLOD.cmake index b6ee8ba792..010a0c5aa4 100644 --- a/indra/cmake/FindGLOD.cmake +++ b/indra/cmake/FindGLOD.cmake @@ -1,16 +1,36 @@ +# -*- cmake -*- -find_library( GLOD_LIBRARY GLOD ) -find_library( VDS_LIBRARY vds ) -find_path( GLOD_INCLUDE_DIR glod/glod.h ) +# - Find GLOD +# This module defines +# GLOD_INCLUDE_DIR, where to find glod.h, etc. +# GLOD_LIBRARIES, the library needed to use GLOD. +# GLOD_FOUND, If false, do not try to use GLOD. -if( GLOD_INCLUDE_DIR STREQUAL "GLOD_INCLUDE_DIR-NOTFOUND" ) - message( FATAL_ERROR "Cannot find glod include dir" ) -endif() -if( GLOD_LIBRARY STREQUAL "GLOD_LIBRARY-NOTFOUND" ) - message( FATAL_ERROR "Cannot find library GLOD.a" ) -endif() -if( VDS_LIBRARY STREQUAL "VDS_LIBRARY-NOTFOUND" ) - message( FATAL_ERROR "Cannot find library vds.a" ) -endif() -set(GLOD_LIBRARIES ${GLOD_LIBRARY} ${VDS_LIBRARY} ) - +# LL coded the #include with a glod path in llfloatermodelpreview.cpp +find_path(GLOD_INCLUDE_DIR glod/glod.h) + +set(GLOD_NAMES ${GLOD_NAMES} glod) +find_library(GLOD_LIBRARIES + NAMES ${GLOD_NAMES} + ) + +if (GLOD_LIBRARIES AND GLOD_INCLUDE_DIR) + set(GLOD_FOUND "YES") +else (GLOD_LIBRARIES AND GLOD_INCLUDE_DIR) + set(GLOD_FOUND "NO") +endif (GLOD_LIBRARIES AND GLOD_INCLUDE_DIR) + +if (GLOD_FOUND) + if (NOT GLOD_FIND_QUIETLY) + message(STATUS "Found GLOD: Library in '${GLOD_LIBRARY}' and header in '${GLOD_INCLUDE_DIR}' ") + endif (NOT GLOD_FIND_QUIETLY) +else (GLOD_FOUND) + if (GLOD_FIND_REQUIRED) + message(FATAL_ERROR " * * * * *\nCould not find GLOD library!\n* * * * *") + endif (GLOD_FIND_REQUIRED) +endif (GLOD_FOUND) + +mark_as_advanced( + GLOD_LIBRARIES + GLOD_INCLUDE_DIR + ) diff --git a/indra/cmake/FindGoogleBreakpad.cmake b/indra/cmake/FindGoogleBreakpad.cmake index 78890ca5c2..e9f67b98c7 100644 --- a/indra/cmake/FindGoogleBreakpad.cmake +++ b/indra/cmake/FindGoogleBreakpad.cmake @@ -9,15 +9,15 @@ # also defined, but not for general use are # BREAKPAD_EXCEPTION_HANDLER_LIBRARY, where to find the Google BreakPad library. -FIND_PATH(BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR breakpad/client/linux/handler/exception_handler.h) +# LL code uses "google_breakpad" path prefix, while google breakpad headers don't use a prefix. Find and add both paths to the correct variable. +FIND_PATH(BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR google_breakpad/exception_handler.h) +FIND_PATH(BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIRS exception_handler.h PATH_SUFFIXES google_breakpad) +SET(BREAKPAD_INCLUDE_DIRECTORIES ${BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR} ${BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIRS}) SET(BREAKPAD_EXCEPTION_HANDLER_NAMES ${BREAKPAD_EXCEPTION_HANDLER_NAMES} breakpad_client) FIND_LIBRARY(BREAKPAD_EXCEPTION_HANDLER_LIBRARY NAMES ${BREAKPAD_EXCEPTION_HANDLER_NAMES} ) -message ( ${BREAKPAD_EXCEPTION_HANDLER_LIBRARY} ) - -include_directories( ${BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR}/google_breakpad/ ) IF (BREAKPAD_EXCEPTION_HANDLER_LIBRARY AND BREAKPAD_EXCEPTION_HANDLER_INCLUDE_DIR) SET(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES ${BREAKPAD_EXCEPTION_HANDLER_LIBRARY}) @@ -30,6 +30,7 @@ ENDIF (BREAKPAD_EXCEPTION_HANDLER_LIBRARY AND BREAKPAD_EXCEPTION_HANDLER_INCLUDE IF (BREAKPAD_EXCEPTION_HANDLER_FOUND) IF (NOT BREAKPAD_EXCEPTION_HANDLER_FIND_QUIETLY) MESSAGE(STATUS "Found Google BreakPad: ${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES}") + MESSAGE(STATUS "Found Google BreakPad headers in: ${BREAKPAD_INCLUDE_DIRECTORIES}") ENDIF (NOT BREAKPAD_EXCEPTION_HANDLER_FIND_QUIETLY) ELSE (BREAKPAD_EXCEPTION_HANDLER_FOUND) IF (BREAKPAD_EXCEPTION_HANDLER_FIND_REQUIRED) diff --git a/indra/cmake/FindHUNSPELL.cmake b/indra/cmake/FindHUNSPELL.cmake index c2b7c589f6..ab621570d9 100644 --- a/indra/cmake/FindHUNSPELL.cmake +++ b/indra/cmake/FindHUNSPELL.cmake @@ -1,6 +1,38 @@ # -*- cmake -*- -include(FindPkgConfig) -pkg_check_modules( HUNSPELL REQUIRED hunspell ) -set( HUNSPELL_INCLUDE_DIR ${HUNSPELL_INCLUDE_DIRS} ) -set( HUNSPELL_LIBRARY ${HUNSPELL_LIBRARIES} ) \ No newline at end of file +# - Find HUNSPELL +# This module defines +# HUNSPELL_INCLUDE_DIR, where to find libhunspell.h, etc. +# HUNSPELL_LIBRARY, the library needed to use HUNSPELL. +# HUNSPELL_FOUND, If false, do not try to use HUNSPELL. + +find_path(HUNSPELL_INCLUDE_DIR hunspell.h + PATH_SUFFIXES hunspell + ) + +set(HUNSPELL_NAMES ${HUNSPELL_NAMES} hunspell-1.4 libhunspell-1.3 libhunspell) +find_library(HUNSPELL_LIBRARY + NAMES ${HUNSPELL_NAMES} + ) + +if (HUNSPELL_LIBRARY AND HUNSPELL_INCLUDE_DIR) + set(HUNSPELL_FOUND "YES") +else (HUNSPELL_LIBRARY AND HUNSPELL_INCLUDE_DIR) + set(HUNSPELL_FOUND "NO") +endif (HUNSPELL_LIBRARY AND HUNSPELL_INCLUDE_DIR) + + +if (HUNSPELL_FOUND) + if (NOT HUNSPELL_FIND_QUIETLY) + message(STATUS "Found Hunspell: Library in '${HUNSPELL_LIBRARY}' and header in '${HUNSPELL_INCLUDE_DIR}' ") + endif (NOT HUNSPELL_FIND_QUIETLY) +else (HUNSPELL_FOUND) + if (HUNSPELL_FIND_REQUIRED) + message(FATAL_ERROR " * * *\nCould not find HUNSPELL library! * * *") + endif (HUNSPELL_FIND_REQUIRED) +endif (HUNSPELL_FOUND) + +mark_as_advanced( + HUNSPELL_LIBRARY + HUNSPELL_INCLUDE_DIR + ) diff --git a/indra/cmake/FindJsonCpp.cmake b/indra/cmake/FindJsonCpp.cmake index c02794ed67..a2c74a4d27 100644 --- a/indra/cmake/FindJsonCpp.cmake +++ b/indra/cmake/FindJsonCpp.cmake @@ -1,6 +1,59 @@ # -*- cmake -*- -include(FindPkgConfig) -pkg_check_modules( JSONCPP REQUIRED jsoncpp ) -set( JSONCPP_INCLUDE_DIR ${JSONCPP_INCLUDE_DIRS} ) +# - Find JSONCpp +# Find the JSONCpp includes and library +# This module defines +# JSONCPP_INCLUDE_DIR, where to find json.h, etc. +# JSONCPP_LIBRARIES, the libraries needed to use jsoncpp. +# JSONCPP_FOUND, If false, do not try to use jsoncpp. +# also defined, but not for general use are +# JSONCPP_LIBRARY, where to find the jsoncpp library. +FIND_PATH(JSONCPP_INCLUDE_DIR NAMES jsoncpp/json.h jsoncpp/json/json.h +/usr/local/include +/usr/include +) + +# Get the GCC compiler version +EXEC_PROGRAM(${CMAKE_CXX_COMPILER} + ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion + OUTPUT_VARIABLE _gcc_COMPILER_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + +# Try to find a library that was compiled with the same compiler version as we currently use. +SET(JSONCPP_NAMES ${JSONCPP_NAMES} libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so) + +# On standalone, assume that the system installed library was compiled with the used compiler. +SET(JSONCPP_NAMES ${JSONCPP_NAMES} libjson.so libjsoncpp.so) + +FIND_LIBRARY(JSONCPP_LIBRARY + NAMES ${JSONCPP_NAMES} + ) + +IF (JSONCPP_LIBRARY AND JSONCPP_INCLUDE_DIR) + SET(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY}) + SET(JSONCPP_FOUND "YES") +ELSE (JSONCPP_LIBRARY AND JSONCPP_INCLUDE_DIR) + SET(JSONCPP_FOUND "NO") +ENDIF (JSONCPP_LIBRARY AND JSONCPP_INCLUDE_DIR) + + +IF (JSONCPP_FOUND) + IF (NOT JSONCPP_FIND_QUIETLY) + MESSAGE(STATUS "Found JSONCpp: ${JSONCPP_LIBRARIES}") + ENDIF (NOT JSONCPP_FIND_QUIETLY) +ELSE (JSONCPP_FOUND) + IF (JSONCPP_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find JSONCpp library") + ENDIF (JSONCPP_FIND_REQUIRED) +ENDIF (JSONCPP_FOUND) + +# Deprecated declarations. +SET (NATIVE_JSONCPP_INCLUDE_PATH ${JSONCPP_INCLUDE_DIR} ) +GET_FILENAME_COMPONENT (NATIVE_JSONCPP_LIB_PATH ${JSONCPP_LIBRARY} PATH) + +MARK_AS_ADVANCED( + JSONCPP_LIBRARY + JSONCPP_INCLUDE_DIR + ) diff --git a/indra/cmake/FindKDU.cmake b/indra/cmake/FindKDU.cmake index 6f86b34812..3944ad8308 100644 --- a/indra/cmake/FindKDU.cmake +++ b/indra/cmake/FindKDU.cmake @@ -1,9 +1,40 @@ -find_path( KDU_INCLUDE_DIR kdu/kdu_image.h ) -find_library( KDU_LIBRARY kdu_x64 ) +# -*- cmake -*- -if ( NOT KDU_LIBRARY OR NOT KDU_INCLUDE_DIR ) - message(FATAL_ERROR "Cannot find KDU: Library '${KDU_LIBRARY}'; header '${KDU_INCLUDE_DIR}' ") -endif() +# - Find KDU +# This module defines +# KDU_INCLUDE_DIR, where to find kdu.h, etc. +# KDU_LIBRARIES, the library needed to use KDU. +# KDU_FOUND, If false, do not try to use KDU. -set( KDU_INCLUDE_DIR ${KDU_INCLUDE_DIR}/kdu ) -set( LLKDU_LIBRARIES llkdu ) +# LL coded the #include with a glod path in llfloatermodelpreview.cpp +find_path(KDU_INCLUDE_DIR kdu_image.h + PATH_SUFFIXES kdu + ) + +set(KDU_NAMES ${KDU_NAMES} kdu) +find_library(KDU_LIBRARIES + NAMES ${KDU_NAMES} + ) + +if (KDU_LIBRARIES AND KDU_INCLUDE_DIR) + set(KDU_FOUND "YES") + set(KDU_INCLUDE_DIRS ${KDU_INCLUDE_DIR}) + set(KDU_LIBRARY ${KDU_LIBRARIES}) +else (KDU_LIBRARIES AND KDU_INCLUDE_DIR) + set(KDU_FOUND "NO") +endif (KDU_LIBRARIES AND KDU_INCLUDE_DIR) + +if (KDU_FOUND) + if (NOT KDU_FIND_QUIETLY) + message(STATUS "Found KDU: Library in '${KDU_LIBRARY}' and header in '${KDU_INCLUDE_DIR}' ") + endif (NOT KDU_FIND_QUIETLY) +else (KDU_FOUND) + if (KDU_FIND_REQUIRED) + message(FATAL_ERROR " * * * * *\nCould not find KDU library!\n* * * * *") + endif (KDU_FIND_REQUIRED) +endif (KDU_FOUND) + +mark_as_advanced( + KDU_LIBRARIES + KDU_INCLUDE_DIR + ) diff --git a/indra/cmake/FindNGHTTP2.cmake b/indra/cmake/FindNGHTTP2.cmake index 0ac3c812f9..c11d88814f 100644 --- a/indra/cmake/FindNGHTTP2.cmake +++ b/indra/cmake/FindNGHTTP2.cmake @@ -1,5 +1,35 @@ # -*- cmake -*- -include(FindPkgConfig) -pkg_check_modules(NGHTTP2 REQUIRED libnghttp2) +# - Find NGHTTP2 +# This module defines +# NGHTTP2_INCLUDE_DIR, where to find glod.h, etc. +# NGHTTP2_LIBRARIES, the library needed to use NGHTTP2. +# NGHTTP2_FOUND, If false, do not try to use NGHTTP2. +find_path(NGHTTP2_INCLUDE_DIR nghttp2/nghttp2.h) + +set(NGHTTP2_NAMES ${NGHTTP2_NAMES} nghttp2) +find_library(NGHTTP2_LIBRARIES + NAMES ${NGHTTP2_NAMES} + ) + +if (NGHTTP2_LIBRARIES AND NGHTTP2_INCLUDE_DIR) + set(NGHTTP2_FOUND "YES") +else (NGHTTP2_LIBRARIES AND NGHTTP2_INCLUDE_DIR) + set(NGHTTP2_FOUND "NO") +endif (NGHTTP2_LIBRARIES AND NGHTTP2_INCLUDE_DIR) + +if (NGHTTP2_FOUND) + if (NOT NGHTTP2_FIND_QUIETLY) + message(STATUS "Found NGHTTP2: Library in '${NGHTTP2_LIBRARY}' and header in '${NGHTTP2_INCLUDE_DIR}' ") + endif (NOT NGHTTP2_FIND_QUIETLY) +else (NGHTTP2_FOUND) + if (NGHTTP2_FIND_REQUIRED) + message(FATAL_ERROR " * * * * *\nCould not find NGHTTP2 library!\n* * * * *") + endif (NGHTTP2_FIND_REQUIRED) +endif (NGHTTP2_FOUND) + +mark_as_advanced( + NGHTTP2_LIBRARIES + NGHTTP2_INCLUDE_DIR + ) diff --git a/indra/cmake/FindOpenJPEG.cmake b/indra/cmake/FindOpenJPEG.cmake index 17ccf1e13d..cdbc6c5841 100644 --- a/indra/cmake/FindOpenJPEG.cmake +++ b/indra/cmake/FindOpenJPEG.cmake @@ -1,7 +1,52 @@ # -*- cmake -*- -include(FindPkgConfig) +# - Find OpenJPEG +# Find the OpenJPEG includes and library +# This module defines +# OPENJPEG_INCLUDE_DIR, where to find openjpeg.h, etc. +# OPENJPEG_LIBRARIES, the libraries needed to use OpenJPEG. +# OPENJPEG_FOUND, If false, do not try to use OpenJPEG. +# also defined, but not for general use are +# OPENJPEG_LIBRARY, where to find the OpenJPEG library. -pkg_check_modules( OPENJPEG REQUIRED libopenjpeg1 ) +FIND_PATH(OPENJPEG_INCLUDE_DIR openjpeg.h +/usr/local/include/openjpeg-2.1 +/usr/local/include/openjpeg +/usr/local/include +/usr/include/openjpeg-2.1 +/usr/include/openjpeg +/usr/include +) -set(OPENJPEG_INCLUDE_DIR ${OPENJPEG_INCLUDE_DIRS}) +SET(OPENJPEG_NAMES ${OPENJPEG_NAMES} openjpeg openjp2) +FIND_LIBRARY(OPENJPEG_LIBRARY + NAMES ${OPENJPEG_NAMES} + PATHS /usr/lib /usr/local/lib + ) + +IF (OPENJPEG_LIBRARY AND OPENJPEG_INCLUDE_DIR) + SET(OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARY}) + SET(OPENJPEG_FOUND "YES") +ELSE (OPENJPEG_LIBRARY AND OPENJPEG_INCLUDE_DIR) + SET(OPENJPEG_FOUND "NO") +ENDIF (OPENJPEG_LIBRARY AND OPENJPEG_INCLUDE_DIR) + + +IF (OPENJPEG_FOUND) + IF (NOT OPENJPEG_FIND_QUIETLY) + MESSAGE(STATUS "Found OpenJPEG: ${OPENJPEG_LIBRARIES}") + ENDIF (NOT OPENJPEG_FIND_QUIETLY) +ELSE (OPENJPEG_FOUND) + IF (OPENJPEG_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find OpenJPEG library") + ENDIF (OPENJPEG_FIND_REQUIRED) +ENDIF (OPENJPEG_FOUND) + +# Deprecated declarations. +SET (NATIVE_OPENJPEG_INCLUDE_PATH ${OPENJPEG_INCLUDE_DIR} ) +GET_FILENAME_COMPONENT (NATIVE_OPENJPEG_LIB_PATH ${OPENJPEG_LIBRARY} PATH) + +MARK_AS_ADVANCED( + OPENJPEG_LIBRARY + OPENJPEG_INCLUDE_DIR + ) diff --git a/indra/cmake/FindURIPARSER.cmake b/indra/cmake/FindURIPARSER.cmake index 213e71e2bf..b3b4efbbdb 100644 --- a/indra/cmake/FindURIPARSER.cmake +++ b/indra/cmake/FindURIPARSER.cmake @@ -1,5 +1,44 @@ # -*- cmake -*- -include(FindPkgConfig) -pkg_check_modules( URIPARSER REQUIRED liburiparser ) -set( URIPARSER_INCLUDE_DIR ${URIPARSER_INCLUDE_DIRS} ) \ No newline at end of file +# - Find uriparser +# Find the URIPARSER includes and library +# This module defines +# URIPARSER_INCLUDE_DIRS, where to find uriparser.h, etc. +# URIPARSER_LIBRARIES, the libraries needed to use uriparser. +# URIPARSER_FOUND, If false, do not try to use uriparser. +# +# This FindURIPARSER is about 43 times as fast the one provided with cmake (2.8.x), +# because it doesn't look up the version of uriparser, resulting in a dramatic +# speed up for configure (from 4 minutes 22 seconds to 6 seconds). +# +# Note: Since this file is only used for standalone, the windows +# specific parts were left out. + +FIND_PATH(URIPARSER_INCLUDE_DIR uriparser/Uri.h) + +FIND_LIBRARY(URIPARSER_LIBRARY uriparser) + +if (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR) + SET(URIPARSER_INCLUDE_DIRS ${URIPARSER_INCLUDE_DIR}) + SET(URIPARSER_LIBRARIES ${URIPARSER_LIBRARY}) + SET(URIPARSER_FOUND "YES") +else (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR) + SET(URIPARSER_FOUND "NO") +endif (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR) + +if (URIPARSER_FOUND) + if (NOT URIPARSER_FIND_QUIETLY) + message(STATUS "Found URIPARSER: ${URIPARSER_LIBRARIES}") + SET(URIPARSER_FIND_QUIETLY TRUE) + endif (NOT URIPARSER_FIND_QUIETLY) +else (URIPARSER_FOUND) + if (URIPARSER_FIND_REQUIRED) + message(FATAL_ERROR "Could not find URIPARSER library") + endif (URIPARSER_FIND_REQUIRED) +endif (URIPARSER_FOUND) + +mark_as_advanced( + URIPARSER_LIBRARY + URIPARSER_INCLUDE_DIR + ) + diff --git a/indra/cmake/FindZLIB.cmake b/indra/cmake/FindZLIB.cmake index 7701aca285..03a7db9d6f 100644 --- a/indra/cmake/FindZLIB.cmake +++ b/indra/cmake/FindZLIB.cmake @@ -1,5 +1,46 @@ # -*- cmake -*- -include(FindPkgConfig) -pkg_check_modules( ZLIB REQUIRED zlib ) -set( ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS} ) +# - Find zlib +# Find the ZLIB includes and library +# This module defines +# ZLIB_INCLUDE_DIRS, where to find zlib.h, etc. +# ZLIB_LIBRARIES, the libraries needed to use zlib. +# ZLIB_FOUND, If false, do not try to use zlib. +# +# This FindZLIB is about 43 times as fast the one provided with cmake (2.8.x), +# because it doesn't look up the version of zlib, resulting in a dramatic +# speed up for configure (from 4 minutes 22 seconds to 6 seconds). +# +# Note: Since this file is only used for standalone, the windows +# specific parts were left out. + +FIND_PATH(ZLIB_INCLUDE_DIR zlib.h + NO_SYSTEM_ENVIRONMENT_PATH + ) + +FIND_LIBRARY(ZLIB_LIBRARY z) + +if (ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR) + SET(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) + SET(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) + SET(ZLIB_FOUND "YES") +else (ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR) + SET(ZLIB_FOUND "NO") +endif (ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR) + +if (ZLIB_FOUND) + if (NOT ZLIB_FIND_QUIETLY) + message(STATUS "Found ZLIB: ${ZLIB_LIBRARIES}") + SET(ZLIB_FIND_QUIETLY TRUE) + endif (NOT ZLIB_FIND_QUIETLY) +else (ZLIB_FOUND) + if (ZLIB_FIND_REQUIRED) + message(FATAL_ERROR "Could not find ZLIB library") + endif (ZLIB_FIND_REQUIRED) +endif (ZLIB_FOUND) + +mark_as_advanced( + ZLIB_LIBRARY + ZLIB_INCLUDE_DIR + ) + diff --git a/indra/cmake/GLIB.cmake b/indra/cmake/GLIB.cmake deleted file mode 100644 index 0024cb26ac..0000000000 --- a/indra/cmake/GLIB.cmake +++ /dev/null @@ -1,11 +0,0 @@ - -include(Prebuilt) - -if( LINUX ) - use_prebuilt_binary(glib) - set(GLIB_FOUND ON CACHE BOOL "Build against glib 2") - set(GLIB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/glib-2.0 ${LIBS_PREBUILT_DIR}/lib/release/glib-2.0/include ) - set(GLIB_LIBRARIES libgobject-2.0.a libglib-2.0.a libffi.a libpcre.a) - - add_definitions(-DLL_GLIB=1) -endif() diff --git a/indra/cmake/GLOD.cmake b/indra/cmake/GLOD.cmake index e7fc1b39e9..2580ead67b 100644 --- a/indra/cmake/GLOD.cmake +++ b/indra/cmake/GLOD.cmake @@ -1,8 +1,9 @@ # -*- cmake -*- -if (USESYSTEMLIBS) - include(FindGLOD) -else (USESYSTEMLIBS) +#if (USESYSTEMLIBS) +# set(GLOD_FIND_REQUIRED true) +# include(FindGLOD) +#else (USESYSTEMLIBS) include(Prebuilt) use_prebuilt_binary(glod) set(GLOD_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include) @@ -11,4 +12,4 @@ if(LINUX) else() set(GLOD_LIBRARIES GLOD) endif() -endif (USESYSTEMLIBS) +#endif (USESYSTEMLIBS) diff --git a/indra/cmake/GStreamer010Plugin.cmake b/indra/cmake/GStreamer010Plugin.cmake index 2a41cc5314..3fbc40ef8f 100644 --- a/indra/cmake/GStreamer010Plugin.cmake +++ b/indra/cmake/GStreamer010Plugin.cmake @@ -1,6 +1,5 @@ # -*- cmake -*- include(Prebuilt) -include(GLIB) if (USESYSTEMLIBS) include(FindPkgConfig) @@ -14,10 +13,10 @@ elseif (LINUX) set(GSTREAMER010_FOUND ON FORCE BOOL) set(GSTREAMER010_PLUGINS_BASE_FOUND ON FORCE BOOL) set(GSTREAMER010_INCLUDE_DIRS - ${GLIB_INCLUDE_DIRS} - ${LIBS_PREBUILT_DIR}/include/gstreamer-0.10 - ${LIBS_PREBUILT_DIR}/include/libxml2 - ) + ${LIBS_PREBUILT_DIR}/include/gstreamer-0.10 + ${LIBS_PREBUILT_DIR}/include/glib-2.0 + ${LIBS_PREBUILT_DIR}/include/libxml2 + ) # We don't need to explicitly link against gstreamer itself, because # LLMediaImplGStreamer probes for the system's copy at runtime. set(GSTREAMER010_LIBRARIES diff --git a/indra/cmake/GStreamer10Plugin.cmake b/indra/cmake/GStreamer10Plugin.cmake deleted file mode 100644 index ded45da610..0000000000 --- a/indra/cmake/GStreamer10Plugin.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# -*- cmake -*- -include(Prebuilt) -include(GLIB) - -if (USESYSTEMLIBS) - include(FindPkgConfig) - - pkg_check_modules(GSTREAMER10 REQUIRED gstreamer-1.0) - pkg_check_modules(GSTREAMER10_PLUGINS_BASE REQUIRED gstreamer-plugins-base-1.0) -elseif (LINUX OR WINDOWS) - use_prebuilt_binary(gstreamer10) - use_prebuilt_binary(libxml2) - set(GSTREAMER10_FOUND ON FORCE BOOL) - set(GSTREAMER10_PLUGINS_BASE_FOUND ON FORCE BOOL) - set(GSTREAMER10_INCLUDE_DIRS - ${GLIB_INCLUDE_DIRS} - ${LIBS_PREBUILT_DIR}/include/gstreamer-1.0 - ${LIBS_PREBUILT_DIR}/include/libxml2 - ) - # We don't need to explicitly link against gstreamer itself, because - # LLMediaImplGStreamer probes for the system's copy at runtime. - set(GSTREAMER10_LIBRARIES) -endif (USESYSTEMLIBS) - -if (GSTREAMER10_FOUND AND GSTREAMER10_PLUGINS_BASE_FOUND) - set(GSTREAMER10 ON CACHE BOOL "Build with GStreamer-1.0 streaming media support.") -endif (GSTREAMER10_FOUND AND GSTREAMER10_PLUGINS_BASE_FOUND) - -if (GSTREAMER10) - add_definitions(-DLL_GSTREAMER10_ENABLED=1) -endif (GSTREAMER10) - diff --git a/indra/cmake/GoogleBreakpad.cmake b/indra/cmake/GoogleBreakpad.cmake index 829e1ac08a..83cf9cb1e7 100644 --- a/indra/cmake/GoogleBreakpad.cmake +++ b/indra/cmake/GoogleBreakpad.cmake @@ -1,10 +1,10 @@ # -*- cmake -*- include(Prebuilt) -if (USESYSTEMLIBS) - set(BREAKPAD_EXCEPTION_HANDLER_FIND_REQUIRED ON) - include(FindGoogleBreakpad) -else (USESYSTEMLIBS) +#if (USESYSTEMLIBS) +# set(BREAKPAD_EXCEPTION_HANDLER_FIND_REQUIRED ON) +# include(FindGoogleBreakpad) +#else (USESYSTEMLIBS) use_prebuilt_binary(google_breakpad) if (DARWIN) set(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES exception_handler) @@ -18,5 +18,5 @@ else (USESYSTEMLIBS) # yes, this does look dumb, no, it's not incorrect # set(BREAKPAD_INCLUDE_DIRECTORIES "${LIBS_PREBUILT_DIR}/include/google_breakpad" "${LIBS_PREBUILT_DIR}/include/google_breakpad/google_breakpad") -endif (USESYSTEMLIBS) +#endif (USESYSTEMLIBS) diff --git a/indra/cmake/GoogleMock.cmake b/indra/cmake/GoogleMock.cmake index 6ea2878d2e..5a00546927 100644 --- a/indra/cmake/GoogleMock.cmake +++ b/indra/cmake/GoogleMock.cmake @@ -2,44 +2,27 @@ include(Prebuilt) include(Linking) -if( NOT USESYSTEMLIBS ) - - use_prebuilt_binary(googlemock) +use_prebuilt_binary(googlemock) - set(GOOGLEMOCK_INCLUDE_DIRS - ${LIBS_PREBUILT_DIR}/include) +set(GOOGLEMOCK_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include) - if (LINUX) - # VWR-24366: gmock is underlinked, it needs gtest. - set(GOOGLEMOCK_LIBRARIES - gmock -Wl,--no-as-needed - gtest -Wl,--as-needed) - elseif(WINDOWS) - set(GOOGLEMOCK_LIBRARIES - gmock) - set(GOOGLEMOCK_INCLUDE_DIRS - ${LIBS_PREBUILT_DIR}/include - ${LIBS_PREBUILT_DIR}/include/gmock - ${LIBS_PREBUILT_DIR}/include/gmock/boost/tr1/tr1) - elseif(DARWIN) - set(GOOGLEMOCK_LIBRARIES - gmock - gtest) - endif(LINUX) -else() - - find_library( GOOGLETEST_LIBRARY gtest ) - find_library( GOOGLEMOCK_LIBRARY gmock ) +if (LINUX) + # VWR-24366: gmock is underlinked, it needs gtest. + set(GOOGLEMOCK_LIBRARIES + gmock -Wl,--no-as-needed + gtest -Wl,--as-needed) +elseif(WINDOWS) + set(GOOGLEMOCK_LIBRARIES + gmock) + set(GOOGLEMOCK_INCLUDE_DIRS + ${LIBS_PREBUILT_DIR}/include + ${LIBS_PREBUILT_DIR}/include/gmock + ${LIBS_PREBUILT_DIR}/include/gmock/boost/tr1/tr1) +elseif(DARWIN) + set(GOOGLEMOCK_LIBRARIES + gmock + gtest) +endif(LINUX) - if( GOOGLETEST_LIBRARY STREQUAL "GOOGLETEST_LIBRARY-NOTFOUND" ) - message( FATAL_ERROR "Cannot find gtest library" ) - endif() - - if( GOOGLEMOCK_LIBRARY STREQUAL "GOOGLEMOCK_LIBRARY-NOTFOUND" ) - message( FATAL_ERROR "Cannot find gmock library" ) - endif() - - set(GOOGLEMOCK_LIBRARIES ${GOOGLEMOCK_LIBRARY} ${GOOGLETEST_LIBRARY} ) - -endif() diff --git a/indra/cmake/LLPhysicsExtensions.cmake b/indra/cmake/LLPhysicsExtensions.cmake index 0093a05c58..3a41305e0c 100644 --- a/indra/cmake/LLPhysicsExtensions.cmake +++ b/indra/cmake/LLPhysicsExtensions.cmake @@ -23,8 +23,7 @@ if (HAVOK) elseif (HAVOK_TPV) use_prebuilt_binary(llphysicsextensions_tpv) - #set(LLPHYSICSEXTENSIONS_LIBRARIES llphysicsextensions_tpv) - set(LLPHYSICSEXTENSIONS_LIBRARIES libhacd.a libnd_hacdConvexDecomposition.a libnd_Pathing.a ) + set(LLPHYSICSEXTENSIONS_LIBRARIES llphysicsextensions_tpv) # include paths for LLs version and ours are different. set(LLPHYSICSEXTENSIONS_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/llphysicsextensions) diff --git a/indra/cmake/LLPrimitive.cmake b/indra/cmake/LLPrimitive.cmake index 1fe2cc6a9c..93626f689f 100644 --- a/indra/cmake/LLPrimitive.cmake +++ b/indra/cmake/LLPrimitive.cmake @@ -4,75 +4,46 @@ include(Prebuilt) include(Boost) +use_prebuilt_binary(colladadom) +use_prebuilt_binary(pcre) +use_prebuilt_binary(libxml2) + set(LLPRIMITIVE_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llprimitive ) +if (WINDOWS) + set(LLPRIMITIVE_LIBRARIES + debug llprimitive + optimized llprimitive + debug libcollada14dom23-sd + optimized libcollada14dom23-s + libxml2_a + debug pcrecppd + optimized pcrecpp + debug pcred + optimized pcre + ${BOOST_SYSTEM_LIBRARIES} + ) +elseif (DARWIN) + set(LLPRIMITIVE_LIBRARIES + llprimitive + debug collada14dom-d + optimized collada14dom + minizip + xml2 + pcrecpp + pcre + iconv # Required by libxml2 + ) +elseif (LINUX) + set(LLPRIMITIVE_LIBRARIES + llprimitive + debug collada14dom-d + optimized collada14dom + minizip + xml2 + pcrecpp + pcre + ) +endif (WINDOWS) -if( NOT USESYSTEMLIBS ) - use_prebuilt_binary(colladadom) - use_prebuilt_binary(pcre) - use_prebuilt_binary(libxml2) - - set( COLLADADOM_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/collada ${LIBS_PREBUILT_DIR}/include/collada/1.4 ) - - if (WINDOWS) - set(LLPRIMITIVE_LIBRARIES - debug llprimitive - optimized llprimitive - debug libcollada14dom23-sd - optimized libcollada14dom23-s - libxml2_a - debug pcrecppd - optimized pcrecpp - debug pcred - optimized pcre - ${BOOST_SYSTEM_LIBRARIES} - ) - elseif (DARWIN) - set(LLPRIMITIVE_LIBRARIES - llprimitive - debug collada14dom-d - optimized collada14dom - minizip - xml2 - pcrecpp - pcre - iconv # Required by libxml2 - ) - elseif (LINUX) - set(LLPRIMITIVE_LIBRARIES - llprimitive - debug collada14dom-d - optimized collada14dom - minizip - xml2 - pcrecpp - pcre - ) - endif (WINDOWS) - -else() - - include(FindPkgConfig) - pkg_check_modules( MINIZIP REQUIRED minizip ) - pkg_check_modules( LIBXML2 REQUIRED libxml-2.0 ) - pkg_check_modules( LIBPCRECPP REQUIRED libpcrecpp ) - - find_library( COLLADADOM_LIBRARY collada14dom ) - find_path( COLLADADOM_INCLUDE_DIR colladadom/dae.h ) - - if( COLLADADOM_INCLUDE_DIR STREQUAL "COLLADADOM_INCLUDE_DIR-NOTFOUND" ) - message( FATAL_ERROR "Cannot find colladadom include dir" ) - endif() - - set( COLLADADOM_INCLUDE_DIRS ${COLLADADOM_INCLUDE_DIR}/colladadom ${COLLADADOM_INCLUDE_DIR}/colladadom/1.4 ) - - set(LLPRIMITIVE_LIBRARIES - llprimitive - ${COLLADADOM_LIBRARY} - ${MINIZIP_LIBRARIES} - ${LIBXML2_LIBRARIES} - ${LIBPRCECPP_LIBRARIES} - ) - -endif() diff --git a/indra/cmake/LLWindow.cmake b/indra/cmake/LLWindow.cmake index 5156f09697..398647e58f 100644 --- a/indra/cmake/LLWindow.cmake +++ b/indra/cmake/LLWindow.cmake @@ -3,10 +3,9 @@ include(Variables) include(GLEXT) include(Prebuilt) -include(FindPkgConfig) if (USESYSTEMLIBS) - pkg_check_modules(SDL2 REQUIRED sdl2) + include(FindSDL) # This should be done by FindSDL. Sigh. mark_as_advanced( @@ -18,7 +17,7 @@ else (USESYSTEMLIBS) if (LINUX) use_prebuilt_binary(SDL) set (SDL_FOUND TRUE) - set (SDL_LIBRARY SDL2 X11) + set (SDL_LIBRARY SDL directfb fusion direct X11) endif (LINUX) endif (USESYSTEMLIBS) diff --git a/indra/cmake/UI.cmake b/indra/cmake/UI.cmake index 8c5d266cf5..f1a8b68900 100644 --- a/indra/cmake/UI.cmake +++ b/indra/cmake/UI.cmake @@ -5,29 +5,23 @@ include(FreeType) if (USESYSTEMLIBS) include(FindPkgConfig) - if( NOT GTK_VERSION ) - set( GTK_VERSION 2.0 ) - endif() if (LINUX) set(PKGCONFIG_PACKAGES atk cairo - gdk-${GTK_VERSION} + gdk-2.0 gdk-pixbuf-2.0 glib-2.0 gmodule-2.0 - gtk+-${GTK_VERSION} + gtk+-2.0 gthread-2.0 libpng pango pangoft2 - sdl2 + pangox + pangoxft + sdl ) - if( GTK_VERSION LESS "3.0" ) - LIST( APPEND PKGCONFIG_PACKAGES pangoxft ) - else() - add_definitions( -DGTK_DISABLE_DEPRECATED) - endif() endif (LINUX) foreach(pkg ${PKGCONFIG_PACKAGES}) @@ -37,16 +31,29 @@ if (USESYSTEMLIBS) list(APPEND UI_LIBRARIES ${${pkg}_LIBRARIES}) add_definitions(${${pkg}_CFLAGS_OTHERS}) endforeach(pkg) - list(APPEND UI_LIBRARIES X11) else (USESYSTEMLIBS) if (LINUX) - use_prebuilt_binary(fltk) + use_prebuilt_binary(gtk-atk-pango-glib) endif (LINUX) if (LINUX) set(UI_LIB_NAMES - libfltk.a freetype + atk-1.0 + gdk-x11-2.0 + gdk_pixbuf-2.0 + glib-2.0 + gmodule-2.0 + gobject-2.0 + gthread-2.0 + gtk-x11-2.0 + pango-1.0 + pangoft2-1.0 + pangox-1.0 + #pangoxft-1.0 + gio-2.0 + pangocairo-1.0 + ffi ) foreach(libname ${UI_LIB_NAMES}) @@ -73,5 +80,5 @@ else (USESYSTEMLIBS) endif (USESYSTEMLIBS) if (LINUX) - add_definitions(-DLL_X11=1 -DLL_FLTK=1) + add_definitions(-DLL_GTK=1 -DLL_X11=1) endif (LINUX) diff --git a/indra/cmake/jemalloc.cmake b/indra/cmake/jemalloc.cmake index d5df9fe2e5..8980134b0a 100644 --- a/indra/cmake/jemalloc.cmake +++ b/indra/cmake/jemalloc.cmake @@ -2,12 +2,12 @@ include(Prebuilt) if (LINUX AND NOT SYSTEMLIBS ) - set( USE_JEMALLOC ON CACHE BOOL "Ship prebuild jemalloc library with packaged viewer" ) + set(USE_JEMALLOC ON) endif () if( USE_JEMALLOC ) if (USESYSTEMLIBS) - message( WARNING "Search for jemalloc not implemented for standalone builds" ) + message( WARNING "Not implemented" ) else (USESYSTEMLIBS) use_prebuilt_binary(jemalloc) endif (USESYSTEMLIBS) diff --git a/indra/linux_crash_logger/CMakeLists.txt b/indra/linux_crash_logger/CMakeLists.txt index b166a33056..aa82ed12cc 100644 --- a/indra/linux_crash_logger/CMakeLists.txt +++ b/indra/linux_crash_logger/CMakeLists.txt @@ -59,9 +59,6 @@ add_executable(linux-crash-logger ${linux_crash_logger_SOURCE_FILES}) # llcommon uses `clock_gettime' which is provided by librt on linux. set(LIBRT_LIBRARY rt) -set(CMAKE_THREAD_PREFER_PTHREAD TRUE) -set(THREADS_PREFER_PTHREAD_FLAG TRUE) -find_package(Threads REQUIRED) target_link_libraries(linux-crash-logger ${LLCRASHLOGGER_LIBRARIES} @@ -77,7 +74,6 @@ target_link_libraries(linux-crash-logger ${DB_LIBRARIES} ${FREETYPE_LIBRARIES} ${LIBRT_LIBRARY} - Threads::Threads ) add_custom_target(linux-crash-logger-target ALL diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index b75e4ae704..cd59780a0f 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -343,9 +343,7 @@ if (DARWIN) target_link_libraries(llcommon ${CARBON_LIBRARY}) endif (DARWIN) -if( NOT USESYSTEMLIBS ) add_dependencies(llcommon stage_third_party_libs) -endif() if (LL_TESTS) include(LLAddBuildTest) diff --git a/indra/llfilesystem/lldir_linux.cpp b/indra/llfilesystem/lldir_linux.cpp index 512bfdb683..2e92e13bfd 100644 --- a/indra/llfilesystem/lldir_linux.cpp +++ b/indra/llfilesystem/lldir_linux.cpp @@ -39,11 +39,6 @@ static std::string getCurrentUserHome(char* fallback) { - // snap-package: - // could use SNAP_USER_DATA (/home/nicky/snap/viewer-release/x1, whereas x1 is the release and thus will change, data is backed up/restored across snap refresh / snap revert) - // could use SNAP_USER_COMMON (/home/nicky/snap/viewer-release/common, data is NOT backed up/restored across snap refresh / snap revert) - // see https://docs.snapcraft.io/environment-variables/7983 - const uid_t uid = getuid(); struct passwd *pw; @@ -176,10 +171,7 @@ void LLDir_Linux::initAppDirs(const std::string &app_name, // traditionally on unixoids, MyApp gets ~/.myapp dir for data mOSUserAppDir = mOSUserDir; mOSUserAppDir += "/"; - // When running as a snap package we canot use /home//.secondlife as strict-mode snaps do not get access to .dot files - // In that case we use /home//secondlife - if( nullptr == getenv( "SNAP_USER_DATA" ) ) - mOSUserAppDir += "."; + mOSUserAppDir += "."; std::string lower_app_name(app_name); LLStringUtil::toLower(lower_app_name); mOSUserAppDir += lower_app_name; diff --git a/indra/llplugin/llpluginsharedmemory.cpp b/indra/llplugin/llpluginsharedmemory.cpp index dcdfe122f5..63ff5085c6 100644 --- a/indra/llplugin/llpluginsharedmemory.cpp +++ b/indra/llplugin/llpluginsharedmemory.cpp @@ -318,16 +318,7 @@ bool LLPluginSharedMemory::unlink(void) bool LLPluginSharedMemory::create(size_t size) { - char const *pSnapName = getenv( "SNAP_NAME" ); - if( pSnapName ) - { - mName = "snap."; - mName += pSnapName; - mName += ".LL"; - } - else - mName = SHM_OPEN_SHARED_MEMORY_PREFIX_STRING; - + mName = SHM_OPEN_SHARED_MEMORY_PREFIX_STRING; mName += createName(); mSize = size; diff --git a/indra/llplugin/slplugin/CMakeLists.txt b/indra/llplugin/slplugin/CMakeLists.txt index 3158cb7e12..3e45820403 100644 --- a/indra/llplugin/slplugin/CMakeLists.txt +++ b/indra/llplugin/slplugin/CMakeLists.txt @@ -91,10 +91,6 @@ if (DARWIN) ) endif (DARWIN) -if( LINUX ) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") -endif() - if (LL_TESTS) ll_deploy_sharedlibs_command(SLPlugin) endif (LL_TESTS) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 81a942cd6d..d436173886 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -273,7 +273,6 @@ void LLGLSLShader::readProfileQuery(U32 count, U32 mode) glEndQueryARB(GL_TIME_ELAPSED); glEndQueryARB(GL_SAMPLES_PASSED); - // U64 and GLuint64 somehow turn out different on x86_64 //U64 time_elapsed = 0; GLuint64 time_elapsed = 0; diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index d242477c7e..bb003a77e3 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -190,12 +190,11 @@ endif (llwindow_HEADER_FILES) ${viewer_SOURCE_FILES} ) -if (SDL2_FOUND OR SDL_FOUND ) +if (SDL_FOUND) set_property(TARGET llwindow PROPERTY COMPILE_DEFINITIONS LL_SDL=1 ) -endif () +endif (SDL_FOUND) + + target_link_libraries (llwindow ${llwindow_LINK_LIBRARIES}) -if (NOT USESYSTEMLIBS) -target_link_libraries (llwindow ${llwindow_LINK_LIBRARIES}) -endif() diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index 10cbcf3115..f6f6c3931c 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -179,10 +179,12 @@ void LLKeyboard::resetKeys() } -BOOL LLKeyboard::translateKey(const U32 os_key, KEY *out_key) +BOOL LLKeyboard::translateKey(const U16 os_key, KEY *out_key) { + std::map::iterator iter; + // Only translate keys in the map, ignore all other keys for now - auto iter = mTranslateKeyMap.find(os_key); + iter = mTranslateKeyMap.find(os_key); if (iter == mTranslateKeyMap.end()) { //LL_WARNS() << "Unknown virtual key " << os_key << LL_ENDL; @@ -197,9 +199,10 @@ BOOL LLKeyboard::translateKey(const U32 os_key, KEY *out_key) } -U32 LLKeyboard::inverseTranslateKey(const KEY translated_key) +U16 LLKeyboard::inverseTranslateKey(const KEY translated_key) { - auto iter = mInvTranslateKeyMap.find(translated_key); + std::map::iterator iter; + iter = mInvTranslateKeyMap.find(translated_key); if (iter == mInvTranslateKeyMap.end()) { return 0; diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index 631ccd3a3a..6f2dc87317 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -75,19 +75,14 @@ public: BOOL getKeyDown(const KEY key) { return mKeyLevel[key]; } BOOL getKeyRepeated(const KEY key) { return mKeyRepeated[key]; } - BOOL translateKey(const U32 os_key, KEY *translated_key); - U32 inverseTranslateKey(const KEY translated_key); + BOOL translateKey(const U16 os_key, KEY *translated_key); + U16 inverseTranslateKey(const KEY translated_key); BOOL handleTranslatedKeyUp(KEY translated_key, U32 translated_mask); // Translated into "Linden" keycodes BOOL handleTranslatedKeyDown(KEY translated_key, U32 translated_mask); // Translated into "Linden" keycodes -#if LL_LINUX - virtual BOOL handleKeyUp(const U32 key, MASK mask) = 0; - virtual BOOL handleKeyDown(const U32 key, MASK mask) = 0; -#else virtual BOOL handleKeyUp(const U16 key, MASK mask) = 0; virtual BOOL handleKeyDown(const U16 key, MASK mask) = 0; -#endif #ifdef LL_DARWIN // We only actually use this for OS X. @@ -121,8 +116,8 @@ protected: void addKeyName(KEY key, const std::string& name); protected: - std::map mTranslateKeyMap; // Map of translations from OS keys to Linden KEYs - std::map mInvTranslateKeyMap; // Map of translations from Linden KEYs to OS keys + std::map mTranslateKeyMap; // Map of translations from OS keys to Linden KEYs + std::map mInvTranslateKeyMap; // Map of translations from Linden KEYs to OS keys LLWindowCallbacks *mCallbacks; LLTimer mKeyLevelTimer[KEY_COUNT]; // Time since level was set diff --git a/indra/llwindow/llkeyboardheadless.cpp b/indra/llwindow/llkeyboardheadless.cpp index 67a84d9478..a1b6b294e0 100644 --- a/indra/llwindow/llkeyboardheadless.cpp +++ b/indra/llwindow/llkeyboardheadless.cpp @@ -35,21 +35,12 @@ void LLKeyboardHeadless::resetMaskKeys() { } -#ifdef LL_LINUX - -BOOL LLKeyboardHeadless::handleKeyDown(const U32 key, const U32 mask) -{ return FALSE; } -BOOL LLKeyboardHeadless::handleKeyUp(const U32 key, const U32 mask) -{ return FALSE; } - -#else - -BOOL LLKeyboardHeadless::handleKeyUp(const U16 key, const U32 mask) -{ return FALSE; } BOOL LLKeyboardHeadless::handleKeyDown(const U16 key, const U32 mask) { return FALSE; } -#endif + +BOOL LLKeyboardHeadless::handleKeyUp(const U16 key, const U32 mask) +{ return FALSE; } MASK LLKeyboardHeadless::currentMask(BOOL for_mouse_event) { return MASK_NONE; } diff --git a/indra/llwindow/llkeyboardheadless.h b/indra/llwindow/llkeyboardheadless.h index 3131897544..8ed28ace90 100644 --- a/indra/llwindow/llkeyboardheadless.h +++ b/indra/llwindow/llkeyboardheadless.h @@ -35,13 +35,8 @@ public: LLKeyboardHeadless(); /*virtual*/ ~LLKeyboardHeadless() {}; -#ifdef LL_LINUX - /*virtual*/ BOOL handleKeyUp(const U32 key, MASK mask); - /*virtual*/ BOOL handleKeyDown(const U32 key, MASK mask); -#else /*virtual*/ BOOL handleKeyUp(const U16 key, MASK mask); /*virtual*/ BOOL handleKeyDown(const U16 key, MASK mask); -#endif /*virtual*/ void resetMaskKeys(); /*virtual*/ MASK currentMask(BOOL for_mouse_event); /*virtual*/ void scanKeyboard(); diff --git a/indra/llwindow/llkeyboardsdl.cpp b/indra/llwindow/llkeyboardsdl.cpp index 7416b4f7b2..7c9aa1d340 100644 --- a/indra/llwindow/llkeyboardsdl.cpp +++ b/indra/llwindow/llkeyboardsdl.cpp @@ -29,8 +29,7 @@ #include "linden_common.h" #include "llkeyboardsdl.h" #include "llwindowcallbacks.h" -#include "SDL2/SDL.h" -#include "SDL2/SDL_keycode.h" +#include "SDL/SDL.h" LLKeyboardSDL::LLKeyboardSDL() { @@ -41,10 +40,6 @@ LLKeyboardSDL::LLKeyboardSDL() // Virtual key mappings from SDL_keysym.h ... // SDL maps the letter keys to the ASCII you'd expect, but it's lowercase... - - // Looks like we need to map those despite of SDL_TEXTINPUT handling most of this, but without - // the translation lower->upper here accelerators will not work. - U16 cur_char; for (cur_char = 'A'; cur_char <= 'Z'; cur_char++) { @@ -54,7 +49,7 @@ LLKeyboardSDL::LLKeyboardSDL() { mTranslateKeyMap[cur_char] = (cur_char - 'a') + 'A'; } - + for (cur_char = '0'; cur_char <= '9'; cur_char++) { mTranslateKeyMap[cur_char] = cur_char; @@ -73,7 +68,7 @@ LLKeyboardSDL::LLKeyboardSDL() //mTranslateKeyMap[SDLK_KP3] = KEY_PAGE_DOWN; //mTranslateKeyMap[SDLK_KP0] = KEY_INSERT; - // mTranslateKeyMap[SDLK_SPACE] = ' '; // Those are handled by SDL2 via text input, do not map them + mTranslateKeyMap[SDLK_SPACE] = ' '; mTranslateKeyMap[SDLK_RETURN] = KEY_RETURN; mTranslateKeyMap[SDLK_LEFT] = KEY_LEFT; mTranslateKeyMap[SDLK_RIGHT] = KEY_RIGHT; @@ -116,39 +111,40 @@ LLKeyboardSDL::LLKeyboardSDL() mTranslateKeyMap[SDLK_F10] = KEY_F10; mTranslateKeyMap[SDLK_F11] = KEY_F11; mTranslateKeyMap[SDLK_F12] = KEY_F12; - // mTranslateKeyMap[SDLK_PLUS] = '='; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_COMMA] = ','; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_MINUS] = '-'; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_PERIOD] = '.'; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_BACKQUOTE] = '`'; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_SLASH] = KEY_DIVIDE; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_SEMICOLON] = ';'; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_LEFTBRACKET] = '['; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_BACKSLASH] = '\\'; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_RIGHTBRACKET] = ']'; // Those are handled by SDL2 via text input, do not map them - // mTranslateKeyMap[SDLK_QUOTE] = '\''; // Those are handled by SDL2 via text input, do not map them + mTranslateKeyMap[SDLK_PLUS] = '='; + mTranslateKeyMap[SDLK_COMMA] = ','; + mTranslateKeyMap[SDLK_MINUS] = '-'; + mTranslateKeyMap[SDLK_PERIOD] = '.'; + mTranslateKeyMap[SDLK_BACKQUOTE] = '`'; + mTranslateKeyMap[SDLK_SLASH] = KEY_DIVIDE; + mTranslateKeyMap[SDLK_SEMICOLON] = ';'; + mTranslateKeyMap[SDLK_LEFTBRACKET] = '['; + mTranslateKeyMap[SDLK_BACKSLASH] = '\\'; + mTranslateKeyMap[SDLK_RIGHTBRACKET] = ']'; + mTranslateKeyMap[SDLK_QUOTE] = '\''; // Build inverse map - for (auto iter = mTranslateKeyMap.begin(); iter != mTranslateKeyMap.end(); iter++) + std::map::iterator iter; + for (iter = mTranslateKeyMap.begin(); iter != mTranslateKeyMap.end(); iter++) { mInvTranslateKeyMap[iter->second] = iter->first; } // numpad map - mTranslateNumpadMap[SDLK_KP_0] = KEY_PAD_INS; - mTranslateNumpadMap[SDLK_KP_1] = KEY_PAD_END; - mTranslateNumpadMap[SDLK_KP_2] = KEY_PAD_DOWN; - mTranslateNumpadMap[SDLK_KP_3] = KEY_PAD_PGDN; - mTranslateNumpadMap[SDLK_KP_4] = KEY_PAD_LEFT; - mTranslateNumpadMap[SDLK_KP_5] = KEY_PAD_CENTER; - mTranslateNumpadMap[SDLK_KP_6] = KEY_PAD_RIGHT; - mTranslateNumpadMap[SDLK_KP_7] = KEY_PAD_HOME; - mTranslateNumpadMap[SDLK_KP_8] = KEY_PAD_UP; - mTranslateNumpadMap[SDLK_KP_9] = KEY_PAD_PGUP; + mTranslateNumpadMap[SDLK_KP0] = KEY_PAD_INS; + mTranslateNumpadMap[SDLK_KP1] = KEY_PAD_END; + mTranslateNumpadMap[SDLK_KP2] = KEY_PAD_DOWN; + mTranslateNumpadMap[SDLK_KP3] = KEY_PAD_PGDN; + mTranslateNumpadMap[SDLK_KP4] = KEY_PAD_LEFT; + mTranslateNumpadMap[SDLK_KP5] = KEY_PAD_CENTER; + mTranslateNumpadMap[SDLK_KP6] = KEY_PAD_RIGHT; + mTranslateNumpadMap[SDLK_KP7] = KEY_PAD_HOME; + mTranslateNumpadMap[SDLK_KP8] = KEY_PAD_UP; + mTranslateNumpadMap[SDLK_KP9] = KEY_PAD_PGUP; mTranslateNumpadMap[SDLK_KP_PERIOD] = KEY_PAD_DEL; // build inverse numpad map - for (auto iter = mTranslateNumpadMap.begin(); + for (iter = mTranslateNumpadMap.begin(); iter != mTranslateNumpadMap.end(); iter++) { @@ -158,7 +154,7 @@ LLKeyboardSDL::LLKeyboardSDL() void LLKeyboardSDL::resetMaskKeys() { - SDL_Keymod mask = SDL_GetModState(); + SDLMod mask = SDL_GetModState(); // MBW -- XXX -- This mirrors the operation of the Windows version of resetMaskKeys(). // It looks a bit suspicious, as it won't correct for keys that have been released. @@ -205,37 +201,37 @@ MASK LLKeyboardSDL::updateModifiers(const U32 mask) } -static U32 adjustNativekeyFromUnhandledMask(const U32 key, const U32 mask) +static U16 adjustNativekeyFromUnhandledMask(const U16 key, const U32 mask) { // SDL doesn't automatically adjust the keysym according to // whether NUMLOCK is engaged, so we massage the keysym manually. - U32 rtn = key; + U16 rtn = key; if (!(mask & KMOD_NUM)) { switch (key) { - case SDLK_KP_PERIOD: rtn = SDLK_DELETE; break; - case SDLK_KP_0: rtn = SDLK_INSERT; break; - case SDLK_KP_1: rtn = SDLK_END; break; - case SDLK_KP_2: rtn = SDLK_DOWN; break; - case SDLK_KP_3: rtn = SDLK_PAGEDOWN; break; - case SDLK_KP_4: rtn = SDLK_LEFT; break; - case SDLK_KP_6: rtn = SDLK_RIGHT; break; - case SDLK_KP_7: rtn = SDLK_HOME; break; - case SDLK_KP_8: rtn = SDLK_UP; break; - case SDLK_KP_9: rtn = SDLK_PAGEUP; break; + case SDLK_KP_PERIOD: rtn = SDLK_DELETE; break; + case SDLK_KP0: rtn = SDLK_INSERT; break; + case SDLK_KP1: rtn = SDLK_END; break; + case SDLK_KP2: rtn = SDLK_DOWN; break; + case SDLK_KP3: rtn = SDLK_PAGEDOWN; break; + case SDLK_KP4: rtn = SDLK_LEFT; break; + case SDLK_KP6: rtn = SDLK_RIGHT; break; + case SDLK_KP7: rtn = SDLK_HOME; break; + case SDLK_KP8: rtn = SDLK_UP; break; + case SDLK_KP9: rtn = SDLK_PAGEUP; break; } } return rtn; } -BOOL LLKeyboardSDL::handleKeyDown(const U32 key, const U32 mask) +BOOL LLKeyboardSDL::handleKeyDown(const U16 key, const U32 mask) { - U32 adjusted_nativekey; + U16 adjusted_nativekey; KEY translated_key = 0; U32 translated_mask = MASK_NONE; - BOOL handled = FALSE; + BOOL handled = FALSE; adjusted_nativekey = adjustNativekeyFromUnhandledMask(key, mask); @@ -250,12 +246,12 @@ BOOL LLKeyboardSDL::handleKeyDown(const U32 key, const U32 mask) } -BOOL LLKeyboardSDL::handleKeyUp(const U32 key, const U32 mask) +BOOL LLKeyboardSDL::handleKeyUp(const U16 key, const U32 mask) { - U32 adjusted_nativekey; + U16 adjusted_nativekey; KEY translated_key = 0; U32 translated_mask = MASK_NONE; - BOOL handled = FALSE; + BOOL handled = FALSE; adjusted_nativekey = adjustNativekeyFromUnhandledMask(key, mask); @@ -272,7 +268,7 @@ BOOL LLKeyboardSDL::handleKeyUp(const U32 key, const U32 mask) MASK LLKeyboardSDL::currentMask(BOOL for_mouse_event) { MASK result = MASK_NONE; - SDL_Keymod mask = SDL_GetModState(); + SDLMod mask = SDL_GetModState(); if (mask & KMOD_SHIFT) result |= MASK_SHIFT; if (mask & KMOD_CTRL) result |= MASK_CONTROL; @@ -281,7 +277,7 @@ MASK LLKeyboardSDL::currentMask(BOOL for_mouse_event) // For keyboard events, consider Meta keys equivalent to Control if (!for_mouse_event) { - if (mask & KMOD_GUI) result |= MASK_CONTROL; + if (mask & KMOD_META) result |= MASK_CONTROL; } return result; @@ -314,7 +310,7 @@ void LLKeyboardSDL::scanKeyboard() } -BOOL LLKeyboardSDL::translateNumpadKey( const U32 os_key, KEY *translated_key) +BOOL LLKeyboardSDL::translateNumpadKey( const U16 os_key, KEY *translated_key) { return translateKey(os_key, translated_key); } @@ -324,258 +320,5 @@ U16 LLKeyboardSDL::inverseTranslateNumpadKey(const KEY translated_key) return inverseTranslateKey(translated_key); } -enum class WindowsVK : U32 -{ - VK_UNKNOWN = 0, - VK_BACK = 0x08, - VK_TAB = 0x09, - VK_CLEAR = 0x0C, - VK_RETURN = 0x0D, - VK_SHIFT = 0x10, - VK_CONTROL = 0x11, - VK_MENU = 0x12, - VK_PAUSE = 0x13, - VK_CAPITAL = 0x14, - VK_KANA = 0x15, - VK_HANGUL = 0x15, - VK_JUNJA = 0x17, - VK_FINAL = 0x18, - VK_HANJA = 0x19, - VK_KANJI = 0x19, - VK_ESCAPE = 0x1B, - VK_CONVERT = 0x1C, - VK_NONCONVERT = 0x1D, - VK_ACCEPT = 0x1E, - VK_MODECHANGE = 0x1F, - VK_SPACE = 0x20, - VK_PRIOR = 0x21, - VK_NEXT = 0x22, - VK_END = 0x23, - VK_HOME = 0x24, - VK_LEFT = 0x25, - VK_UP = 0x26, - VK_RIGHT = 0x27, - VK_DOWN = 0x28, - VK_SELECT = 0x29, - VK_PRINT = 0x2A, - VK_EXECUTE = 0x2B, - VK_SNAPSHOT = 0x2C, - VK_INSERT = 0x2D, - VK_DELETE = 0x2E, - VK_HELP = 0x2F, - VK_0 = 0x30, - VK_1 = 0x31, - VK_2 = 0x32, - VK_3 = 0x33, - VK_4 = 0x34, - VK_5 = 0x35, - VK_6 = 0x36, - VK_7 = 0x37, - VK_8 = 0x38, - VK_9 = 0x39, - VK_A = 0x41, - VK_B = 0x42, - VK_C = 0x43, - VK_D = 0x44, - VK_E = 0x45, - VK_F = 0x46, - VK_G = 0x47, - VK_H = 0x48, - VK_I = 0x49, - VK_J = 0x4A, - VK_K = 0x4B, - VK_L = 0x4C, - VK_M = 0x4D, - VK_N = 0x4E, - VK_O = 0x4F, - VK_P = 0x50, - VK_Q = 0x51, - VK_R = 0x52, - VK_S = 0x53, - VK_T = 0x54, - VK_U = 0x55, - VK_V = 0x56, - VK_W = 0x57, - VK_X = 0x58, - VK_Y = 0x59, - VK_Z = 0x5A, - VK_LWIN = 0x5B, - VK_RWIN = 0x5C, - VK_APPS = 0x5D, - VK_SLEEP = 0x5F, - VK_NUMPAD0 = 0x60, - VK_NUMPAD1 = 0x61, - VK_NUMPAD2 = 0x62, - VK_NUMPAD3 = 0x63, - VK_NUMPAD4 = 0x64, - VK_NUMPAD5 = 0x65, - VK_NUMPAD6 = 0x66, - VK_NUMPAD7 = 0x67, - VK_NUMPAD8 = 0x68, - VK_NUMPAD9 = 0x69, - VK_MULTIPLY = 0x6A, - VK_ADD = 0x6B, - VK_SEPARATOR = 0x6C, - VK_SUBTRACT = 0x6D, - VK_DECIMAL = 0x6E, - VK_DIVIDE = 0x6F, - VK_F1 = 0x70, - VK_F2 = 0x71, - VK_F3 = 0x72, - VK_F4 = 0x73, - VK_F5 = 0x74, - VK_F6 = 0x75, - VK_F7 = 0x76, - VK_F8 = 0x77, - VK_F9 = 0x78, - VK_F10 = 0x79, - VK_F11 = 0x7A, - VK_F12 = 0x7B, - VK_F13 = 0x7C, - VK_F14 = 0x7D, - VK_F15 = 0x7E, - VK_F16 = 0x7F, - VK_F17 = 0x80, - VK_F18 = 0x81, - VK_F19 = 0x82, - VK_F20 = 0x83, - VK_F21 = 0x84, - VK_F22 = 0x85, - VK_F23 = 0x86, - VK_F24 = 0x87, - VK_NUMLOCK = 0x90, - VK_SCROLL = 0x91, - VK_LSHIFT = 0xA0, - VK_RSHIFT = 0xA1, - VK_LCONTROL = 0xA2, - VK_RCONTROL = 0xA3, - VK_LMENU = 0xA4, - VK_RMENU = 0xA5, - VK_BROWSER_BACK = 0xA6, - VK_BROWSER_FORWARD = 0xA7, - VK_BROWSER_REFRESH = 0xA8, - VK_BROWSER_STOP = 0xA9, - VK_BROWSER_SEARCH = 0xAA, - VK_BROWSER_FAVORITES = 0xAB, - VK_BROWSER_HOME = 0xAC, - VK_VOLUME_MUTE = 0xAD, - VK_VOLUME_DOWN = 0xAE, - VK_VOLUME_UP = 0xAF, - VK_MEDIA_NEXT_TRACK = 0xB0, - VK_MEDIA_PREV_TRACK = 0xB1, - VK_MEDIA_STOP = 0xB2, - VK_MEDIA_PLAY_PAUSE = 0xB3, - VK_MEDIA_LAUNCH_MAIL = 0xB4, - VK_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5, - VK_MEDIA_LAUNCH_APP1 = 0xB6, - VK_MEDIA_LAUNCH_APP2 = 0xB7, - VK_OEM_1 = 0xBA, - VK_OEM_PLUS = 0xBB, - VK_OEM_COMMA = 0xBC, - VK_OEM_MINUS = 0xBD, - VK_OEM_PERIOD = 0xBE, - VK_OEM_2 = 0xBF, - VK_OEM_3 = 0xC0, - VK_OEM_4 = 0xDB, - VK_OEM_5 = 0xDC, - VK_OEM_6 = 0xDD, - VK_OEM_7 = 0xDE, - VK_OEM_8 = 0xDF, - VK_OEM_102 = 0xE2, - VK_PROCESSKEY = 0xE5, - VK_PACKET = 0xE7, - VK_ATTN = 0xF6, - VK_CRSEL = 0xF7, - VK_EXSEL = 0xF8, - VK_EREOF = 0xF9, - VK_PLAY = 0xFA, - VK_ZOOM = 0xFB, - VK_NONAME = 0xFC, - VK_PA1 = 0xFD, - VK_OEM_CLEAR = 0xFE, -}; - -std::map< U32, U32 > mSDL2_to_Win; -std::set< U32 > mIgnoreSDL2Keys; - -U32 LLKeyboardSDL::mapSDL2toWin( U32 aSymbol ) -{ - // Map SDLK_ virtual keys to Windows VK_ virtual keys. - // Text is handled via unicode input (SDL_TEXTINPUT event) and does not need to be translated into VK_ values as those match already. - if( mSDL2_to_Win.empty() ) - { - mSDL2_to_Win[ SDLK_UNKNOWN ] = (U32)WindowsVK::VK_UNKNOWN; - mSDL2_to_Win[ SDLK_BACKSPACE ] = (U32)WindowsVK::VK_BACK; - mSDL2_to_Win[ SDLK_TAB ] = (U32)WindowsVK::VK_TAB; - mSDL2_to_Win[ SDLK_CLEAR ] = (U32)WindowsVK::VK_CLEAR; - mSDL2_to_Win[ SDLK_RETURN ] = (U32)WindowsVK::VK_RETURN; - mSDL2_to_Win[ SDLK_PAUSE ] = (U32)WindowsVK::VK_PAUSE; - mSDL2_to_Win[ SDLK_ESCAPE ] = (U32)WindowsVK::VK_ESCAPE; - mSDL2_to_Win[ SDLK_DELETE ] = (U32)WindowsVK::VK_DELETE; - mSDL2_to_Win[ SDLK_KP_PERIOD ] = (U32)WindowsVK::VK_OEM_PERIOD; - mSDL2_to_Win[ SDLK_KP_DIVIDE ] = (U32)WindowsVK::VK_DIVIDE; - mSDL2_to_Win[ SDLK_KP_MULTIPLY] = (U32)WindowsVK::VK_MULTIPLY; - mSDL2_to_Win[ SDLK_KP_MINUS ] = (U32)WindowsVK::VK_OEM_MINUS; - mSDL2_to_Win[ SDLK_KP_PLUS ] = (U32)WindowsVK::VK_OEM_PLUS; - mSDL2_to_Win[ SDLK_KP_ENTER ] = (U32)WindowsVK::VK_RETURN; - - // ? - //mSDL2_to_Win[ SDLK_KP_EQUALS ] = (U32)WindowsVK::VK_EQUALS; - - mSDL2_to_Win[ SDLK_UP ] = (U32)WindowsVK::VK_UP; - mSDL2_to_Win[ SDLK_DOWN ] = (U32)WindowsVK::VK_DOWN; - mSDL2_to_Win[ SDLK_RIGHT ] = (U32)WindowsVK::VK_RIGHT; - mSDL2_to_Win[ SDLK_LEFT ] = (U32)WindowsVK::VK_LEFT; - mSDL2_to_Win[ SDLK_INSERT ] = (U32)WindowsVK::VK_INSERT; - mSDL2_to_Win[ SDLK_HOME ] = (U32)WindowsVK::VK_HOME; - mSDL2_to_Win[ SDLK_END ] = (U32)WindowsVK::VK_END; - mSDL2_to_Win[ SDLK_PAGEUP ] = (U32)WindowsVK::VK_PRIOR; - mSDL2_to_Win[ SDLK_PAGEDOWN ] = (U32)WindowsVK::VK_NEXT; - mSDL2_to_Win[ SDLK_F1 ] = (U32)WindowsVK::VK_F1; - mSDL2_to_Win[ SDLK_F2 ] = (U32)WindowsVK::VK_F2; - mSDL2_to_Win[ SDLK_F3 ] = (U32)WindowsVK::VK_F3; - mSDL2_to_Win[ SDLK_F4 ] = (U32)WindowsVK::VK_F4; - mSDL2_to_Win[ SDLK_F5 ] = (U32)WindowsVK::VK_F5; - mSDL2_to_Win[ SDLK_F6 ] = (U32)WindowsVK::VK_F6; - mSDL2_to_Win[ SDLK_F7 ] = (U32)WindowsVK::VK_F7; - mSDL2_to_Win[ SDLK_F8 ] = (U32)WindowsVK::VK_F8; - mSDL2_to_Win[ SDLK_F9 ] = (U32)WindowsVK::VK_F9; - mSDL2_to_Win[ SDLK_F10 ] = (U32)WindowsVK::VK_F10; - mSDL2_to_Win[ SDLK_F11 ] = (U32)WindowsVK::VK_F11; - mSDL2_to_Win[ SDLK_F12 ] = (U32)WindowsVK::VK_F12; - mSDL2_to_Win[ SDLK_F13 ] = (U32)WindowsVK::VK_F13; - mSDL2_to_Win[ SDLK_F14 ] = (U32)WindowsVK::VK_F14; - mSDL2_to_Win[ SDLK_F15 ] = (U32)WindowsVK::VK_F15; - mSDL2_to_Win[ SDLK_CAPSLOCK ] = (U32)WindowsVK::VK_CAPITAL; - mSDL2_to_Win[ SDLK_RSHIFT ] = (U32)WindowsVK::VK_SHIFT; - mSDL2_to_Win[ SDLK_LSHIFT ] = (U32)WindowsVK::VK_SHIFT; - mSDL2_to_Win[ SDLK_RCTRL ] = (U32)WindowsVK::VK_CONTROL; - mSDL2_to_Win[ SDLK_LCTRL ] = (U32)WindowsVK::VK_CONTROL; - mSDL2_to_Win[ SDLK_RALT ] = (U32)WindowsVK::VK_MENU; - mSDL2_to_Win[ SDLK_LALT ] = (U32)WindowsVK::VK_MENU; - - // VK_MODECHANGE ? - // mSDL2_to_Win[ SDLK_MODE ] = (U32)WindowsVK::VK_MODE; - - mSDL2_to_Win[ SDLK_HELP ] = (U32)WindowsVK::VK_HELP; - - // ? - // mSDL2_to_Win[ SDLK_SYSREQ ] = (U32)WindowsVK::VK_SYSREQ; - mSDL2_to_Win[ SDLK_MENU ] = (U32)WindowsVK::VK_MENU; - - // ? - // mSDL2_to_Win[ SDLK_POWER ] = (U32)WindowsVK::VK_POWER; - - // ? - //mSDL2_to_Win[ SDLK_UNDO ] = (U32)WindowsVK::VK_UNDO; - } - - auto itr = mSDL2_to_Win.find( aSymbol ); - if( itr != mSDL2_to_Win.end() ) - return itr->second; - - return aSymbol; -} - #endif diff --git a/indra/llwindow/llkeyboardsdl.h b/indra/llwindow/llkeyboardsdl.h index e31229eb6e..02a71425f1 100644 --- a/indra/llwindow/llkeyboardsdl.h +++ b/indra/llwindow/llkeyboardsdl.h @@ -28,7 +28,7 @@ #define LL_LLKEYBOARDSDL_H #include "llkeyboard.h" -#include "SDL2/SDL.h" +#include "SDL/SDL.h" class LLKeyboardSDL : public LLKeyboard { @@ -36,8 +36,8 @@ public: LLKeyboardSDL(); /*virtual*/ ~LLKeyboardSDL() {}; - /*virtual*/ BOOL handleKeyUp(const U32 key, MASK mask); - /*virtual*/ BOOL handleKeyDown(const U32 key, MASK mask); + /*virtual*/ BOOL handleKeyUp(const U16 key, MASK mask); + /*virtual*/ BOOL handleKeyDown(const U16 key, MASK mask); /*virtual*/ void resetMaskKeys(); /*virtual*/ MASK currentMask(BOOL for_mouse_event); /*virtual*/ void scanKeyboard(); @@ -45,14 +45,11 @@ public: protected: MASK updateModifiers(const U32 mask); void setModifierKeyLevel( KEY key, BOOL new_state ); - BOOL translateNumpadKey( const U32 os_key, KEY *translated_key ); + BOOL translateNumpadKey( const U16 os_key, KEY *translated_key ); U16 inverseTranslateNumpadKey(const KEY translated_key); private: - std::map mTranslateNumpadMap; // special map for translating OS keys to numpad keys - std::map mInvTranslateNumpadMap; // inverse of the above - -public: - static U32 mapSDL2toWin( U32 ); + std::map mTranslateNumpadMap; // special map for translating OS keys to numpad keys + std::map mInvTranslateNumpadMap; // inverse of the above }; #endif diff --git a/indra/llwindow/llkeyboardwin32.cpp b/indra/llwindow/llkeyboardwin32.cpp index 5ce422a294..04b99187eb 100644 --- a/indra/llwindow/llkeyboardwin32.cpp +++ b/indra/llwindow/llkeyboardwin32.cpp @@ -119,10 +119,8 @@ LLKeyboardWin32::LLKeyboardWin32() mTranslateKeyMap[VK_APPS] = KEY_CONTEXT_MENU; // FIRE-19933: Open context menu on context menu key press // Build inverse map - // Change to U32 for SDL2 - //std::map::iterator iter; - // for (iter = mTranslateKeyMap.begin(); iter != mTranslateKeyMap.end(); iter++) - for (auto iter = mTranslateKeyMap.begin(); iter != mTranslateKeyMap.end(); iter++) + std::map::iterator iter; + for (iter = mTranslateKeyMap.begin(); iter != mTranslateKeyMap.end(); iter++) { mInvTranslateKeyMap[iter->second] = iter->first; } @@ -144,9 +142,7 @@ LLKeyboardWin32::LLKeyboardWin32() mTranslateNumpadMap[0x6E] = KEY_PAD_DEL; // keypad . mTranslateNumpadMap[0x6F] = KEY_PAD_DIVIDE; // keypad / - // Change to U32 for SDL2 - // for (iter = mTranslateNumpadMap.begin(); iter != mTranslateNumpadMap.end(); iter++) - for (auto iter = mTranslateNumpadMap.begin(); iter != mTranslateNumpadMap.end(); iter++) + for (iter = mTranslateNumpadMap.begin(); iter != mTranslateNumpadMap.end(); iter++) { mInvTranslateNumpadMap[iter->second] = iter->first; } diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 1d842755b0..52b48017ee 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -43,7 +43,6 @@ #if LL_GTK extern "C" { # include "gtk/gtk.h" -#include } #include #endif // LL_GTK @@ -121,6 +120,11 @@ bool LLWindowSDL::ll_try_gtk_init(void) if (!tried_gtk_init) { tried_gtk_init = TRUE; + +#if ( !defined(GLIB_MAJOR_VERSION) && !defined(GLIB_MINOR_VERSION) ) || ( GLIB_MAJOR_VERSION < 2 ) || ( GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 32 ) + if (!g_thread_supported ()) g_thread_init (NULL); +#endif + maybe_lock_display(); gtk_is_good = gtk_init_check(NULL, NULL); maybe_unlock_display(); @@ -204,7 +208,6 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, // Ignore use_gl for now, only used for drones on PC mWindow = NULL; - mContext = {}; mNeedsResize = FALSE; mOverrideAspectRatio = 0.f; mGrabbyKeyFlags = 0; @@ -252,6 +255,7 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, mFlashing = FALSE; #endif // LL_X11 + mKeyScanCode = 0; mKeyVirtualKey = 0; mKeyModifiers = KMOD_NONE; } @@ -328,6 +332,12 @@ static int x11_detect_VRAM_kb_fp(FILE *fp, const char *prefix_str) static int x11_detect_VRAM_kb() { +#if LL_SOLARIS && defined(__sparc) + // NOTE: there's no Xorg server on SPARC so just return 0 + // and allow SDL to attempt to get the amount of VRAM + return(0); +#else + std::string x_log_location("/var/log/"); std::string fname; int rtn = 0; // 'could not detect' @@ -408,65 +418,13 @@ static int x11_detect_VRAM_kb() } } return rtn; +#endif // LL_SOLARIS } #endif // LL_X11 void LLWindowSDL::setTitle(const std::string &title) { - SDL_SetWindowTitle( mWindow, title.c_str() ); -} - -void LLWindowSDL::tryFindFullscreenSize( int &width, int &height ) -{ - LL_INFOS() << "createContext: setting up fullscreen " << width << "x" << height << LL_ENDL; - - // If the requested width or height is 0, find the best default for the monitor. - if((width == 0) || (height == 0)) - { - // Scan through the list of modes, looking for one which has: - // height between 700 and 800 - // aspect ratio closest to the user's original mode - S32 resolutionCount = 0; - LLWindowResolution *resolutionList = getSupportedResolutions(resolutionCount); - - if(resolutionList != NULL) - { - F32 closestAspect = 0; - U32 closestHeight = 0; - U32 closestWidth = 0; - int i; - - LL_INFOS() << "createContext: searching for a display mode, original aspect is " << mOriginalAspectRatio << LL_ENDL; - - for(i=0; i < resolutionCount; i++) - { - F32 aspect = (F32)resolutionList[i].mWidth / (F32)resolutionList[i].mHeight; - - LL_INFOS() << "createContext: width " << resolutionList[i].mWidth << " height " << resolutionList[i].mHeight << " aspect " << aspect << LL_ENDL; - - if( (resolutionList[i].mHeight >= 700) && (resolutionList[i].mHeight <= 800) && - (fabs(aspect - mOriginalAspectRatio) < fabs(closestAspect - mOriginalAspectRatio))) - { - LL_INFOS() << " (new closest mode) " << LL_ENDL; - - // This is the closest mode we've seen yet. - closestWidth = resolutionList[i].mWidth; - closestHeight = resolutionList[i].mHeight; - closestAspect = aspect; - } - } - - width = closestWidth; - height = closestHeight; - } - } - - if((width == 0) || (height == 0)) - { - // Mode search failed for some reason. Use the old-school default. - width = 1024; - height = 768; - } + SDL_WM_SetCaption(title.c_str(), title.c_str()); } BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync) @@ -493,48 +451,90 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B << int(c_sdl_version.major) << "." << int(c_sdl_version.minor) << "." << int(c_sdl_version.patch) << LL_ENDL; - SDL_version r_sdl_version; - SDL_GetVersion(&r_sdl_version); + const SDL_version *r_sdl_version; + r_sdl_version = SDL_Linked_Version(); LL_INFOS() << " Running against SDL " - << int(r_sdl_version.major) << "." - << int(r_sdl_version.minor) << "." - << int(r_sdl_version.patch) << LL_ENDL; + << int(r_sdl_version->major) << "." + << int(r_sdl_version->minor) << "." + << int(r_sdl_version->patch) << LL_ENDL; - if (width == 0) - width = 1024; - if (height == 0) - width = 768; + const SDL_VideoInfo *video_info = SDL_GetVideoInfo( ); + if (!video_info) + { + LL_INFOS() << "SDL_GetVideoInfo() failed! " << SDL_GetError() << LL_ENDL; + setupFailure("SDL_GetVideoInfo() failed, Window creation error", "Error", OSMB_OK); + return FALSE; + } + + if (video_info->current_h > 0) + { + mOriginalAspectRatio = (float)video_info->current_w / (float)video_info->current_h; + + // FIRE-8825 - Try to work around an issue with Fullscreen and dual monitors + // assume two equal width monitors if aspect ratio exceeds 2.0 + // if someone can find out how to read a monitor's native resolution in OpenGL, please change this + // SDL1.2 doesn't offer any way to do it, apparently SDL 1.3 does + if(mOriginalAspectRatio>2.0f) + mOriginalAspectRatio=mOriginalAspectRatio/2.0f; + // + + LL_INFOS() << "Original aspect ratio was " << video_info->current_w << ":" << video_info->current_h << "=" << mOriginalAspectRatio << LL_ENDL; + } + + SDL_EnableUNICODE(1); + SDL_WM_SetCaption(mWindowTitle.c_str(), mWindowTitle.c_str()); + + // Set the application icon. + SDL_Surface *bmpsurface; + bmpsurface = Load_BMP_Resource("firestorm_icon.BMP"); + if (bmpsurface) + { + // This attempts to give a black-keyed mask to the icon. + SDL_SetColorKey(bmpsurface, + SDL_SRCCOLORKEY, + SDL_MapRGB(bmpsurface->format, 0,0,0) ); + SDL_WM_SetIcon(bmpsurface, NULL); + // The SDL examples cheerfully avoid freeing the icon + // surface, but I'm betting that's leaky. + SDL_FreeSurface(bmpsurface); + bmpsurface = NULL; + } + + // note: these SetAttributes make Tom's 9600-on-AMD64 fail to + // get a visual, but it's broken anyway when it does, and without + // these SetAttributes we might easily get an avoidable substandard + // visual to work with on most other machines. + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); +#if !LL_SOLARIS + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, (bits <= 16) ? 16 : 24); + // We need stencil support for a few (minor) things. + if (!getenv("LL_GL_NO_STENCIL")) + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); +#else + // NOTE- use smaller Z-buffer to enable more graphics cards + // - This should not affect better GPUs and has been proven + // to provide 24-bit z-buffers when available. + // + // As the API states: + // + // GLX_DEPTH_SIZE Must be followed by a nonnegative + // minimum size specification. If this + // value is zero, visuals with no depth + // buffer are preferred. Otherwise, the + // largest available depth buffer of at + // least the minimum size is preferred. + + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); +#endif + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, (bits <= 16) ? 1 : 8); + + // *FIX: try to toggle vsync here? mFullscreen = fullscreen; - int sdlflags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; - - if( mFullscreen ) - { - sdlflags |= SDL_WINDOW_FULLSCREEN; - tryFindFullscreenSize( width, height ); - } - - mSDLFlags = sdlflags; - - GLint redBits{8}, greenBits{8}, blueBits{8}, alphaBits{8}; - - GLint depthBits{(bits <= 16) ? 16 : 24}, stencilBits{8}; - - if (getenv("LL_GL_NO_STENCIL")) - stencilBits = 0; - - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, alphaBits); - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, redBits); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, greenBits); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, blueBits); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthBits ); - - // We need stencil support for a few (minor) things. - if (stencilBits) - SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBits); - - // *FIX: try to toggle vsync here? + int sdlflags = SDL_OPENGL | SDL_RESIZABLE | SDL_ANYFORMAT; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); @@ -544,31 +544,73 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, mFSAASamples); } - mWindow = SDL_CreateWindow( mWindowTitle.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, mSDLFlags ); + mSDLFlags = sdlflags; - if( mWindow ) + if (mFullscreen) { - mContext = SDL_GL_CreateContext( mWindow ); + LL_INFOS() << "createContext: setting up fullscreen " << width << "x" << height << LL_ENDL; - if( mContext == 0 ) + // If the requested width or height is 0, find the best default for the monitor. + if((width == 0) || (height == 0)) { - LL_WARNS() << "Cannot create GL context " << SDL_GetError() << LL_ENDL; - setupFailure("GL Context creation error creation error", "Error", OSMB_OK); - return FALSE; + // Scan through the list of modes, looking for one which has: + // height between 700 and 800 + // aspect ratio closest to the user's original mode + S32 resolutionCount = 0; + LLWindowResolution *resolutionList = getSupportedResolutions(resolutionCount); + + if(resolutionList != NULL) + { + F32 closestAspect = 0; + U32 closestHeight = 0; + U32 closestWidth = 0; + int i; + + LL_INFOS() << "createContext: searching for a display mode, original aspect is " << mOriginalAspectRatio << LL_ENDL; + + for(i=0; i < resolutionCount; i++) + { + F32 aspect = (F32)resolutionList[i].mWidth / (F32)resolutionList[i].mHeight; + + LL_INFOS() << "createContext: width " << resolutionList[i].mWidth << " height " << resolutionList[i].mHeight << " aspect " << aspect << LL_ENDL; + + if( (resolutionList[i].mHeight >= 700) && (resolutionList[i].mHeight <= 800) && + (fabs(aspect - mOriginalAspectRatio) < fabs(closestAspect - mOriginalAspectRatio))) + { + LL_INFOS() << " (new closest mode) " << LL_ENDL; + + // This is the closest mode we've seen yet. + closestWidth = resolutionList[i].mWidth; + closestHeight = resolutionList[i].mHeight; + closestAspect = aspect; + } + } + + width = closestWidth; + height = closestHeight; + } } - // SDL_GL_SetSwapInterval(1); - mSurface = SDL_GetWindowSurface( mWindow ); - } + if((width == 0) || (height == 0)) + { + // Mode search failed for some reason. Use the old-school default. + width = 1024; + height = 768; + } - if( mFullscreen ) - { - if (mSurface) + mWindow = SDL_SetVideoMode(width, height, bits, sdlflags | SDL_FULLSCREEN); + if (!mWindow && bits > 16) + { + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + mWindow = SDL_SetVideoMode(width, height, bits, sdlflags | SDL_FULLSCREEN); + } + + if (mWindow) { mFullscreen = TRUE; - mFullscreenWidth = mSurface->w; - mFullscreenHeight = mSurface->h; - mFullscreenBits = mSurface->format->BitsPerPixel; + mFullscreenWidth = mWindow->w; + mFullscreenHeight = mWindow->h; + mFullscreenBits = mWindow->format->BitsPerPixel; mFullscreenRefresh = -1; LL_INFOS() << "Running at " << mFullscreenWidth @@ -589,29 +631,35 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B std::string error = llformat("Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); OSMessageBox(error, "Error", OSMB_OK); - return FALSE; } } - else + + if(!mFullscreen && (mWindow == NULL)) { + if (width == 0) + width = 1024; + if (height == 0) + width = 768; + + LL_INFOS() << "createContext: creating window " << width << "x" << height << "x" << bits << LL_ENDL; + mWindow = SDL_SetVideoMode(width, height, bits, sdlflags); + if (!mWindow && bits > 16) + { + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + mWindow = SDL_SetVideoMode(width, height, bits, sdlflags); + } + if (!mWindow) { LL_WARNS() << "createContext: window creation failure. SDL: " << SDL_GetError() << LL_ENDL; setupFailure("Window creation error", "Error", OSMB_OK); return FALSE; } + } else if (!mFullscreen && (mWindow != NULL)) + { + LL_INFOS() << "createContext: SKIPPING - !fullscreen, but +mWindow " << width << "x" << height << "x" << bits << LL_ENDL; } - // Set the application icon. - SDL_Surface *bmpsurface; - bmpsurface = Load_BMP_Resource("firestorm_icon.BMP"); - if (bmpsurface) - { - SDL_SetWindowIcon(mWindow, bmpsurface); - SDL_FreeSurface(bmpsurface); - bmpsurface = NULL; - } - // Detect video memory size. # if LL_X11 gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024; @@ -624,7 +672,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B // fallback to letting SDL detect VRAM. // note: I've not seen SDL's detection ever actually find // VRAM != 0, but if SDL *does* detect it then that's a bonus. - gGLManager.mVRAM = 0; + gGLManager.mVRAM = video_info->video_mem / 1024; if (gGLManager.mVRAM != 0) { LL_INFOS() << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; @@ -636,32 +684,46 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B // explicitly unsupported cards. //const char* RENDERER = (const char*) glGetString(GL_RENDERER); - SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &redBits); - SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &greenBits); - SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &blueBits); - SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &alphaBits); - SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depthBits); - SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencilBits); + GLint depthBits, stencilBits, redBits, greenBits, blueBits, alphaBits; + + glGetIntegerv(GL_RED_BITS, &redBits); + glGetIntegerv(GL_GREEN_BITS, &greenBits); + glGetIntegerv(GL_BLUE_BITS, &blueBits); + glGetIntegerv(GL_ALPHA_BITS, &alphaBits); + glGetIntegerv(GL_DEPTH_BITS, &depthBits); + glGetIntegerv(GL_STENCIL_BITS, &stencilBits); LL_INFOS() << "GL buffer:" << LL_ENDL; - LL_INFOS() << " Red Bits " << S32(redBits) << LL_ENDL; - LL_INFOS() << " Green Bits " << S32(greenBits) << LL_ENDL; - LL_INFOS() << " Blue Bits " << S32(blueBits) << LL_ENDL; - LL_INFOS() << " Alpha Bits " << S32(alphaBits) << LL_ENDL; - LL_INFOS() << " Depth Bits " << S32(depthBits) << LL_ENDL; - LL_INFOS() << " Stencil Bits " << S32(stencilBits) << LL_ENDL; + LL_INFOS() << " Red Bits " << S32(redBits) << LL_ENDL; + LL_INFOS() << " Green Bits " << S32(greenBits) << LL_ENDL; + LL_INFOS() << " Blue Bits " << S32(blueBits) << LL_ENDL; + LL_INFOS() << " Alpha Bits " << S32(alphaBits) << LL_ENDL; + LL_INFOS() << " Depth Bits " << S32(depthBits) << LL_ENDL; + LL_INFOS() << " Stencil Bits " << S32(stencilBits) << LL_ENDL; GLint colorBits = redBits + greenBits + blueBits + alphaBits; // fixme: actually, it's REALLY important for picking that we get at // least 8 bits each of red,green,blue. Alpha we can be a bit more // relaxed about if we have to. +#if LL_SOLARIS && defined(__sparc) +// again the __sparc required because Xsun support, 32bit are very pricey on SPARC + if(colorBits < 24) //HACK: on SPARC allow 24-bit color +#else if (colorBits < 32) +#endif { close(); setupFailure( +#if LL_SOLARIS && defined(__sparc) + "Second Life requires at least 24-bit color on SPARC to run in a window.\n" + "Please use fbconfig to set your default color depth to 24 bits.\n" + "You may also need to adjust the X11 setting in SMF. To do so use\n" + " 'svccfg -s svc:/application/x11/x11-server setprop options/default_depth=24'\n" +#else "Second Life requires True Color (32-bit) to run in a window.\n" "Please go to Control Panels -> Display -> Settings and\n" "set the screen to 32-bit color.\n" +#endif "Alternately, if you choose to run fullscreen, Second Life\n" "will automatically adjust the screen each time it runs.", "Error", @@ -669,17 +731,36 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B return FALSE; } +#if 0 // *FIX: we're going to brave it for now... + if (alphaBits < 8) + { + close(); + setupFailure( + "Second Life is unable to run because it can't get an 8 bit alpha\n" + "channel. Usually this is due to video card driver issues.\n" + "Please make sure you have the latest video card drivers installed.\n" + "Also be sure your monitor is set to True Color (32-bit) in\n" + "Control Panels -> Display -> Settings.\n" + "If you continue to receive this message, contact customer service.", + "Error", + OSMB_OK); + return FALSE; + } +#endif + #if LL_X11 /* Grab the window manager specific information */ SDL_SysWMinfo info; SDL_VERSION(&info.version); - if ( SDL_GetWindowWMInfo(mWindow, &info) ) + if ( SDL_GetWMInfo(&info) ) { /* Save the information for later use */ if ( info.subsystem == SDL_SYSWM_X11 ) { mSDL_Display = info.info.x11.display; - mSDL_XWindowID = info.info.x11.window; + mSDL_XWindowID = info.info.x11.wmwindow; + Lock_Display = info.info.x11.lock_func; + Unlock_Display = info.info.x11.unlock_func; } else { @@ -695,10 +776,14 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B #endif // LL_X11 - SDL_StartTextInput(); //make sure multisampling is disabled by default glDisable(GL_MULTISAMPLE_ARB); + // We need to do this here, once video is init'd + if (-1 == SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, + SDL_DEFAULT_REPEAT_INTERVAL)) + LL_WARNS() << "Couldn't enable key-repeat: " << SDL_GetError() <mX = mSurface->w; - size->mY = mSurface->h; - return (TRUE); + size->mX = mWindow->w; + size->mY = mWindow->h; + return (TRUE); } return (FALSE); @@ -881,11 +965,11 @@ BOOL LLWindowSDL::getSize(LLCoordScreen *size) BOOL LLWindowSDL::getSize(LLCoordWindow *size) { - if (mSurface) + if (mWindow) { - size->mX = mSurface->w; - size->mY = mSurface->h; - return (TRUE); + size->mX = mWindow->w; + size->mY = mWindow->h; + return (TRUE); } return (FALSE); @@ -902,45 +986,48 @@ BOOL LLWindowSDL::setPosition(const LLCoordScreen position) return TRUE; } -template< typename T > bool setSizeImpl( const T& newSize, SDL_Window *pWin ) -{ - if( !pWin ) - return false; - - auto nFlags = SDL_GetWindowFlags( pWin ); - - if( nFlags & SDL_WINDOW_MAXIMIZED ) - SDL_RestoreWindow( pWin ); - - - SDL_SetWindowSize( pWin, newSize.mX, newSize.mY ); - SDL_Event event; - event.type = SDL_WINDOWEVENT; - event.window.event = SDL_WINDOWEVENT_RESIZED; - event.window.windowID = SDL_GetWindowID( pWin ); - event.window.data1 = newSize.mX; - event.window.data2 = newSize.mY; - SDL_PushEvent( &event ); - - return true; -} - BOOL LLWindowSDL::setSizeImpl(const LLCoordScreen size) { - return ::setSizeImpl( size, mWindow ); + if(mWindow) + { + // Push a resize event onto SDL's queue - we'll handle it + // when it comes out again. + SDL_Event event; + event.type = SDL_VIDEORESIZE; + event.resize.w = size.mX; + event.resize.h = size.mY; + SDL_PushEvent(&event); // copied into queue + + return TRUE; + } + + return FALSE; } BOOL LLWindowSDL::setSizeImpl(const LLCoordWindow size) { - return ::setSizeImpl( size, mWindow ); + if(mWindow) + { + // Push a resize event onto SDL's queue - we'll handle it + // when it comes out again. + SDL_Event event; + event.type = SDL_VIDEORESIZE; + event.resize.w = size.mX; + event.resize.h = size.mY; + SDL_PushEvent(&event); // copied into queue + + return TRUE; + } + + return FALSE; } void LLWindowSDL::swapBuffers() { if (mWindow) - { - SDL_GL_SwapWindow( mWindow ); + { + SDL_GL_SwapBuffers(); } } @@ -962,7 +1049,7 @@ F32 LLWindowSDL::getGamma() BOOL LLWindowSDL::restoreGamma() { //CGDisplayRestoreColorSyncSettings(); - // SDL_SetGamma(1.0f, 1.0f, 1.0f); + SDL_SetGamma(1.0f, 1.0f, 1.0f); return true; } @@ -971,7 +1058,7 @@ BOOL LLWindowSDL::setGamma(const F32 gamma) mGamma = gamma; if (mGamma == 0) mGamma = 0.1f; mGamma = 1/mGamma; - // SDL_SetGamma(mGamma, mGamma, mGamma); + SDL_SetGamma(mGamma, mGamma, mGamma); return true; } @@ -1020,7 +1107,7 @@ BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position) //LL_INFOS() << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << LL_ENDL; // do the actual forced cursor move. - SDL_WarpMouseInWindow(mWindow, screen_pos.mX, screen_pos.mY); + SDL_WarpMouse(screen_pos.mX, screen_pos.mY); //LL_INFOS() << llformat("llcw %d,%d -> scr %d,%d", position.mX, position.mY, screen_pos.mX, screen_pos.mY) << LL_ENDL; @@ -1118,7 +1205,7 @@ void LLWindowSDL::beforeDialog() // it only works in X11 if (running_x11 && mWindow) { - SDL_SetWindowFullscreen( mWindow, 0 ); + SDL_WM_ToggleFullScreen(mWindow); } } } @@ -1160,7 +1247,7 @@ void LLWindowSDL::afterDialog() // in X11 if (running_x11 && mWindow) { - SDL_SetWindowFullscreen( mWindow, 0 ); + SDL_WM_ToggleFullScreen(mWindow); } } } @@ -1216,33 +1303,107 @@ void LLWindowSDL::flashIcon(F32 seconds) } +#if LL_GTK BOOL LLWindowSDL::isClipboardTextAvailable() { - return SDL_HasClipboardText()==SDL_TRUE ? TRUE: FALSE; + if (ll_try_gtk_init()) + { + GtkClipboard * const clipboard = + gtk_clipboard_get(GDK_NONE); + return gtk_clipboard_wait_is_text_available(clipboard) ? + TRUE : FALSE; + } + return FALSE; // failure } BOOL LLWindowSDL::pasteTextFromClipboard(LLWString &text) { - char *pText = SDL_GetClipboardText(); - if( !pText ) - return FALSE; - - text = LLWString(utf8str_to_wstring(pText)); - SDL_free( pText ); - return TRUE; + if (ll_try_gtk_init()) + { + GtkClipboard * const clipboard = + gtk_clipboard_get(GDK_NONE); + gchar * const data = gtk_clipboard_wait_for_text(clipboard); + if (data) + { + text = LLWString(utf8str_to_wstring(data)); + g_free(data); + return TRUE; + } + } + return FALSE; // failure } BOOL LLWindowSDL::copyTextToClipboard(const LLWString &text) { - std::string utf8 = wstring_to_utf8str(text); - int res = SDL_SetClipboardText( utf8.c_str() ); - - if( res != 0 ) + if (ll_try_gtk_init()) { - LL_WARNS() << "SDL_SetClipboardText failed: " << SDL_GetError() << LL_ENDL; + const std::string utf8 = wstring_to_utf8str(text); + GtkClipboard * const clipboard = + gtk_clipboard_get(GDK_NONE); + gtk_clipboard_set_text(clipboard, utf8.c_str(), utf8.length()); + return TRUE; } - - return res == 0 ? TRUE : FALSE; + return FALSE; // failure +} + + +BOOL LLWindowSDL::isPrimaryTextAvailable() +{ + if (ll_try_gtk_init()) + { + GtkClipboard * const clipboard = + gtk_clipboard_get(GDK_SELECTION_PRIMARY); + return gtk_clipboard_wait_is_text_available(clipboard) ? + TRUE : FALSE; + } + return FALSE; // failure +} + +BOOL LLWindowSDL::pasteTextFromPrimary(LLWString &text) +{ + if (ll_try_gtk_init()) + { + GtkClipboard * const clipboard = + gtk_clipboard_get(GDK_SELECTION_PRIMARY); + gchar * const data = gtk_clipboard_wait_for_text(clipboard); + if (data) + { + text = LLWString(utf8str_to_wstring(data)); + g_free(data); + return TRUE; + } + } + return FALSE; // failure +} + +BOOL LLWindowSDL::copyTextToPrimary(const LLWString &text) +{ + if (ll_try_gtk_init()) + { + const std::string utf8 = wstring_to_utf8str(text); + GtkClipboard * const clipboard = + gtk_clipboard_get(GDK_SELECTION_PRIMARY); + gtk_clipboard_set_text(clipboard, utf8.c_str(), utf8.length()); + return TRUE; + } + return FALSE; // failure +} + +#else + +BOOL LLWindowSDL::isClipboardTextAvailable() +{ + return FALSE; // unsupported +} + +BOOL LLWindowSDL::pasteTextFromClipboard(LLWString &dst) +{ + return FALSE; // unsupported +} + +BOOL LLWindowSDL::copyTextToClipboard(const LLWString &s) +{ + return FALSE; // unsupported } BOOL LLWindowSDL::isPrimaryTextAvailable() @@ -1250,16 +1411,18 @@ BOOL LLWindowSDL::isPrimaryTextAvailable() return FALSE; // unsupported } -BOOL LLWindowSDL::pasteTextFromPrimary(LLWString &text) +BOOL LLWindowSDL::pasteTextFromPrimary(LLWString &dst) { return FALSE; // unsupported } -BOOL LLWindowSDL::copyTextToPrimary(const LLWString &text) +BOOL LLWindowSDL::copyTextToPrimary(const LLWString &s) { - return FALSE; // unsupported + return FALSE; // unsupported } +#endif // LL_GTK + LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_resolutions) { if (!mSupportedResolutions) @@ -1267,33 +1430,36 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso mSupportedResolutions = new LLWindowResolution[MAX_NUM_RESOLUTIONS]; mNumSupportedResolutions = 0; - // Use display no from mWindow/mSurface here? - int max = SDL_GetNumDisplayModes(0); - max = llclamp( max, 0, MAX_NUM_RESOLUTIONS ); + SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN); + if ( (modes != NULL) && (modes != ((SDL_Rect **) -1)) ) + { + int count = 0; + while (*modes && count= 800) && (h >= 600)) - { - // make sure we don't add the same resolution multiple times! - if ( (mNumSupportedResolutions == 0) || - ((mSupportedResolutions[mNumSupportedResolutions-1].mWidth != w) && - (mSupportedResolutions[mNumSupportedResolutions-1].mHeight != h)) ) - { - mSupportedResolutions[mNumSupportedResolutions].mWidth = w; - mSupportedResolutions[mNumSupportedResolutions].mHeight = h; - mNumSupportedResolutions++; - } - } - } + while (count--) + { + modes--; + SDL_Rect *r = *modes; + int w = r->w; + int h = r->h; + if ((w >= 800) && (h >= 600)) + { + // make sure we don't add the same resolution multiple times! + if ( (mNumSupportedResolutions == 0) || + ((mSupportedResolutions[mNumSupportedResolutions-1].mWidth != w) && + (mSupportedResolutions[mNumSupportedResolutions-1].mHeight != h)) ) + { + mSupportedResolutions[mNumSupportedResolutions].mWidth = w; + mSupportedResolutions[mNumSupportedResolutions].mHeight = h; + mNumSupportedResolutions++; + } + } + } + } } num_resolutions = mNumSupportedResolutions; @@ -1306,7 +1472,7 @@ BOOL LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to) return FALSE; to->mX = from.mX; - to->mY = mSurface->h - from.mY - 1; + to->mY = mWindow->h - from.mY - 1; return TRUE; } @@ -1317,7 +1483,7 @@ BOOL LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to) return FALSE; to->mX = from.mX; - to->mY = mSurface->h - from.mY - 1; + to->mY = mWindow->h - from.mY - 1; return TRUE; } @@ -1378,13 +1544,13 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) else mReallyCapturedCount = 0; - bool wantGrab; + SDL_GrabMode wantmode, newmode; if (mReallyCapturedCount <= 0) // uncapture { - wantGrab = false; + wantmode = SDL_GRAB_OFF; } else // capture { - wantGrab = true; + wantmode = SDL_GRAB_ON; } if (mReallyCapturedCount < 0) // yuck, imbalance. @@ -1393,11 +1559,9 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) LL_WARNS() << "ReallyCapture count was < 0" << LL_ENDL; } - bool newGrab = wantGrab; - -#if LL_X11 if (!mFullscreen) /* only bother if we're windowed anyway */ { +#if LL_X11 if (mSDL_Display) { /* we dirtily mix raw X11 with SDL so that our pointer @@ -1410,8 +1574,10 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) *keyboard* input from the window manager, which was frustrating users. */ int result; - if (wantGrab == true) + if (wantmode == SDL_GRAB_ON) { + //LL_INFOS() << "X11 POINTER GRABBY" << LL_ENDL; + //newmode = SDL_WM_GrabInput(wantmode); maybe_lock_display(); result = XGrabPointer(mSDL_Display, mSDL_XWindowID, True, 0, GrabModeAsync, @@ -1419,28 +1585,38 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) None, None, CurrentTime); maybe_unlock_display(); if (GrabSuccess == result) - newGrab = true; + newmode = SDL_GRAB_ON; else - newGrab = false; - } - else + newmode = SDL_GRAB_OFF; + } else if (wantmode == SDL_GRAB_OFF) { - newGrab = false; + //LL_INFOS() << "X11 POINTER UNGRABBY" << LL_ENDL; + newmode = SDL_GRAB_OFF; + //newmode = SDL_WM_GrabInput(SDL_GRAB_OFF); maybe_lock_display(); XUngrabPointer(mSDL_Display, CurrentTime); // Make sure the ungrab happens RIGHT NOW. XSync(mSDL_Display, False); maybe_unlock_display(); + } else + { + newmode = SDL_GRAB_QUERY; // neutral } - } - } + } else // not actually running on X11, for some reason + newmode = wantmode; #endif // LL_X11 + } else { + // pretend we got what we wanted, when really we don't care. + newmode = wantmode; + } + // return boolean success for whether we ended up in the desired state - return capture == newGrab; + return (capture && SDL_GRAB_ON==newmode) || + (!capture && SDL_GRAB_OFF==newmode); } -U32 LLWindowSDL::SDLCheckGrabbyKeys(U32 keysym, BOOL gain) +U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain) { /* part of the fix for SL-13243: Some popular window managers like to totally eat alt-drag for the purposes of moving windows. We @@ -1629,11 +1805,6 @@ void LLWindowSDL::gatherInput() { switch (event.type) { - case SDL_MOUSEWHEEL: - if( event.wheel.y != 0 ) - mCallbacks->handleScrollWheel(this, -event.wheel.y); - break; - case SDL_MOUSEMOTION: { LLCoordWindow winCoord(event.button.x, event.button.y); @@ -1644,45 +1815,35 @@ void LLWindowSDL::gatherInput() break; } - case SDL_TEXTINPUT: - { - auto string = utf8str_to_utf16str( event.text.text ); - for( auto key: string ) - { - mKeyVirtualKey = string[0]; - mKeyModifiers = SDL_GetModState(); - handleUnicodeUTF16( key, mKeyModifiers ); - } - break; - } - case SDL_KEYDOWN: - mKeyVirtualKey = event.key.keysym.sym; - mKeyModifiers = event.key.keysym.mod; + mKeyScanCode = event.key.keysym.scancode; + mKeyVirtualKey = event.key.keysym.unicode; + mKeyModifiers = event.key.keysym.mod; + mSDLSym = event.key.keysym.sym; // Store the SDL Keysym too. + + gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod); + // part of the fix for SL-13243 + if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0) + SDLReallyCaptureInput(TRUE); - gKeyboard->handleKeyDown(mKeyVirtualKey, mKeyModifiers ); - - // Slightly hacky :| To make the viewer honor enter (eg to accept form input) we've to not only send handleKeyDown but also send a - // invoke handleUnicodeUTF16 in case the user hits return. - // Note that we cannot blindly use handleUnicodeUTF16 for each SDL_KEYDOWN. Doing so will create bogus keyboard input (like % for cursor left). - if( mKeyVirtualKey == SDLK_RETURN ) - handleUnicodeUTF16( mKeyVirtualKey, mKeyModifiers ); - - // part of the fix for SL-13243 - if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0) - SDLReallyCaptureInput(TRUE); - - break; + if (event.key.keysym.unicode) + { + handleUnicodeUTF16(event.key.keysym.unicode, + gKeyboard->currentMask(FALSE)); + } + break; case SDL_KEYUP: - mKeyVirtualKey = event.key.keysym.sym; - mKeyModifiers = event.key.keysym.mod; + mKeyScanCode = event.key.keysym.scancode; + mKeyVirtualKey = event.key.keysym.unicode; + mKeyModifiers = event.key.keysym.mod; + mSDLSym = event.key.keysym.sym; // Store the SDL Keysym too. - if (SDLCheckGrabbyKeys(mKeyVirtualKey, FALSE) == 0) - SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243 + if (SDLCheckGrabbyKeys(event.key.keysym.sym, FALSE) == 0) + SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243 - gKeyboard->handleKeyUp(mKeyVirtualKey,mKeyModifiers); - break; + gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod); + break; case SDL_MOUSEBUTTONDOWN: { @@ -1690,7 +1851,7 @@ void LLWindowSDL::gatherInput() LLCoordWindow winCoord(event.button.x, event.button.y); LLCoordGL openGlCoord; convertCoords(winCoord, &openGlCoord); - MASK mask = gKeyboard->currentMask(TRUE); + MASK mask = gKeyboard->currentMask(TRUE); if (event.button.button == SDL_BUTTON_LEFT) // SDL doesn't manage double clicking... { @@ -1702,7 +1863,7 @@ void LLWindowSDL::gatherInput() if (++leftClick >= 2) { leftClick = 0; - isDoubleClick = true; + isDoubleClick = true; } } lastLeftDown = now; @@ -1733,7 +1894,7 @@ void LLWindowSDL::gatherInput() else if (event.button.button == SDL_BUTTON_RIGHT) // right { - mCallbacks->handleRightMouseDown(this, openGlCoord, mask); + mCallbacks->handleRightMouseDown(this, openGlCoord, mask); } else if (event.button.button == SDL_BUTTON_MIDDLE) // middle @@ -1753,67 +1914,86 @@ void LLWindowSDL::gatherInput() LLCoordWindow winCoord(event.button.x, event.button.y); LLCoordGL openGlCoord; convertCoords(winCoord, &openGlCoord); - MASK mask = gKeyboard->currentMask(TRUE); + MASK mask = gKeyboard->currentMask(TRUE); if (event.button.button == SDL_BUTTON_LEFT) // left - mCallbacks->handleMouseUp(this, openGlCoord, mask); + mCallbacks->handleMouseUp(this, openGlCoord, mask); else if (event.button.button == SDL_BUTTON_RIGHT) // right - mCallbacks->handleRightMouseUp(this, openGlCoord, mask); + mCallbacks->handleRightMouseUp(this, openGlCoord, mask); else if (event.button.button == SDL_BUTTON_MIDDLE) // middle - mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask); + mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask); // don't handle mousewheel here... break; } - case SDL_WINDOWEVENT: // *FIX: handle this? - { - if( event.window.event == SDL_WINDOWEVENT_RESIZED - /* || event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED*/ ) // SDL_WINDOWEVENT_SIZE_CHANGED is followed by SDL_WINDOWEVENT_RESIZED, so handling one shall be enough - { - LL_INFOS() << "Handling a resize event: " << event.window.data1 << "x" << event.window.data2 << LL_ENDL; - - S32 width = llmax(event.window.data1, (S32)mMinWindowWidth); - S32 height = llmax(event.window.data2, (S32)mMinWindowHeight); - mSurface = SDL_GetWindowSurface( mWindow ); - - // *FIX: I'm not sure this is necessary! - // I think is is not - // SDL_SetWindowSize(mWindow, width, height); - // - - mCallbacks->handleResize(this, width, height); - } - else if( event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED ) // What about SDL_WINDOWEVENT_ENTER (mouse focus) - { - // We have to do our own state massaging because SDL - // can send us two unfocus events in a row for example, - // which confuses the focus code [SL-24071]. - mHaveInputFocus = true; - - mCallbacks->handleFocus(this); - } - else if( event.window.event == SDL_WINDOWEVENT_FOCUS_LOST ) // What about SDL_WINDOWEVENT_LEAVE (mouse focus) - { - // We have to do our own state massaging because SDL - // can send us two unfocus events in a row for example, - // which confuses the focus code [SL-24071]. - mHaveInputFocus = false; - - mCallbacks->handleFocusLost(this); - } - else if( event.window.event == SDL_WINDOWEVENT_MINIMIZED || - event.window.event == SDL_WINDOWEVENT_MAXIMIZED || - event.window.event == SDL_WINDOWEVENT_RESTORED) - { - mIsMinimized = (event.window.event == SDL_WINDOWEVENT_MINIMIZED); - - mCallbacks->handleActivate(this, !mIsMinimized); - LL_INFOS() << "SDL deiconification state switched to " << mIsMinimized << LL_ENDL; - } + case SDL_VIDEOEXPOSE: // VIDEOEXPOSE doesn't specify the damage, but hey, it's OpenGL...repaint the whole thing! + mCallbacks->handlePaint(this, 0, 0, mWindow->w, mWindow->h); + break; - break; + case SDL_VIDEORESIZE: // *FIX: handle this? + { + LL_INFOS() << "Handling a resize event: " << event.resize.w << + "x" << event.resize.h << LL_ENDL; + + S32 width = llmax(event.resize.w, (S32)mMinWindowWidth); + S32 height = llmax(event.resize.h, (S32)mMinWindowHeight); + + // *FIX: I'm not sure this is necessary! + mWindow = SDL_SetVideoMode(width, height, 32, mSDLFlags); + if (!mWindow) + { + // *FIX: More informative dialog? + LL_INFOS() << "Could not recreate context after resize! Quitting..." << LL_ENDL; + if(mCallbacks->handleCloseRequest(this)) + { + // Get the app to initiate cleanup. + mCallbacks->handleQuit(this); + // The app is responsible for calling destroyWindow when done with GL + } + break; + } + + mCallbacks->handleResize(this, width, height); + break; + } + case SDL_ACTIVEEVENT: + if (event.active.state & SDL_APPINPUTFOCUS) + { + // Note that for SDL (particularly on X11), keyboard + // and mouse focus are independent things. Here we are + // tracking keyboard focus state changes. + + // We have to do our own state massaging because SDL + // can send us two unfocus events in a row for example, + // which confuses the focus code [SL-24071]. + if (event.active.gain != mHaveInputFocus) + { + mHaveInputFocus = !!event.active.gain; + + if (mHaveInputFocus) + mCallbacks->handleFocus(this); + else + mCallbacks->handleFocusLost(this); } + } + if (event.active.state & SDL_APPACTIVE) + { + // Change in iconification/minimization state. + if ((!event.active.gain) != mIsMinimized) + { + mIsMinimized = (!event.active.gain); + + mCallbacks->handleActivate(this, !mIsMinimized); + LL_INFOS() << "SDL deiconification state switched to " << BOOL(event.active.gain) << LL_ENDL; + } + else + { + LL_INFOS() << "Ignored bogus redundant SDL deiconification state switch to " << BOOL(event.active.gain) << LL_ENDL; + } + } + break; + case SDL_QUIT: if(mCallbacks->handleCloseRequest(this)) { @@ -1822,9 +2002,9 @@ void LLWindowSDL::gatherInput() // The app is responsible for calling destroyWindow when done with GL } break; - default: - //LL_INFOS() << "Unhandled SDL event type " << event.type << LL_ENDL; - break; + default: + //LL_INFOS() << "Unhandled SDL event type " << event.type << LL_ENDL; + break; } } @@ -1852,21 +2032,21 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty { SDL_Surface *cursurface; LL_DEBUGS() << "Loaded cursor file " << filename << " " - << bmpsurface->w << "x" << bmpsurface->h << LL_ENDL; + << bmpsurface->w << "x" << bmpsurface->h << LL_ENDL; cursurface = SDL_CreateRGBSurface (SDL_SWSURFACE, - bmpsurface->w, - bmpsurface->h, - 32, - SDL_SwapLE32(0xFFU), - SDL_SwapLE32(0xFF00U), - SDL_SwapLE32(0xFF0000U), - SDL_SwapLE32(0xFF000000U)); + bmpsurface->w, + bmpsurface->h, + 32, + SDL_SwapLE32(0xFFU), + SDL_SwapLE32(0xFF00U), + SDL_SwapLE32(0xFF0000U), + SDL_SwapLE32(0xFF000000U)); SDL_FillRect(cursurface, NULL, SDL_SwapLE32(0x00000000U)); // Blit the cursor pixel data onto a 32-bit RGBA surface so we // only have to cope with processing one type of pixel format. if (0 == SDL_BlitSurface(bmpsurface, NULL, - cursurface, NULL)) + cursurface, NULL)) { // n.b. we already checked that width is a multiple of 8. const int bitmap_bytes = (cursurface->w * cursurface->h) / 8; @@ -1898,9 +2078,9 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty } } sdlcursor = SDL_CreateCursor((Uint8*)cursor_data, - (Uint8*)cursor_mask, - cursurface->w, cursurface->h, - hotx, hoty); + (Uint8*)cursor_mask, + cursurface->w, cursurface->h, + hotx, hoty); delete[] cursor_data; delete[] cursor_mask; } else { @@ -2187,8 +2367,9 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ gWindowImplementation->mSDL_XWindowID != None) { gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin - GdkWindow *gdkwin = gdk_x11_window_foreign_new_for_display (gdk_display_get_default(), gWindowImplementation->mSDL_XWindowID); - gdk_window_set_transient_for(gtk_widget_get_window(GTK_WIDGET(win)), gdkwin); + GdkWindow *gdkwin = gdk_window_foreign_new(gWindowImplementation->mSDL_XWindowID); + gdk_window_set_transient_for(GTK_WIDGET(win)->window, + gdkwin); } # endif //LL_X11 @@ -2240,53 +2421,15 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ return rtn; } -BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) +static void color_changed_callback(GtkWidget *widget, + gpointer user_data) { - return FALSE; -} - -#else - -S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 type) -{ - SDL_MessageBoxData oData = { SDL_MESSAGEBOX_INFORMATION, nullptr, caption.c_str(), text.c_str(), 0, nullptr, nullptr }; - SDL_MessageBoxButtonData btnOk[] = {{SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, OSBTN_OK, "OK" }}; - SDL_MessageBoxButtonData btnOkCancel [] = {{SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, OSBTN_OK, "OK" }, {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, OSBTN_CANCEL, "Cancel"} }; - SDL_MessageBoxButtonData btnYesNo[] = { {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, OSBTN_YES, "Yes" }, {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, OSBTN_NO, "No"} }; + GtkColorSelection *colorsel = GTK_COLOR_SELECTION(widget); + GdkColor *colorp = (GdkColor*)user_data; - switch (type) - { - default: - case OSMB_OK: - oData.flags = SDL_MESSAGEBOX_WARNING; - oData.buttons = btnOk; - oData.numbuttons = 1; - break; - case OSMB_OKCANCEL: - oData.flags = SDL_MESSAGEBOX_INFORMATION; - oData.buttons = btnOkCancel; - oData.numbuttons = 2; - break; - case OSMB_YESNO: - oData.flags = SDL_MESSAGEBOX_INFORMATION; - oData.buttons = btnYesNo; - oData.numbuttons = 2; - break; - } - - int btn{0}; - if( 0 == SDL_ShowMessageBox( &oData, &btn ) ) - return btn; - return OSBTN_CANCEL; + gtk_color_selection_get_current_color(colorsel, colorp); } -BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) -{ - return (FALSE); -} -#endif // LL_GTK - - /* Make the raw keyboard data available - used to poke through to LLQtWebKit so @@ -2294,7 +2437,7 @@ BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) */ LLSD LLWindowSDL::getNativeKeyData() { - LLSD result = LLSD::emptyMap(); + LLSD result = LLSD::emptyMap(); U32 modifiers = 0; // pretend-native modifiers... oh what a tangled web we weave! @@ -2312,13 +2455,98 @@ LLSD LLWindowSDL::getNativeKeyData() // *todo: test ALTs - I don't have a case for testing these. Do you? // *todo: NUM? - I don't care enough right now (and it's not a GDK modifier). - result["virtual_key"] = (S32)mKeyVirtualKey; - result["virtual_key_win"] = (S32)LLKeyboardSDL::mapSDL2toWin( mKeyVirtualKey ); + result["scan_code"] = (S32)mKeyScanCode; + result["virtual_key"] = (S32)mKeyVirtualKey; result["modifiers"] = (S32)modifiers; - - return result; + result[ "sdl_sym" ] = (S32)mSDLSym; // Store the SDL Keysym too. + return result; } + +BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) +{ + BOOL rtn = FALSE; + + beforeDialog(); + + if (ll_try_gtk_init()) + { + GtkWidget *win = NULL; + + win = gtk_color_selection_dialog_new(NULL); + +# if LL_X11 + // Get GTK to tell the window manager to associate this + // dialog with our non-GTK SDL window, which should try + // to keep it on top etc. + if (mSDL_XWindowID != None) + { + gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin + GdkWindow *gdkwin = gdk_window_foreign_new(mSDL_XWindowID); + gdk_window_set_transient_for(GTK_WIDGET(win)->window, + gdkwin); + } +# endif //LL_X11 + + GtkColorSelection *colorsel = GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG(win)->colorsel); + + GdkColor color, orig_color; + orig_color.pixel = 0; + orig_color.red = guint16(65535 * *r); + orig_color.green= guint16(65535 * *g); + orig_color.blue = guint16(65535 * *b); + color = orig_color; + + gtk_color_selection_set_previous_color (colorsel, &color); + gtk_color_selection_set_current_color (colorsel, &color); + gtk_color_selection_set_has_palette (colorsel, TRUE); + gtk_color_selection_set_has_opacity_control(colorsel, FALSE); + + gint response = GTK_RESPONSE_NONE; + g_signal_connect (win, + "response", + G_CALLBACK (response_callback), + &response); + + g_signal_connect (G_OBJECT (colorsel), "color_changed", + G_CALLBACK (color_changed_callback), + &color); + + gtk_window_set_modal(GTK_WINDOW(win), TRUE); + gtk_widget_show_all(win); + // hide the help button - we don't service it. + gtk_widget_hide(GTK_COLOR_SELECTION_DIALOG(win)->help_button); + gtk_main(); + + if (response == GTK_RESPONSE_OK && + (orig_color.red != color.red + || orig_color.green != color.green + || orig_color.blue != color.blue) ) + { + *r = color.red / 65535.0f; + *g = color.green / 65535.0f; + *b = color.blue / 65535.0f; + rtn = TRUE; + } + } + + afterDialog(); + + return rtn; +} +#else +S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 type) +{ + LL_INFOS() << "MSGBOX: " << caption << ": " << text << LL_ENDL; + return 0; +} + +BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) +{ + return (FALSE); +} +#endif // LL_GTK + #if LL_LINUX || LL_SOLARIS // extracted from spawnWebBrowser for clarity and to eliminate // compiler confusion regarding close(int fd) vs. LLWindow::close() diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index 698f678b80..de0ee173ec 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -32,12 +32,12 @@ #include "llwindow.h" #include "lltimer.h" -#include "SDL2/SDL.h" -#include "SDL2/SDL_endian.h" +#include "SDL/SDL.h" +#include "SDL/SDL_endian.h" #if LL_X11 // get X11-specific headers for use in low-level stuff like copy-and-paste support -#include "SDL2/SDL_syswm.h" +#include "SDL/SDL_syswm.h" #endif // AssertMacros.h does bad things. @@ -182,7 +182,7 @@ protected: void destroyContext(); void setupFailure(const std::string& text, const std::string& caption, U32 type); void fixWindowSize(void); - U32 SDLCheckGrabbyKeys(U32 keysym, BOOL gain); + U32 SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain); BOOL SDLReallyCaptureInput(BOOL capture); // @@ -190,12 +190,7 @@ protected: // U32 mGrabbyKeyFlags; int mReallyCapturedCount; - - SDL_Window* mWindow; - SDL_Surface* mSurface; - SDL_GLContext mContext; - SDL_Cursor* mSDLCursors[UI_CURSOR_COUNT]; - + SDL_Surface * mWindow; std::string mWindowTitle; double mOriginalAspectRatio; BOOL mNeedsResize; // Constructor figured out the window is too big, it needs a resize. @@ -206,6 +201,7 @@ protected: int mSDLFlags; + SDL_Cursor* mSDLCursors[UI_CURSOR_COUNT]; int mHaveInputFocus; /* 0=no, 1=yes, else unknown */ int mIsMinimized; /* 0=no, 1=yes, else unknown */ @@ -218,12 +214,12 @@ private: LLTimer mFlashTimer; #endif //LL_X11 - U32 mKeyVirtualKey; - U32 mKeyModifiers; + U32 mKeyScanCode; + U32 mKeyVirtualKey; + SDLMod mKeyModifiers; + U32 mSDLSym; // Store the SDL Keysym too. BOOL mUseLegacyCursors; // Legacy cursor setting from main program -private: - void tryFindFullscreenSize( int &aWidth, int &aHeight ); }; diff --git a/indra/media_plugins/CMakeLists.txt b/indra/media_plugins/CMakeLists.txt index f1b617baa4..32e440a829 100644 --- a/indra/media_plugins/CMakeLists.txt +++ b/indra/media_plugins/CMakeLists.txt @@ -1,18 +1,11 @@ # -*- cmake -*- - add_subdirectory(base) if (LINUX) - include(GLIB) - #add_subdirectory(gstreamer010) - #add_subdirectory(example) - if( GLIB_FOUND ) - add_subdirectory(gstreamer10) - else() - MESSAGE( "Building without gstreamer (missing GLIB)" ) - endif() - #add_subdirectory(libvlc) +# add_subdirectory(gstreamer010) add_subdirectory(cef) + add_subdirectory(libvlc) + #add_subdirectory(example) endif (LINUX) if (DARWIN) diff --git a/indra/media_plugins/cef/media_plugin_cef.cpp b/indra/media_plugins/cef/media_plugin_cef.cpp index 8650b8cb8c..e845e81808 100644 --- a/indra/media_plugins/cef/media_plugin_cef.cpp +++ b/indra/media_plugins/cef/media_plugin_cef.cpp @@ -897,20 +897,12 @@ void MediaPluginCEF::keyEvent(dullahan::EKeyEvent key_event, LLSD native_key_dat // Keyboard handling for Linux. #if LL_LINUX - uint32_t native_virtual_key = (uint32_t)(native_key_data["virtual_key_win"].asInteger()); - uint32_t native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger()); - - if( native_virtual_key == '\n' ) - native_virtual_key = '\r'; - - mCEFLib->nativeKeyboardEventSDL2(key_event, native_virtual_key, native_modifiers, false); - - // Slightly hacky :| To make CEF honor enter (eg to accept form input) we've to not only send KE_KEY_UP/KE_KEY_DOWN - // but also a KE_KEY_CHAR event. - // Note that we cannot blindly send a KE_CHAR for each KE_KEY_UP. Doing so will create bogus keyboard input (like % for cursor left). - // Adding this just in llwindowsdl does not seem to fire an appropriate unicodeInput event down below, thus repeat this check here again :( - if( dullahan::KE_KEY_UP == key_event && native_virtual_key == '\r' ) - mCEFLib->nativeKeyboardEventSDL2(dullahan::KE_KEY_CHAR, native_virtual_key, native_modifiers, false); + uint32_t native_scan_code = (uint32_t)(native_key_data["sdl_sym"].asInteger()); + uint32_t native_virtual_key = (uint32_t)(native_key_data["virtual_key"].asInteger()); + uint32_t native_modifiers = (uint32_t)(native_key_data["cef_modifiers"].asInteger()); + if( native_scan_code == '\n' ) + native_scan_code = '\r'; + mCEFLib->nativeKeyboardEvent(key_event, native_scan_code, native_virtual_key, native_modifiers); #endif // }; @@ -943,17 +935,6 @@ void MediaPluginCEF::unicodeInput(std::string event, LLSD native_key_data = LLSD U64 lparam = ll_U32_from_sd(native_key_data["l_param"]); mCEFLib->nativeKeyboardEventWin(msg, wparam, lparam); #endif -// Keyboard handling for Linux. -#if LL_LINUX - uint32_t native_virtual_key = (uint32_t)(native_key_data["virtual_key_win"].asInteger()); - uint32_t native_modifiers = (uint32_t)(native_key_data["modifiers"].asInteger()); - - if( native_virtual_key == '\n' ) - native_virtual_key = '\r'; - - mCEFLib->nativeKeyboardEventSDL2(dullahan::KE_KEY_CHAR, native_virtual_key, native_modifiers, false); -#endif -// }; //////////////////////////////////////////////////////////////////////////////// diff --git a/indra/media_plugins/gstreamer010/CMakeLists.txt b/indra/media_plugins/gstreamer010/CMakeLists.txt index 67454c96c4..571eb57b24 100644 --- a/indra/media_plugins/gstreamer010/CMakeLists.txt +++ b/indra/media_plugins/gstreamer010/CMakeLists.txt @@ -37,7 +37,7 @@ if(NOT ADDRESS_SIZE EQUAL 32) if(WINDOWS) ##add_definitions(/FIXED:NO) else(WINDOWS) # not windows therefore gcc LINUX and DARWIN - add_definitions(-fPIC -Wno-literal-suffix) + add_definitions(-fPIC) endif(WINDOWS) endif(NOT ADDRESS_SIZE EQUAL 32) @@ -69,7 +69,7 @@ target_link_libraries(media_plugin_gstreamer010 add_dependencies(media_plugin_gstreamer010 ${LLPLUGIN_LIBRARIES} ${MEDIA_PLUGIN_BASE_LIBRARIES} - llcommon + ${LLCOMMON_LIBRARIES} ) diff --git a/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp b/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp index 6526706a24..6e8aa49377 100644 --- a/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp +++ b/indra/media_plugins/gstreamer010/media_plugin_gstreamer010.cpp @@ -853,6 +853,15 @@ MediaPluginGStreamer010::startup() if (!mDoneInit) { +#if ( !defined(GLIB_MAJOR_VERSION) && !defined(GLIB_MINOR_VERSION) ) || ( GLIB_MAJOR_VERSION < 2 ) || ( GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 32 ) + g_thread_init(NULL); +#endif + + // Init the glib type system - we need it. +#if ( !defined(GLIB_MAJOR_VERSION) && !defined(GLIB_MINOR_VERSION) ) || ( GLIB_MAJOR_VERSION < 2 ) || ( GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 35 ) + g_type_init(); +#endif + // Get symbols! #if LL_DARWIN if (! grab_gst_syms("libgstreamer-0.10.dylib", diff --git a/indra/media_plugins/gstreamer10/CMakeLists.txt b/indra/media_plugins/gstreamer10/CMakeLists.txt deleted file mode 100644 index 730a2c27fb..0000000000 --- a/indra/media_plugins/gstreamer10/CMakeLists.txt +++ /dev/null @@ -1,78 +0,0 @@ -# -*- cmake -*- - -project(media_plugin_gstreamer10) - -include(00-Common) -include(LLCommon) -include(LLImage) -include(LLPlugin) -include(LLMath) -include(LLRender) -include(LLWindow) -include(Linking) -include(PluginAPI) -include(MediaPluginBase) -include(OpenGL) -include(GLIB) - -include(GStreamer10Plugin) - -include_directories( - ${LLPLUGIN_INCLUDE_DIRS} - ${MEDIA_PLUGIN_BASE_INCLUDE_DIRS} - ${LLCOMMON_INCLUDE_DIRS} - ${LLMATH_INCLUDE_DIRS} - ${LLIMAGE_INCLUDE_DIRS} - ${LLRENDER_INCLUDE_DIRS} - ${LLWINDOW_INCLUDE_DIRS} - ${GSTREAMER10_INCLUDE_DIRS} - ${GSTREAMER10_PLUGINS_BASE_INCLUDE_DIRS} -) -include_directories(SYSTEM - ${LLCOMMON_SYSTEM_INCLUDE_DIRS} - ) - -### media_plugin_gstreamer10 - -if(NOT WORD_SIZE EQUAL 32) - if(NOT WINDOWS) # not windows therefore gcc LINUX and DARWIN - add_definitions(-fPIC) - endif() -endif(NOT WORD_SIZE EQUAL 32) - -set(media_plugin_gstreamer10_SOURCE_FILES - media_plugin_gstreamer10.cpp - llmediaimplgstreamer_syms.cpp - ) - -set(media_plugin_gstreamer10_HEADER_FILES - llmediaimplgstreamer_syms.h - llmediaimplgstreamertriviallogging.h - ) - -add_library(media_plugin_gstreamer10 - SHARED - ${media_plugin_gstreamer10_SOURCE_FILES} -) - -target_link_libraries(media_plugin_gstreamer10 - ${LLPLUGIN_LIBRARIES} - ${MEDIA_PLUGIN_BASE_LIBRARIES} - ${LLCOMMON_LIBRARIES} - ${PLUGIN_API_WINDOWS_LIBRARIES} - ${GSTREAMER10_LIBRARIES} -) - -#add_dependencies(media_plugin_gstreamer10 -# ${LLPLUGIN_LIBRARIES} -# ${MEDIA_PLUGIN_BASE_LIBRARIES} -# ${LLCOMMON_LIBRARIES} -#) - -if (WINDOWS) - set_target_properties( - media_plugin_gstreamer10 - PROPERTIES - LINK_FLAGS "/MANIFEST:NO /SAFESEH:NO /NODEFAULTLIB:LIBCMT" - ) -endif (WINDOWS) diff --git a/indra/media_plugins/gstreamer10/llmediaimplgstreamer.h b/indra/media_plugins/gstreamer10/llmediaimplgstreamer.h deleted file mode 100644 index 6bc272c009..0000000000 --- a/indra/media_plugins/gstreamer10/llmediaimplgstreamer.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file llmediaimplgstreamer.h - * @author Tofu Linden - * @brief implementation that supports media playback via GStreamer. - * - * @cond - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - * @endcond - */ - -// header guard -#ifndef llmediaimplgstreamer_h -#define llmediaimplgstreamer_h - -#if LL_GSTREAMER010_ENABLED - -extern "C" { -#include -#include - -#include "apr_pools.h" -#include "apr_dso.h" -} - - -extern "C" { -gboolean llmediaimplgstreamer_bus_callback (GstBus *bus, - GstMessage *message, - gpointer data); -} - -#endif // LL_GSTREAMER010_ENABLED - -#endif // llmediaimplgstreamer_h diff --git a/indra/media_plugins/gstreamer10/llmediaimplgstreamer_syms.cpp b/indra/media_plugins/gstreamer10/llmediaimplgstreamer_syms.cpp deleted file mode 100644 index e5e5c1c9a3..0000000000 --- a/indra/media_plugins/gstreamer10/llmediaimplgstreamer_syms.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/** - * @file llmediaimplgstreamer_syms.cpp - * @brief dynamic GStreamer symbol-grabbing code - * - * @cond - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - * @endcond - */ - -#include -#include -#include - -#ifdef LL_WINDOWS -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0502 -#include -#endif - -#include "linden_common.h" - -extern "C" { -#include -#include -} - -#include "apr_pools.h" -#include "apr_dso.h" - -#ifdef LL_WINDOWS - -#ifndef _M_AMD64 -#define GSTREAMER_REG_KEY "Software\\GStreamer1.0\\x86" -#define GSTREAMER_DIR_SUFFIX "1.0\\x86\\bin\\" -#else -#define GSTREAMER_REG_KEY "Software\\GStreamer1.0\\x86_64" -#define GSTREAMER_DIR_SUFFIX "1.0\\x86_64\\bin\\" -#endif - -bool openRegKey( HKEY &aKey ) -{ - // Try native (32 bit view/64 bit view) of registry first. - if( ERROR_SUCCESS == ::RegOpenKeyExA( HKEY_LOCAL_MACHINE, GSTREAMER_REG_KEY, 0, KEY_QUERY_VALUE, &aKey ) ) - return true; - - // If native view fails, use 32 bit view or registry. - if( ERROR_SUCCESS == ::RegOpenKeyExA( HKEY_LOCAL_MACHINE, GSTREAMER_REG_KEY, 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &aKey ) ) - return true; - - return false; -} - -std::string getGStreamerDir() -{ - std::string ret; - HKEY hKey; - - if( openRegKey( hKey ) ) - { - DWORD dwLen(0); - ::RegQueryValueExA( hKey, "InstallDir", nullptr, nullptr, nullptr, &dwLen ); - - if( dwLen > 0 ) - { - std::vector< char > vctBuffer; - vctBuffer.resize( dwLen ); - ::RegQueryValueExA( hKey, "InstallDir", nullptr, nullptr, reinterpret_cast< LPBYTE>(&vctBuffer[ 0 ]), &dwLen ); - ret = &vctBuffer[0]; - - if( ret[ dwLen-1 ] != '\\' ) - ret += "\\"; - ret += GSTREAMER_DIR_SUFFIX; - - SetDllDirectoryA( ret.c_str() ); - } - ::RegCloseKey( hKey ); - } - return ret; -} -#else -std::string getGStreamerDir() { return ""; } -#endif - -#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) RTN (*ll##GSTSYM)(__VA_ARGS__) = NULL; -#include "llmediaimplgstreamer_syms_raw.inc" -#undef LL_GST_SYM - -struct Symloader -{ - bool mRequired; - char const *mName; - apr_dso_handle_sym_t *mPPFunc; -}; - -#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) { REQ, #GSTSYM , (apr_dso_handle_sym_t*)&ll##GSTSYM}, -Symloader sSyms[] = { -#include "llmediaimplgstreamer_syms_raw.inc" -{ false, 0, 0 } }; -#undef LL_GST_SYM - -// a couple of stubs for disgusting reasons -GstDebugCategory* -ll_gst_debug_category_new(gchar *name, guint color, gchar *description) -{ - static GstDebugCategory dummy; - return &dummy; -} -void ll_gst_debug_register_funcptr(GstDebugFuncPtr func, gchar* ptrname) -{ -} - -static bool sSymsGrabbed = false; -static apr_pool_t *sSymGSTDSOMemoryPool = NULL; - -std::vector< apr_dso_handle_t* > sLoadedLibraries; - -bool grab_gst_syms( std::vector< std::string > const &aDSONames ) -{ - if (sSymsGrabbed) - return true; - - //attempt to load the shared libraries - apr_pool_create(&sSymGSTDSOMemoryPool, NULL); - - for( std::vector< std::string >::const_iterator itr = aDSONames.begin(); itr != aDSONames.end(); ++itr ) - { - apr_dso_handle_t *pDSO(NULL); - std::string strDSO = getGStreamerDir() + *itr; - if( APR_SUCCESS == apr_dso_load( &pDSO, strDSO.c_str(), sSymGSTDSOMemoryPool )) - sLoadedLibraries.push_back( pDSO ); - - for( int i = 0; sSyms[ i ].mName; ++i ) - { - if( !*sSyms[ i ].mPPFunc ) - { - apr_dso_sym( sSyms[ i ].mPPFunc, pDSO, sSyms[ i ].mName ); - } - } - } - - std::stringstream strm; - bool sym_error = false; - for( int i = 0; sSyms[ i ].mName; ++i ) - { - if( sSyms[ i ].mRequired && ! *sSyms[ i ].mPPFunc ) - { - sym_error = true; - strm << sSyms[ i ].mName << std::endl; - } - } - - sSymsGrabbed = !sym_error; - return sSymsGrabbed; -} - - -void ungrab_gst_syms() -{ - // should be safe to call regardless of whether we've - // actually grabbed syms. - - for( std::vector< apr_dso_handle_t* >::iterator itr = sLoadedLibraries.begin(); itr != sLoadedLibraries.end(); ++itr ) - apr_dso_unload( *itr ); - - sLoadedLibraries.clear(); - - if ( sSymGSTDSOMemoryPool ) - { - apr_pool_destroy(sSymGSTDSOMemoryPool); - sSymGSTDSOMemoryPool = NULL; - } - - for( int i = 0; sSyms[ i ].mName; ++i ) - *sSyms[ i ].mPPFunc = NULL; - - sSymsGrabbed = false; -} - diff --git a/indra/media_plugins/gstreamer10/llmediaimplgstreamer_syms.h b/indra/media_plugins/gstreamer10/llmediaimplgstreamer_syms.h deleted file mode 100644 index 0874644ee6..0000000000 --- a/indra/media_plugins/gstreamer10/llmediaimplgstreamer_syms.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file llmediaimplgstreamer_syms.h - * @brief dynamic GStreamer symbol-grabbing code - * - * @cond - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - * @endcond - */ - -#include "linden_common.h" -#include -extern "C" { -#include -} - -bool grab_gst_syms( std::vector< std::string > const&); -void ungrab_gst_syms(); - -#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) extern RTN (*ll##GSTSYM)(__VA_ARGS__); -#include "llmediaimplgstreamer_syms_raw.inc" -#undef LL_GST_SYM - -// regrettable hacks to give us better runtime compatibility with older systems -#define llg_return_if_fail(COND) do{if (!(COND)) return;}while(0) -#define llg_return_val_if_fail(COND,V) do{if (!(COND)) return V;}while(0) - -// regrettable hacks because GStreamer was not designed for runtime loading -#undef GST_TYPE_MESSAGE -#define GST_TYPE_MESSAGE (llgst_message_get_type()) -#undef GST_TYPE_OBJECT -#define GST_TYPE_OBJECT (llgst_object_get_type()) -#undef GST_TYPE_PIPELINE -#define GST_TYPE_PIPELINE (llgst_pipeline_get_type()) -#undef GST_TYPE_ELEMENT -#define GST_TYPE_ELEMENT (llgst_element_get_type()) -#undef GST_TYPE_VIDEO_SINK -#define GST_TYPE_VIDEO_SINK (llgst_video_sink_get_type()) -// more regrettable hacks to stub-out these .h-exposed GStreamer internals -void ll_gst_debug_register_funcptr(GstDebugFuncPtr func, gchar* ptrname); -#undef _gst_debug_register_funcptr -#define _gst_debug_register_funcptr ll_gst_debug_register_funcptr -GstDebugCategory* ll_gst_debug_category_new(gchar *name, guint color, gchar *description); -#undef _gst_debug_category_new -#define _gst_debug_category_new ll_gst_debug_category_new -#undef __gst_debug_enabled -#define __gst_debug_enabled (0) - -// more hacks -#define LLGST_MESSAGE_TYPE_NAME(M) (llgst_message_type_get_name(GST_MESSAGE_TYPE(M))) diff --git a/indra/media_plugins/gstreamer10/llmediaimplgstreamer_syms_raw.inc b/indra/media_plugins/gstreamer10/llmediaimplgstreamer_syms_raw.inc deleted file mode 100644 index da1aa8ec1d..0000000000 --- a/indra/media_plugins/gstreamer10/llmediaimplgstreamer_syms_raw.inc +++ /dev/null @@ -1,68 +0,0 @@ -LL_GST_SYM(true, gst_buffer_new, GstBuffer*, void) -LL_GST_SYM(true, gst_structure_set_value, void, GstStructure *, const gchar *, const GValue*) -LL_GST_SYM(true, gst_init_check, gboolean, int *argc, char **argv[], GError ** err) -LL_GST_SYM(true, gst_message_get_type, GType, void) -LL_GST_SYM(true, gst_message_type_get_name, const gchar*, GstMessageType type) -LL_GST_SYM(true, gst_message_parse_error, void, GstMessage *message, GError **gerror, gchar **debug) -LL_GST_SYM(true, gst_message_parse_warning, void, GstMessage *message, GError **gerror, gchar **debug) -LL_GST_SYM(true, gst_message_parse_state_changed, void, GstMessage *message, GstState *oldstate, GstState *newstate, GstState *pending) -LL_GST_SYM(true, gst_element_set_state, GstStateChangeReturn, GstElement *element, GstState state) -LL_GST_SYM(true, gst_object_unref, void, gpointer object) -LL_GST_SYM(true, gst_object_get_type, GType, void) -LL_GST_SYM(true, gst_pipeline_get_type, GType, void) -LL_GST_SYM(true, gst_pipeline_get_bus, GstBus*, GstPipeline *pipeline) -LL_GST_SYM(true, gst_bus_add_watch, guint, GstBus * bus, GstBusFunc func, gpointer user_data) -LL_GST_SYM(true, gst_element_factory_make, GstElement*, const gchar *factoryname, const gchar *name) -LL_GST_SYM(true, gst_element_get_type, GType, void) -LL_GST_SYM(true, gst_static_pad_template_get, GstPadTemplate*, GstStaticPadTemplate *pad_template) -LL_GST_SYM(true, gst_element_class_add_pad_template, void, GstElementClass *klass, GstPadTemplate *temp) -LL_GST_SYM(true, gst_caps_from_string, GstCaps *, const gchar *string) -LL_GST_SYM(true, gst_caps_get_structure, GstStructure *, const GstCaps *caps, guint index) -LL_GST_SYM(true, gst_element_register, gboolean, GstPlugin *plugin, const gchar *name, guint rank, GType type) -LL_GST_SYM(true, gst_structure_get_int, gboolean, const GstStructure *structure, const gchar *fieldname, gint *value) -LL_GST_SYM(true, gst_structure_get_value, G_CONST_RETURN GValue *, const GstStructure *structure, const gchar *fieldname) -LL_GST_SYM(true, gst_value_get_fraction_numerator, gint, const GValue *value) -LL_GST_SYM(true, gst_value_get_fraction_denominator, gint, const GValue *value) -LL_GST_SYM(true, gst_structure_get_name, G_CONST_RETURN gchar *, const GstStructure *structure) -LL_GST_SYM(true, gst_element_seek, bool, GstElement *, gdouble, GstFormat, GstSeekFlags, GstSeekType, gint64, GstSeekType, gint64) - -LL_GST_SYM(false, gst_registry_fork_set_enabled, void, gboolean enabled) -LL_GST_SYM(false, gst_segtrap_set_enabled, void, gboolean enabled) -LL_GST_SYM(false, gst_message_parse_buffering, void, GstMessage *message, gint *percent) -LL_GST_SYM(false, gst_message_parse_info, void, GstMessage *message, GError **gerror, gchar **debug) -LL_GST_SYM(false, gst_element_query_position, gboolean, GstElement *element, GstFormat *format, gint64 *cur) -LL_GST_SYM(false, gst_version, void, guint *major, guint *minor, guint *micro, guint *nano) - -LL_GST_SYM( true, gst_message_parse_tag, void, GstMessage *, GstTagList **) -LL_GST_SYM( true, gst_tag_list_foreach, void, const GstTagList *, GstTagForeachFunc, gpointer) -LL_GST_SYM( true, gst_tag_list_get_tag_size, guint, const GstTagList *, const gchar *) -LL_GST_SYM( true, gst_tag_list_get_value_index, const GValue *, const GstTagList *, const gchar *, guint) - -LL_GST_SYM( true, gst_caps_new_simple, GstCaps*, const char *, const char*, ... ) - -LL_GST_SYM( true, gst_sample_get_caps, GstCaps*, GstSample* ) -LL_GST_SYM( true, gst_sample_get_buffer, GstBuffer*, GstSample* ) -LL_GST_SYM( true, gst_buffer_map, gboolean, GstBuffer*, GstMapInfo*, GstMapFlags ) -LL_GST_SYM( true, gst_buffer_unmap, void, GstBuffer*, GstMapInfo* ) - -LL_GST_SYM( true, gst_app_sink_set_caps, void, GstAppSink*, GstCaps const* ) -LL_GST_SYM( true, gst_app_sink_pull_sample, GstSample*, GstAppSink* ) - -LL_GST_SYM( true, g_free, void, gpointer ) -LL_GST_SYM( true, g_error_free, void, GError* ) - -LL_GST_SYM( true, g_main_context_pending, gboolean, GMainContext* ) -LL_GST_SYM( true, g_main_loop_get_context, GMainContext*, GMainLoop* ) -LL_GST_SYM( true, g_main_context_iteration, gboolean, GMainContext*, gboolean ) -LL_GST_SYM( true, g_main_loop_new, GMainLoop*, GMainContext*, gboolean ) -LL_GST_SYM( true, g_main_loop_quit, void, GMainLoop* ) -LL_GST_SYM( true, gst_mini_object_unref, void, GstMiniObject* ) -LL_GST_SYM( true, g_object_set, void, gpointer, gchar const*, ... ) -LL_GST_SYM( true, g_source_remove, gboolean, guint ) -LL_GST_SYM( true, g_value_get_string, gchar const*, GValue const* ) - - -LL_GST_SYM( true, gst_debug_set_active, void, gboolean ) -LL_GST_SYM( true, gst_debug_add_log_function, void, GstLogFunction, gpointer, GDestroyNotify ) -LL_GST_SYM( true, gst_debug_set_default_threshold, void, GstDebugLevel ) -LL_GST_SYM( true, gst_debug_message_get , gchar const*, GstDebugMessage * ) \ No newline at end of file diff --git a/indra/media_plugins/gstreamer10/media_plugin_gstreamer10.cpp b/indra/media_plugins/gstreamer10/media_plugin_gstreamer10.cpp deleted file mode 100644 index 5c931ea8f0..0000000000 --- a/indra/media_plugins/gstreamer10/media_plugin_gstreamer10.cpp +++ /dev/null @@ -1,980 +0,0 @@ -/** - * @file media_plugin_gstreamer10.cpp - * @brief GStreamer-1.0 plugin for LLMedia API plugin system - * - * @cond - * $LicenseInfo:firstyear=2016&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2016, Linden Research, Inc. / Nicky Dasmijn - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - * @endcond - */ - -#define FLIP_Y - -#include "linden_common.h" - -#include "llgl.h" - -#include "llplugininstance.h" -#include "llpluginmessage.h" -#include "llpluginmessageclasses.h" -#include "media_plugin_base.h" - -#define G_DISABLE_CAST_CHECKS -extern "C" { -#include -#include - -} - -#include "llmediaimplgstreamer.h" -#include "llmediaimplgstreamer_syms.h" - -static inline void llgst_caps_unref( GstCaps * caps ) -{ - llgst_mini_object_unref( GST_MINI_OBJECT_CAST( caps ) ); -} - -static inline void llgst_sample_unref( GstSample *aSample ) -{ - llgst_mini_object_unref( GST_MINI_OBJECT_CAST( aSample ) ); -} - -////////////////////////////////////////////////////////////////////////////// -// -class MediaPluginGStreamer10 : public MediaPluginBase -{ -public: - MediaPluginGStreamer10(LLPluginInstance::sendMessageFunction host_send_func, void *host_user_data); - ~MediaPluginGStreamer10(); - - /* virtual */ void receiveMessage(const char *message_string); - - static bool startup(); - static bool closedown(); - - gboolean processGSTEvents(GstBus *bus, GstMessage *message); - -private: - std::string getVersion(); - bool navigateTo( const std::string urlIn ); - bool seek( double time_sec ); - bool setVolume( float volume ); - - // misc - bool pause(); - bool stop(); - bool play(double rate); - bool getTimePos(double &sec_out); - - double MIN_LOOP_SEC = 1.0F; - U32 INTERNAL_TEXTURE_SIZE = 1024; - - bool mIsLooping; - - enum ECommand { - COMMAND_NONE, - COMMAND_STOP, - COMMAND_PLAY, - COMMAND_FAST_FORWARD, - COMMAND_FAST_REWIND, - COMMAND_PAUSE, - COMMAND_SEEK, - }; - ECommand mCommand; - -private: - bool unload(); - bool load(); - - bool update(int milliseconds); - void mouseDown( int x, int y ); - void mouseUp( int x, int y ); - void mouseMove( int x, int y ); - - static bool mDoneInit; - - guint mBusWatchID; - - float mVolume; - - int mDepth; - - // padded texture size we need to write into - int mTextureWidth; - int mTextureHeight; - - bool mSeekWanted; - double mSeekDestination; - - // Very GStreamer-specific - GMainLoop *mPump; // event pump for this media - GstElement *mPlaybin; - GstAppSink *mAppSink; -}; - -//static -bool MediaPluginGStreamer10::mDoneInit = false; - -MediaPluginGStreamer10::MediaPluginGStreamer10( LLPluginInstance::sendMessageFunction host_send_func, - void *host_user_data ) - : MediaPluginBase(host_send_func, host_user_data) - , mBusWatchID ( 0 ) - , mSeekWanted(false) - , mSeekDestination(0.0) - , mPump ( NULL ) - , mPlaybin ( NULL ) - , mAppSink ( NULL ) - , mCommand ( COMMAND_NONE ) -{ -} - -gboolean MediaPluginGStreamer10::processGSTEvents(GstBus *bus, GstMessage *message) -{ - if (!message) - return TRUE; // shield against GStreamer bug - - switch (GST_MESSAGE_TYPE (message)) - { - case GST_MESSAGE_BUFFERING: - { - // NEEDS GST 0.10.11+ - if (llgst_message_parse_buffering) - { - gint percent = 0; - llgst_message_parse_buffering(message, &percent); - } - break; - } - case GST_MESSAGE_STATE_CHANGED: - { - GstState old_state; - GstState new_state; - GstState pending_state; - llgst_message_parse_state_changed(message, - &old_state, - &new_state, - &pending_state); - - switch (new_state) - { - case GST_STATE_VOID_PENDING: - break; - case GST_STATE_NULL: - break; - case GST_STATE_READY: - setStatus(STATUS_LOADED); - break; - case GST_STATE_PAUSED: - setStatus(STATUS_PAUSED); - break; - case GST_STATE_PLAYING: - setStatus(STATUS_PLAYING); - break; - } - break; - } - case GST_MESSAGE_ERROR: - { - GError *err = NULL; - gchar *debug = NULL; - - llgst_message_parse_error (message, &err, &debug); - if (err) - llg_error_free (err); - llg_free (debug); - - mCommand = COMMAND_STOP; - - setStatus(STATUS_ERROR); - - break; - } - case GST_MESSAGE_INFO: - { - if (llgst_message_parse_info) - { - GError *err = NULL; - gchar *debug = NULL; - - llgst_message_parse_info (message, &err, &debug); - if (err) - llg_error_free (err); - llg_free (debug); - } - break; - } - case GST_MESSAGE_WARNING: - { - GError *err = NULL; - gchar *debug = NULL; - - llgst_message_parse_warning (message, &err, &debug); - if (err) - llg_error_free (err); - llg_free (debug); - - break; - } - case GST_MESSAGE_EOS: - /* end-of-stream */ - if (mIsLooping) - { - double eos_pos_sec = 0.0F; - bool got_eos_position = getTimePos(eos_pos_sec); - - if (got_eos_position && eos_pos_sec < MIN_LOOP_SEC) - { - // if we know that the movie is really short, don't - // loop it else it can easily become a time-hog - // because of GStreamer spin-up overhead - // inject a COMMAND_PAUSE - mCommand = COMMAND_PAUSE; - } - else - { - stop(); - play(1.0); - } - } - else // not a looping media - { - // inject a COMMAND_STOP - mCommand = COMMAND_STOP; - } - break; - default: - /* unhandled message */ - break; - } - - /* we want to be notified again the next time there is a message - * on the bus, so return true (false means we want to stop watching - * for messages on the bus and our callback should not be called again) - */ - return TRUE; -} - -extern "C" { - gboolean llmediaimplgstreamer_bus_callback (GstBus *bus, - GstMessage *message, - gpointer data) - { - MediaPluginGStreamer10 *impl = (MediaPluginGStreamer10*)data; - return impl->processGSTEvents(bus, message); - } -} // extern "C" - - - -bool MediaPluginGStreamer10::navigateTo ( const std::string urlIn ) -{ - if (!mDoneInit) - return false; // error - - setStatus(STATUS_LOADING); - - mSeekWanted = false; - - if (NULL == mPump || NULL == mPlaybin) - { - setStatus(STATUS_ERROR); - return false; // error - } - - llg_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); - - // navigateTo implicitly plays, too. - play(1.0); - - return true; -} - - -class GstSampleUnref -{ - GstSample *mT; -public: - GstSampleUnref( GstSample *aT ) - : mT( aT ) - { llassert_always( mT ); } - - ~GstSampleUnref( ) - { llgst_sample_unref( mT ); } -}; - -bool MediaPluginGStreamer10::update(int milliseconds) -{ - if (!mDoneInit) - return false; // error - - // DEBUGMSG("updating media..."); - - // sanity check - if (NULL == mPump || NULL == mPlaybin) - { - return false; - } - - // see if there's an outstanding seek wanted - if (mSeekWanted && - // bleh, GST has to be happy that the movie is really truly playing - // or it may quietly ignore the seek (with rtsp:// at least). - (GST_STATE(mPlaybin) == GST_STATE_PLAYING)) - { - seek(mSeekDestination); - mSeekWanted = false; - } - - // *TODO: time-limit - but there isn't a lot we can do here, most - // time is spent in gstreamer's own opaque worker-threads. maybe - // we can do something sneaky like only unlock the video object - // for 'milliseconds' and otherwise hold the lock. - while (llg_main_context_pending(llg_main_loop_get_context(mPump))) - { - llg_main_context_iteration(llg_main_loop_get_context(mPump), FALSE); - } - - // check for availability of a new frame - - if( !mAppSink ) - return true; - - if( GST_STATE(mPlaybin) != GST_STATE_PLAYING) // Do not try to pull a sample if not in playing state - return true; - - GstSample *pSample = llgst_app_sink_pull_sample( mAppSink ); - if(!pSample) - return false; // Done playing - - GstSampleUnref oSampleUnref( pSample ); - GstCaps *pCaps = llgst_sample_get_caps ( pSample ); - if (!pCaps) - return false; - - gint width, height; - GstStructure *pStruct = llgst_caps_get_structure ( pCaps, 0); - - int res = llgst_structure_get_int ( pStruct, "width", &width); - res |= llgst_structure_get_int ( pStruct, "height", &height); - - if( !mPixels ) - return true; - - GstBuffer *pBuffer = llgst_sample_get_buffer ( pSample ); - GstMapInfo map; - llgst_buffer_map ( pBuffer, &map, GST_MAP_READ); - - // Our render buffer is always 1kx1k - - U32 rowSkip = INTERNAL_TEXTURE_SIZE / mTextureHeight; - U32 colSkip = INTERNAL_TEXTURE_SIZE / mTextureWidth; - - for (int row = 0; row < mTextureHeight; ++row) - { - U8 const *pTexelIn = map.data + (row*rowSkip * width *3); -#ifndef FLIP_Y - U8 *pTexelOut = mPixels + (row * mTextureWidth * mDepth ); -#else - U8 *pTexelOut = mPixels + ((mTextureHeight-row-1) * mTextureWidth * mDepth ); -#endif - for( int col = 0; col < mTextureWidth; ++col ) - { - pTexelOut[ 0 ] = pTexelIn[0]; - pTexelOut[ 1 ] = pTexelIn[1]; - pTexelOut[ 2 ] = pTexelIn[2]; - pTexelOut += mDepth; - pTexelIn += colSkip*3; - } - } - - llgst_buffer_unmap( pBuffer, &map ); - setDirty(0,0,mTextureWidth,mTextureHeight); - - return true; -} - -void MediaPluginGStreamer10::mouseDown( int x, int y ) -{ - // do nothing -} - -void MediaPluginGStreamer10::mouseUp( int x, int y ) -{ - // do nothing -} - -void MediaPluginGStreamer10::mouseMove( int x, int y ) -{ - // do nothing -} - - -bool MediaPluginGStreamer10::pause() -{ - // todo: error-check this? - if (mDoneInit && mPlaybin) - { - llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); - return true; - } - return false; -} - -bool MediaPluginGStreamer10::stop() -{ - // todo: error-check this? - if (mDoneInit && mPlaybin) - { - llgst_element_set_state(mPlaybin, GST_STATE_READY); - return true; - } - return false; -} - -bool MediaPluginGStreamer10::play(double rate) -{ - // NOTE: we don't actually support non-natural rate. - - // todo: error-check this? - if (mDoneInit && mPlaybin) - { - llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); - return true; - } - return false; -} - -bool MediaPluginGStreamer10::setVolume( float volume ) -{ - // we try to only update volume as conservatively as - // possible, as many gst-plugins-base versions up to at least - // November 2008 have critical race-conditions in setting volume - sigh - if (mVolume == volume) - return true; // nothing to do, everything's fine - - mVolume = volume; - if (mDoneInit && mPlaybin) - { - llg_object_set(mPlaybin, "volume", mVolume, NULL); - return true; - } - - return false; -} - -bool MediaPluginGStreamer10::seek(double time_sec) -{ - bool success = false; - if (mDoneInit && mPlaybin) - { - success = llgst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME, - GstSeekFlags(GST_SEEK_FLAG_FLUSH | - GST_SEEK_FLAG_KEY_UNIT), - GST_SEEK_TYPE_SET, gint64(time_sec*GST_SECOND), - GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); - } - return success; -} - -bool MediaPluginGStreamer10::getTimePos(double &sec_out) -{ - bool got_position = false; - if (mDoneInit && mPlaybin) - { - gint64 pos(0); - GstFormat timefmt = GST_FORMAT_TIME; - got_position = - llgst_element_query_position && - llgst_element_query_position(mPlaybin, - &timefmt, - &pos); - got_position = got_position - && (timefmt == GST_FORMAT_TIME); - // GStreamer may have other ideas, but we consider the current position - // undefined if not PLAYING or PAUSED - got_position = got_position && - (GST_STATE(mPlaybin) == GST_STATE_PLAYING || - GST_STATE(mPlaybin) == GST_STATE_PAUSED); - if (got_position && !GST_CLOCK_TIME_IS_VALID(pos)) - { - if (GST_STATE(mPlaybin) == GST_STATE_PLAYING) - { - // if we're playing then we treat an invalid clock time - // as 0, for complicated reasons (insert reason here) - pos = 0; - } - else - { - got_position = false; - } - - } - // If all the preconditions succeeded... we can trust the result. - if (got_position) - { - sec_out = double(pos) / double(GST_SECOND); // gst to sec - } - } - return got_position; -} - -bool MediaPluginGStreamer10::load() -{ - if (!mDoneInit) - return false; // error - - setStatus(STATUS_LOADING); - - mIsLooping = false; - mVolume = 0.1234567f; // minor hack to force an initial volume update - - // Create a pumpable main-loop for this media - mPump = llg_main_loop_new (NULL, FALSE); - if (!mPump) - { - setStatus(STATUS_ERROR); - return false; // error - } - - // instantiate a playbin element to do the hard work - mPlaybin = llgst_element_factory_make ("playbin", ""); - if (!mPlaybin) - { - setStatus(STATUS_ERROR); - return false; // error - } - - // get playbin's bus - GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); - if (!bus) - { - setStatus(STATUS_ERROR); - return false; // error - } - mBusWatchID = llgst_bus_add_watch (bus, - llmediaimplgstreamer_bus_callback, - this); - llgst_object_unref (bus); - - mAppSink = (GstAppSink*)(llgst_element_factory_make ("appsink", "")); - - GstCaps* pCaps = llgst_caps_new_simple( "video/x-raw", - "format", G_TYPE_STRING, "RGB", - "width", G_TYPE_INT, INTERNAL_TEXTURE_SIZE, - "height", G_TYPE_INT, INTERNAL_TEXTURE_SIZE, - NULL ); - - llgst_app_sink_set_caps( mAppSink, pCaps ); - llgst_caps_unref( pCaps ); - - if (!mAppSink) - { - setStatus(STATUS_ERROR); - return false; - } - - llg_object_set(mPlaybin, "video-sink", mAppSink, NULL); - - return true; -} - -bool MediaPluginGStreamer10::unload () -{ - if (!mDoneInit) - return false; // error - - // stop getting callbacks for this bus - llg_source_remove(mBusWatchID); - mBusWatchID = 0; - - if (mPlaybin) - { - llgst_element_set_state (mPlaybin, GST_STATE_NULL); - llgst_object_unref (GST_OBJECT (mPlaybin)); - mPlaybin = NULL; - } - - if (mPump) - { - llg_main_loop_quit(mPump); - mPump = NULL; - } - - mAppSink = NULL; - - setStatus(STATUS_NONE); - - return true; -} - -void LogFunction(GstDebugCategory *category, GstDebugLevel level, const gchar *file, const gchar *function, gint line, GObject *object, GstDebugMessage *message, gpointer user_data ) -#ifndef LL_LINUX // Docu says we need G_GNUC_NO_INSTRUMENT, but GCC says 'error' - G_GNUC_NO_INSTRUMENT -#endif -{ -#ifdef LL_LINUX - std::cerr << file << ":" << line << "(" << function << "): " << llgst_debug_message_get( message ) << std::endl; -#endif -} - -//static -bool MediaPluginGStreamer10::startup() -{ - // first - check if GStreamer is explicitly disabled - if (NULL != getenv("LL_DISABLE_GSTREAMER")) - return false; - - // only do global GStreamer initialization once. - if (!mDoneInit) - { - ll_init_apr(); - - // Get symbols! - std::vector< std::string > vctDSONames; -#if LL_DARWIN -#elif LL_WINDOWS - vctDSONames.push_back( "libgstreamer-1.0-0.dll" ); - vctDSONames.push_back( "libgstapp-1.0-0.dll" ); - vctDSONames.push_back( "libglib-2.0-0.dll" ); - vctDSONames.push_back( "libgobject-2.0-0.dll" ); -#else // linux or other ELFy unixoid - vctDSONames.push_back( "libgstreamer-1.0.so.0" ); - vctDSONames.push_back( "libgstapp-1.0.so.0" ); - vctDSONames.push_back( "libglib-2.0.so.0" ); - vctDSONames.push_back( "libgobject-2.0.so" ); -#endif - if( !grab_gst_syms( vctDSONames ) ) - { - return false; - } - - if (llgst_segtrap_set_enabled) - { - llgst_segtrap_set_enabled(FALSE); - } -#if LL_LINUX - // Gstreamer tries a fork during init, waitpid-ing on it, - // which conflicts with any installed SIGCHLD handler... - struct sigaction tmpact, oldact; - if (llgst_registry_fork_set_enabled ) { - // if we can disable SIGCHLD-using forking behaviour, - // do it. - llgst_registry_fork_set_enabled(false); - } - else { - // else temporarily install default SIGCHLD handler - // while GStreamer initialises - tmpact.sa_handler = SIG_DFL; - sigemptyset( &tmpact.sa_mask ); - tmpact.sa_flags = SA_SIGINFO; - sigaction(SIGCHLD, &tmpact, &oldact); - } -#endif // LL_LINUX - // Protect against GStreamer resetting the locale, yuck. - static std::string saved_locale; - saved_locale = setlocale(LC_ALL, NULL); - -// _putenv_s( "GST_PLUGIN_PATH", "E:\\gstreamer\\1.0\\x86\\lib\\gstreamer-1.0" ); - - llgst_debug_set_default_threshold( GST_LEVEL_WARNING ); - llgst_debug_add_log_function( LogFunction, NULL, NULL ); - llgst_debug_set_active( false ); - - // finally, try to initialize GStreamer! - GError *err = NULL; - gboolean init_gst_success = llgst_init_check(NULL, NULL, &err); - - // restore old locale - setlocale(LC_ALL, saved_locale.c_str() ); - -#if LL_LINUX - // restore old SIGCHLD handler - if (!llgst_registry_fork_set_enabled) - sigaction(SIGCHLD, &oldact, NULL); -#endif // LL_LINUX - - if (!init_gst_success) // fail - { - if (err) - { - llg_error_free(err); - } - return false; - } - - mDoneInit = true; - } - - return true; -} - -//static -bool MediaPluginGStreamer10::closedown() -{ - if (!mDoneInit) - return false; // error - - ungrab_gst_syms(); - - mDoneInit = false; - - return true; -} - -MediaPluginGStreamer10::~MediaPluginGStreamer10() -{ - closedown(); -} - - -std::string MediaPluginGStreamer10::getVersion() -{ - std::string plugin_version = "GStreamer10 media plugin, GStreamer version "; - if (mDoneInit && - llgst_version) - { - guint major, minor, micro, nano; - llgst_version(&major, &minor, µ, &nano); - plugin_version += llformat("%u.%u.%u.%u (runtime), %u.%u.%u.%u (headers)", (unsigned int)major, (unsigned int)minor, - (unsigned int)micro, (unsigned int)nano, (unsigned int)GST_VERSION_MAJOR, (unsigned int)GST_VERSION_MINOR, - (unsigned int)GST_VERSION_MICRO, (unsigned int)GST_VERSION_NANO); - } - else - { - plugin_version += "(unknown)"; - } - return plugin_version; -} - -void MediaPluginGStreamer10::receiveMessage(const char *message_string) -{ - LLPluginMessage message_in; - - if(message_in.parse(message_string) >= 0) - { - std::string message_class = message_in.getClass(); - std::string message_name = message_in.getName(); - - if(message_class == LLPLUGIN_MESSAGE_CLASS_BASE) - { - if(message_name == "init") - { - LLPluginMessage message("base", "init_response"); - LLSD versions = LLSD::emptyMap(); - versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION; - versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION; - versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME] = LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME_VERSION; - message.setValueLLSD("versions", versions); - - load(); - - message.setValue("plugin_version", getVersion()); - sendMessage(message); - } - else if(message_name == "idle") - { - // no response is necessary here. - double time = message_in.getValueReal("time"); - - // Convert time to milliseconds for update() - update((int)(time * 1000.0f)); - } - else if(message_name == "cleanup") - { - unload(); - closedown(); - } - else if(message_name == "shm_added") - { - SharedSegmentInfo info; - info.mAddress = message_in.getValuePointer("address"); - info.mSize = (size_t)message_in.getValueS32("size"); - std::string name = message_in.getValue("name"); - - mSharedSegments.insert(SharedSegmentMap::value_type(name, info)); - } - else if(message_name == "shm_remove") - { - std::string name = message_in.getValue("name"); - - SharedSegmentMap::iterator iter = mSharedSegments.find(name); - if(iter != mSharedSegments.end()) - { - if(mPixels == iter->second.mAddress) - { - // This is the currently active pixel buffer. Make sure we stop drawing to it. - mPixels = NULL; - mTextureSegmentName.clear(); - } - mSharedSegments.erase(iter); - } - - // Send the response so it can be cleaned up. - LLPluginMessage message("base", "shm_remove_response"); - message.setValue("name", name); - sendMessage(message); - } - } - else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA) - { - if(message_name == "init") - { - // Plugin gets to decide the texture parameters to use. - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params"); - // lame to have to decide this now, it depends on the movie. Oh well. - mDepth = 4; - - mTextureWidth = 1; - mTextureHeight = 1; - - message.setValueU32("format", GL_RGBA); - message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV); - - message.setValueS32("depth", mDepth); - message.setValueS32("default_width", INTERNAL_TEXTURE_SIZE ); - message.setValueS32("default_height", INTERNAL_TEXTURE_SIZE ); - message.setValueU32("internalformat", GL_RGBA8); - message.setValueBoolean("coords_opengl", true); // true == use OpenGL-style coordinates, false == (0,0) is upper left. - message.setValueBoolean("allow_downsample", true); // we respond with grace and performance if asked to downscale - sendMessage(message); - } - else if(message_name == "size_change") - { - std::string name = message_in.getValue("name"); - S32 width = message_in.getValueS32("width"); - S32 height = message_in.getValueS32("height"); - S32 texture_width = message_in.getValueS32("texture_width"); - S32 texture_height = message_in.getValueS32("texture_height"); - - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response"); - message.setValue("name", name); - message.setValueS32("width", width); - message.setValueS32("height", height); - message.setValueS32("texture_width", texture_width); - message.setValueS32("texture_height", texture_height); - sendMessage(message); - - if(!name.empty()) - { - // Find the shared memory region with this name - SharedSegmentMap::iterator iter = mSharedSegments.find(name); - if(iter != mSharedSegments.end()) - { - mPixels = (unsigned char*)iter->second.mAddress; - mTextureSegmentName = name; - - mTextureWidth = texture_width; - mTextureHeight = texture_height; - memset( mPixels, 0, mTextureWidth*mTextureHeight*mDepth ); - } - - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_request"); - message.setValue("name", mTextureSegmentName); - message.setValueS32("width", INTERNAL_TEXTURE_SIZE ); - message.setValueS32("height", INTERNAL_TEXTURE_SIZE ); - sendMessage(message); - - } - } - else if(message_name == "load_uri") - { - std::string uri = message_in.getValue("uri"); - navigateTo( uri ); - sendStatus(); - } - else if(message_name == "mouse_event") - { - std::string event = message_in.getValue("event"); - S32 x = message_in.getValueS32("x"); - S32 y = message_in.getValueS32("y"); - - if(event == "down") - { - mouseDown(x, y); - } - else if(event == "up") - { - mouseUp(x, y); - } - else if(event == "move") - { - mouseMove(x, y); - }; - }; - } - else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME) - { - if(message_name == "stop") - { - stop(); - } - else if(message_name == "start") - { - double rate = 0.0; - if(message_in.hasValue("rate")) - { - rate = message_in.getValueReal("rate"); - } - // NOTE: we don't actually support rate. - play(rate); - } - else if(message_name == "pause") - { - pause(); - } - else if(message_name == "seek") - { - double time = message_in.getValueReal("time"); - // defer the actual seek in case we haven't - // really truly started yet in which case there - // is nothing to seek upon - mSeekWanted = true; - mSeekDestination = time; - } - else if(message_name == "set_loop") - { - bool loop = message_in.getValueBoolean("loop"); - mIsLooping = loop; - } - else if(message_name == "set_volume") - { - double volume = message_in.getValueReal("volume"); - setVolume(volume); - } - } - } -} - -int init_media_plugin(LLPluginInstance::sendMessageFunction host_send_func, void *host_user_data, LLPluginInstance::sendMessageFunction *plugin_send_func, void **plugin_user_data) -{ - if( MediaPluginGStreamer10::startup() ) - { - MediaPluginGStreamer10 *self = new MediaPluginGStreamer10(host_send_func, host_user_data); - *plugin_send_func = MediaPluginGStreamer10::staticReceiveMessage; - *plugin_user_data = (void*)self; - - return 0; // okay - } - else - { - return -1; // failed to init - } -} diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index de4fea39bd..49bbd8520d 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2089,13 +2089,9 @@ set(viewer_APPSETTINGS_FILES app_settings/viewerart.xml ${CMAKE_SOURCE_DIR}/../etc/message.xml ${CMAKE_SOURCE_DIR}/../scripts/messages/message_template.msg - #packages-info.txt + packages-info.txt ) -if( NOT USESYSTEMLIBS ) - set( viewer_APPSETTINGS_FILES ${viewer_APPSETTINGS_FILE} packages-info.txt ) -endif() - if (WINDOWS) LIST(APPEND viewer_APPSETTINGS_FILES app_settings/growl_notifications.xml) endif (WINDOWS) @@ -2180,11 +2176,11 @@ add_executable(${VIEWER_BINARY_NAME} ${viewer_SOURCE_FILES} ) -if (SDL_FOUND OR SDL2_FOUND) +if (SDL_FOUND) set_property(TARGET ${VIEWER_BINARY_NAME} PROPERTY COMPILE_DEFINITIONS LL_SDL=1 ) -endif () +endif (SDL_FOUND) if (BUGSPLAT_DB) set_property(TARGET ${VIEWER_BINARY_NAME} @@ -2491,7 +2487,7 @@ target_link_libraries(${VIEWER_BINARY_NAME} ${BOOST_WAVE_LIBRARY} #FS specific ${BOOST_THREAD_LIBRARY} #FS specific ${BOOST_CONTEXT_LIBRARY} - ${GLIB_LIBRARIES} + ${DBUSGLIB_LIBRARIES} ${OPENGL_LIBRARIES} ${FMODWRAPPER_LIBRARY} # must come after LLAudio ${OPENAL_LIBRARIES} @@ -2542,10 +2538,10 @@ if (NOT ENABLE_MEDIA_PLUGINS) set(COPY_INPUT_DEPENDENCIES ${VIEWER_BINARY_NAME} linux-crash-logger - #SLPlugin - #media_plugin_cef - #media_plugin_gstreamer10 - #media_plugin_libvlc + SLPlugin + media_plugin_cef + #media_plugin_gstreamer010 + media_plugin_libvlc llcommon ) else (NOT ENABLE_MEDIA_PLUGINS) @@ -2554,8 +2550,7 @@ else (NOT ENABLE_MEDIA_PLUGINS) linux-crash-logger SLPlugin media_plugin_cef - media_plugin_gstreamer10 - #media_plugin_libvlc + #media_plugin_gstreamer010 llcommon ) endif (NOT ENABLE_MEDIA_PLUGINS) diff --git a/indra/newview/desktopnotifierlinux.cpp b/indra/newview/desktopnotifierlinux.cpp index be5cd722c7..f3b2508409 100644 --- a/indra/newview/desktopnotifierlinux.cpp +++ b/indra/newview/desktopnotifierlinux.cpp @@ -38,25 +38,8 @@ #include -#ifdef LL_GLIB - #include -#else - -// ND: If we cannot use glib headers just stub out what'ns needed to compile. -// In theory that is enough to have a (leaky, see g_free) implementation. But to play it safe tryLoadLibnotify won't try to load any DSO, thus effectivly -// disabling the usage of libnotify. -typedef int gint; -typedef gint gboolean; -typedef char gchar; -struct GError; - -void g_free( void* ) -{ -} - -#endif typedef enum { @@ -82,6 +65,7 @@ typedef void (*pND_notify_notification_set_urgency) ( NotifyNotification *notifi // the unused one is always pushed first and qualifies just as dead weight. typedef NotifyNotification* (*pND_notify_notification_new) (const char *summary, const char *body, const char *icon, void*); + void* tryLoadLibnotify() { char const* aNames[] = { @@ -97,7 +81,6 @@ void* tryLoadLibnotify() void *pLibHandle(0); -#ifdef LL_GLIB for( int i = 0; !pLibHandle && aNames[i]; ++i ) { pLibHandle = dlopen( aNames[i], RTLD_NOW ); @@ -106,8 +89,7 @@ void* tryLoadLibnotify() else LL_INFOS( "DesktopNotifierLinux" ) << "Loaded " << aNames[i] << LL_ENDL; } -#endif - + return pLibHandle; }; @@ -316,12 +298,10 @@ void DesktopNotifierLinux::showNotification( const std::string& notification_tit { LL_INFOS( "DesktopNotifierLinux" ) << "Linux desktop notification type " << notification_type << " sent." << LL_ENDL; } -#if LL_GLIB else { LL_WARNS( "DesktopNotifierLinux" ) << "Linux desktop notification type " << notification_type << " FAILED to send, error was " << error->message << LL_ENDL; } -#endif } bool DesktopNotifierLinux::isUsable() diff --git a/indra/newview/exoflickr.cpp b/indra/newview/exoflickr.cpp index 39a1d8477a..287a4e6a4a 100644 --- a/indra/newview/exoflickr.cpp +++ b/indra/newview/exoflickr.cpp @@ -31,7 +31,12 @@ #include "llsdutil.h" #include "llflickrconnect.h" +// third-party +#if LL_USESYSTEMLIBS +#include "jsoncpp/reader.h" // JSON +#else #include "json/reader.h" // JSON +#endif #include #include diff --git a/indra/newview/linux_tools/wrapper.sh b/indra/newview/linux_tools/wrapper.sh index 479584c009..57da1b18ae 100755 --- a/indra/newview/linux_tools/wrapper.sh +++ b/indra/newview/linux_tools/wrapper.sh @@ -158,17 +158,6 @@ for ARG in "$@"; do fi done -# Hack, otherwise eg sscanf inside flatpak fails. -# This happens if the locale is set (for example) to de_DE which uses , as a decimal separator. -# There is code in the viewer which should handle this but when run from "flatpak run" it will not work. -# Needs some more investigation; but at least this hack will allow the viewer to run. -if [ ! -z "${FLATPAK_ID}" ] -then - echo "Setting LC_NUMERIC to en_US.utf8 due to running inside flatpak" - export LC_NUMERIC=en_US.utf8 -fi -# - # Run the program. # Don't quote $LL_WRAPPER because, if empty, it should simply vanish from the # command line. But DO quote "${ARGS[@]}": preserve separate args as diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 41d077bd11..67ebdb43e2 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -143,21 +143,10 @@ #include "stringize.h" #include "llcoros.h" #include "llexception.h" - -#if !LL_LINUX - #include "cef/dullahan.h" - #include "cef/dullahan_version.h" - #include "vlc/libvlc_version.h" -#else - #if LL_USESYSTEMLIBS - #include "dullahan.h" - #include "dullahan_version.h" - #else - #include "cef/dullahan.h" - #include "cef/dullahan_version.h" - #endif - -#endif +//#if !LL_LINUX +#include "cef/dullahan_version.h" +#include "vlc/libvlc_version.h" +//#endif // LL_LINUX // Third party library includes #include @@ -3910,7 +3899,7 @@ LLSD LLAppViewer::getViewerInfo() const // info["LIBCEF_VERSION"] = "Undefined"; //#endif -#if !LL_LINUX +//#if !LL_LINUX std::ostringstream vlc_ver_codec; vlc_ver_codec << LIBVLC_VERSION_MAJOR; vlc_ver_codec << "."; @@ -3918,9 +3907,9 @@ LLSD LLAppViewer::getViewerInfo() const vlc_ver_codec << "."; vlc_ver_codec << LIBVLC_VERSION_REVISION; info["LIBVLC_VERSION"] = vlc_ver_codec.str(); -#else - info["LIBVLC_VERSION"] = "Using gstreamer 10"; -#endif +//#else +// info["LIBVLC_VERSION"] = "Undefined"; +//#endif S32 packets_in = LLViewerStats::instance().getRecording().getSum(LLStatViewer::PACKETS_IN); if (packets_in > 0) diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp index 7b5adf53e1..cba36b8356 100644 --- a/indra/newview/llappviewerlinux.cpp +++ b/indra/newview/llappviewerlinux.cpp @@ -2,7 +2,7 @@ * @file llappviewerlinux.cpp * @brief The LLAppViewerLinux class definitions * -1 * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * @@ -194,6 +194,15 @@ LLAppViewerLinux::~LLAppViewerLinux() bool LLAppViewerLinux::init() { + // g_thread_init() must be called before *any* use of glib, *and* + // before any mutexes are held, *and* some of our third-party + // libraries likes to use glib functions; in short, do this here + // really early in app startup! + +#if ( !defined(GLIB_MAJOR_VERSION) && !defined(GLIB_MINOR_VERSION) ) || ( GLIB_MAJOR_VERSION < 2 ) || ( GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 32 ) + if (!g_thread_supported ()) g_thread_init (NULL); +#endif + bool success = LLAppViewer::init(); #if LL_SEND_CRASH_REPORTS @@ -341,6 +350,10 @@ bool LLAppViewerLinux::initSLURLHandler() return false; // failed } +#if ( !defined(GLIB_MAJOR_VERSION) && !defined(GLIB_MINOR_VERSION) ) || ( GLIB_MAJOR_VERSION < 2 ) || ( GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 35 ) + g_type_init(); +#endif + //ViewerAppAPI *api_server = (ViewerAppAPI*) g_object_new(viewerappapi_get_type(), NULL); @@ -359,6 +372,10 @@ bool LLAppViewerLinux::sendURLToOtherInstance(const std::string& url) DBusGConnection *bus; GError *error = NULL; +#if ( !defined(GLIB_MAJOR_VERSION) && !defined(GLIB_MINOR_VERSION) ) || ( GLIB_MAJOR_VERSION < 2 ) || ( GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 35 ) + g_type_init(); +#endif + bus = lldbus_g_bus_get (DBUS_BUS_SESSION, &error); if (bus) { diff --git a/indra/newview/llappviewerlinux.h b/indra/newview/llappviewerlinux.h index 1196bc58c1..ed71ff36fd 100644 --- a/indra/newview/llappviewerlinux.h +++ b/indra/newview/llappviewerlinux.h @@ -27,17 +27,15 @@ #ifndef LL_LLAPPVIEWERLINUX_H #define LL_LLAPPVIEWERLINUX_H -#ifdef LL_GLIB extern "C" { # include - -#if LL_DBUS_ENABLED -# include -# include -#endif - } +#if LL_DBUS_ENABLED +extern "C" { +# include +# include +} #endif #ifndef LL_LLAPPVIEWER_H @@ -72,7 +70,7 @@ protected: virtual bool sendURLToOtherInstance(const std::string& url); }; -#if LL_DBUS_ENABLED && LL_GLIB +#if LL_DBUS_ENABLED typedef struct { GObject parent; diff --git a/indra/newview/lldirpicker.cpp b/indra/newview/lldirpicker.cpp index 3c72a3db28..b8e6e81ee6 100644 --- a/indra/newview/lldirpicker.cpp +++ b/indra/newview/lldirpicker.cpp @@ -41,11 +41,6 @@ # include "llfilepicker.h" #endif -#ifdef LL_FLTK - #include "FL/Fl.H" - #include "FL/Fl_Native_File_Chooser.H" -#endif - // // Globals // @@ -198,41 +193,32 @@ LLDirPicker::LLDirPicker() : mFileName(NULL), mLocked(false) { -#ifndef LL_FLTK mFilePicker = new LLFilePicker(); -#endif - reset(); } LLDirPicker::~LLDirPicker() { -#ifndef LL_FLTK delete mFilePicker; -#endif } void LLDirPicker::reset() { -#ifndef LL_FLTK if (mFilePicker) - mFilePicker->reset(); -#else - mDir = ""; -#endif + mFilePicker->reset(); } BOOL LLDirPicker::getDir(std::string* filename, bool blocking) { reset(); + // if local file browsing is turned off, return without opening dialog if ( check_local_file_access_enabled() == false ) { return FALSE; } -#ifndef LL_FLTK #if !LL_MESA_HEADLESS if (mFilePicker) @@ -251,38 +237,15 @@ BOOL LLDirPicker::getDir(std::string* filename, bool blocking) #endif // !LL_MESA_HEADLESS return FALSE; -#else - Fl_Native_File_Chooser flDlg; - flDlg.title("Pick a dir"); - flDlg.type(Fl_Native_File_Chooser::BROWSE_DIRECTORY ); - - int res = flDlg.show(); - if( res == 0 ) - { - char const *pDir = flDlg.filename(0); - if( pDir ) - mDir = pDir; - } - else if( res == -1 ) - { - LL_WARNS() << "FLTK failed: " << flDlg.errmsg() << LL_ENDL; - } - - return !mDir.empty(); -#endif } std::string LLDirPicker::getDirName() { -#ifndef LL_FLTK if (mFilePicker) { return mFilePicker->getFirstFile(); } return ""; -#else - return mDir; -#endif } #else // not implemented diff --git a/indra/newview/lldirpicker.h b/indra/newview/lldirpicker.h index 861913c51c..c7dba12130 100644 --- a/indra/newview/lldirpicker.h +++ b/indra/newview/lldirpicker.h @@ -80,7 +80,7 @@ private: #if LL_LINUX || LL_SOLARIS || LL_DARWIN // On Linux we just implement LLDirPicker on top of LLFilePicker - // LLFilePicker *mFilePicker; + LLFilePicker *mFilePicker; #endif diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index ec048ea752..db95618bd0 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -36,18 +36,10 @@ #include "llviewercontrol.h" #include "llwindow.h" // beforeDialog() -#undef LL_GTK #if LL_SDL -// #include "llwindowsdl.h" // for some X/GTK utils to help with filepickers -// #include +#include "llwindowsdl.h" // for some X/GTK utils to help with filepickers #endif // LL_SDL -#ifdef LL_FLTK - #include "FL/Fl.H" - #include "FL/Fl_Native_File_Chooser.H" -#endif - - #if LL_LINUX || LL_SOLARIS #include "llhttpconstants.h" // file picker uses some of thes constants on Linux #endif @@ -1143,14 +1135,17 @@ GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, std::stri GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : GTK_FILE_CHOOSER_ACTION_OPEN); - gchar const *acceptText = is_folder ? "_Apply" :(is_save ? "_Save" : "_Open"); win = gtk_file_chooser_dialog_new(NULL, NULL, - pickertype, - "_Cancel", - GTK_RESPONSE_CANCEL, - acceptText, - GTK_RESPONSE_ACCEPT, - (gchar *)NULL); + pickertype, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + is_folder ? + GTK_STOCK_APPLY : + (is_save ? + GTK_STOCK_SAVE : + GTK_STOCK_OPEN), + GTK_RESPONSE_ACCEPT, + (gchar *)NULL); mCurContextName = context; // get the default path for this usage context if it's been @@ -1191,8 +1186,9 @@ GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, std::stri if (None != XWindowID) { gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin - GdkWindow *gdkwin = gdk_x11_window_foreign_new_for_display (gdk_display_get_default(),XWindowID); - gdk_window_set_transient_for(gtk_widget_get_window(GTK_WIDGET(win)), gdkwin); + GdkWindow *gdkwin = gdk_window_foreign_new(XWindowID); + gdk_window_set_transient_for(GTK_WIDGET(win)->window, + gdkwin); } else { @@ -1570,79 +1566,12 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter, bool blocking) return rtn; } -#elif LL_FLTK -BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename, bool blocking ) -{ - return openFileDialog( filter, blocking, eSaveFile ); -} - -BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking ) -{ - return openFileDialog( filter, blocking, eOpenFile ); -} - -BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter, bool blocking) -{ - return openFileDialog( filter, blocking, eOpenMultiple ); -} - -void setupFilter( Fl_Native_File_Chooser &chooser, LLFilePicker::ESaveFilter filter ) -{ -} - -void setupFilter( Fl_Native_File_Chooser &chooser, LLFilePicker::ELoadFilter filter ) -{ -} - -bool LLFilePicker::openFileDialog( int32_t filter, bool blocking, EType aType ) -{ - if ( check_local_file_access_enabled() == false ) - return false; - - reset(); - Fl_Native_File_Chooser::Type flType = Fl_Native_File_Chooser::BROWSE_FILE; - - if( aType == eOpenMultiple ) - flType = Fl_Native_File_Chooser::BROWSE_MULTI_FILE; - else if( aType == eSaveFile ) - flType = Fl_Native_File_Chooser::BROWSE_SAVE_FILE; - - Fl_Native_File_Chooser flDlg; - flDlg.title("Pick a file"); - flDlg.type( flType ); - - if( aType == eSaveFile ) - setupFilter( flDlg, (ESaveFilter) filter ); - else - setupFilter( flDlg, (ELoadFilter) filter ); - - int res = flDlg.show(); - if( res == 0 ) - { - int32_t count = flDlg.count(); - if( count < 0 ) - count = 0; - for( int32_t i = 0; i < count; ++i ) - { - char const *pFile = flDlg.filename(i); - if( pFile && strlen(pFile) > 0 ) - mFiles.push_back( pFile ); - } - } - else if( res == -1 ) - { - LL_WARNS() << "FLTK failed: " << flDlg.errmsg() << LL_ENDL; - } - - return mFiles.empty()?FALSE:TRUE; -} - # else // LL_GTK // Hacky stubs designed to facilitate fake getSaveFile and getOpenFile with // static results, when we don't have a real filepicker. -BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename, bool blocking ) +BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename ) { // if local file browsing is turned off, return without opening dialog // (Even though this is a stub, I think we still should not return anything at all) @@ -1705,7 +1634,7 @@ BOOL LLFilePicker::getMultipleOpenFiles( ELoadFilter filter, bool blocking) #else // not implemented -BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename, bool blockin ) +BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename ) { reset(); return FALSE; diff --git a/indra/newview/llfilepicker.h b/indra/newview/llfilepicker.h index ba3383d995..53ea7fd316 100644 --- a/indra/newview/llfilepicker.h +++ b/indra/newview/llfilepicker.h @@ -33,12 +33,6 @@ #ifndef LL_LLFILEPICKER_H #define LL_LLFILEPICKER_H -#if LL_FLTK - #if LL_GTK - #undef LL_GTK - #endif -#endif - #include "stdtypes.h" #if LL_DARWIN @@ -69,7 +63,7 @@ extern "C" { class LLFilePicker { -#if LL_GTK +#ifdef LL_GTK friend class LLDirPicker; friend void chooser_responder(GtkWidget *, gint, gpointer); #endif // LL_GTK @@ -193,14 +187,7 @@ private: // we also remember the extension of the last added file. std::string mCurrentExtension; #endif -#if LL_FLTK - enum EType - { - eSaveFile, eOpenFile, eOpenMultiple - }; - bool openFileDialog( int32_t filter, bool blocking, EType aType ); -#endif - + std::vector mFiles; S32 mCurrentFile; bool mLocked; diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 3059b6fcc4..e626143224 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -79,15 +79,6 @@ #pragma warning (disable:4702) #endif -// ND: Disable some warnings on newer GCC versions. -#if LL_LINUX -#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ ) >= 40800 - #pragma GCC diagnostic ignored "-Wuninitialized" - #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" - #endif -#endif -// - #include #if LL_MSVC diff --git a/indra/newview/skins/default/xui/en/mime_types_linux.xml b/indra/newview/skins/default/xui/en/mime_types_linux.xml index 22a0024874..a130d2b0e9 100644 --- a/indra/newview/skins/default/xui/en/mime_types_linux.xml +++ b/indra/newview/skins/default/xui/en/mime_types_linux.xml @@ -130,7 +130,7 @@ movie - media_plugin_gstreamer + media_plugin_libvlc @@ -163,7 +163,7 @@ audio - media_plugin_gstreamer + media_plugin_libvlc @@ -174,7 +174,7 @@ movie - media_plugin_gstreamer + media_plugin_libvlc @@ -196,7 +196,7 @@ movie - media_plugin_gstreamer + media_plugin_libvlc @@ -218,7 +218,7 @@ audio - media_plugin_gstreamer + media_plugin_libvlc @@ -295,7 +295,7 @@ audio - media_plugin_gstreamer + media_plugin_libvlc @@ -306,7 +306,7 @@ audio - media_plugin_gstreamer + media_plugin_libvlc @@ -317,7 +317,7 @@ audio - media_plugin_gstreamer + media_plugin_libvlc @@ -328,7 +328,7 @@ audio - media_plugin_gstreamer + media_plugin_libvlc @@ -438,7 +438,7 @@ movie - media_plugin_gstreamer + media_plugin_libvlc @@ -449,7 +449,7 @@ movie - media_plugin_gstreamer + media_plugin_libvlc @@ -460,7 +460,7 @@ movie - media_plugin_gstreamer + media_plugin_libvlc @@ -471,7 +471,7 @@ movie - media_plugin_gstreamer + media_plugin_libvlc @@ -482,7 +482,7 @@ movie - media_plugin_gstreamer + media_plugin_libvlc @@ -493,7 +493,7 @@ movie - media_plugin_gstreamer + media_plugin_libvlc diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 975fc05657..e9fd0e3d35 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -1861,56 +1861,35 @@ class LinuxManifest(ViewerManifest): # plugins with self.prefix(src=os.path.join(self.args['build'], os.pardir, 'media_plugins'), dst="bin/llplugin"): #self.path("gstreamer010/libmedia_plugin_gstreamer010.so", "libmedia_plugin_gstreamer.so") - #self.path2basename("libvlc", "libmedia_plugin_libvlc.so") + self.path2basename("libvlc", "libmedia_plugin_libvlc.so") self.path("cef/libmedia_plugin_cef.so", "libmedia_plugin_cef.so" ) - #with self.prefix(src=os.path.join(pkgdir, 'lib', 'vlc', 'plugins'), dst="bin/llplugin/vlc/plugins"): - # self.path( "plugins.dat" ) - # self.path( "*/*.so" ) + with self.prefix(src=os.path.join(pkgdir, 'lib', 'vlc', 'plugins'), dst="bin/llplugin/vlc/plugins"): + self.path( "plugins.dat" ) + self.path( "*/*.so" ) - #with self.prefix(src=os.path.join(pkgdir, 'lib' ), dst="lib"): - # self.path( "libvlc*.so*" ) + with self.prefix(src=os.path.join(pkgdir, 'lib' ), dst="lib"): + self.path( "libvlc*.so*" ) - #with self.prefix(src=os.path.join(pkgdir, 'lib', 'vlc', 'plugins'), dst="bin/llplugin/vlc/plugins"): - # self.path( "plugins.dat" ) - # self.path( "*/*.so" ) + with self.prefix(src=os.path.join(pkgdir, 'lib', 'vlc', 'plugins'), dst="bin/llplugin/vlc/plugins"): + self.path( "plugins.dat" ) + self.path( "*/*.so" ) - #with self.prefix(src=os.path.join(pkgdir, 'lib' ), dst="lib"): - # self.path( "libvlc*.so*" ) + with self.prefix(src=os.path.join(pkgdir, 'lib' ), dst="lib"): + self.path( "libvlc*.so*" ) - snapStage = os.environ.get( "SNAPCRAFT_STAGE" ) - if snapStage != None: - print( "Building snap package" ) - else: - snapStage = os.environ.get( "FLATPAK_DEST" ) - if snapStage != None: - print( "Building flatpak package" ) - - if snapStage == None: - data = open( "/proc/1/cgroup", "r" ).readlines()[0] - if "docker" in data: - snapStage = "/usr" - - pkgBase = os.path.join( pkgdir, 'lib', 'release') - if snapStage != None: - pkgBase = os.path.join( snapStage, "lib" ) - # CEF files - with self.prefix(src=pkgBase, dst="lib"): + with self.prefix(src=os.path.join(pkgdir, 'lib', 'release'), dst="lib"): self.path( "libcef.so" ) self.fs_try_path( "libminigbm.so" ) - pkgBase = os.path.join( pkgBase, "swiftshader" ) - with self.prefix(src=pkgBase, dst=os.path.join("bin", "swiftshader") ): + with self.prefix(src=os.path.join(pkgdir, 'lib', 'release', 'swiftshader'), dst=os.path.join("bin", "swiftshader") ): self.path( "*.so" ) with self.prefix(src=os.path.join(pkgdir, 'lib', 'release', 'swiftshader'), dst=os.path.join("lib", "swiftshader") ): self.path( "*.so" ) - pkgBase = os.path.join(pkgdir, 'bin', 'release') - if snapStage != None: - pkgBase = os.path.join( snapStage, "lib" ) - with self.prefix(pkgBase, dst="bin"): + with self.prefix(src=os.path.join(pkgdir, 'bin', 'release'), dst="bin"): self.path( "chrome-sandbox" ) self.path( "dullahan_host" ) self.fs_try_path( "natives_blob.bin" ) @@ -1921,11 +1900,7 @@ class LinuxManifest(ViewerManifest): self.path( "snapshot_blob.bin" ) self.path( "v8_context_snapshot.bin" ) - pkgBase = os.path.join(pkgdir, 'resources') - if snapStage != None: - pkgBase = os.path.join( snapStage, "resources" ) - - with self.prefix(src=pkgBase, dst="bin"): + with self.prefix(src=os.path.join(pkgdir, 'resources'), dst="bin"): self.path( "cef.pak" ) self.path( "cef_extensions.pak" ) self.path( "cef_100_percent.pak" ) @@ -1940,9 +1915,7 @@ class LinuxManifest(ViewerManifest): self.path( "devtools_resources.pak" ) self.path( "icudtl.dat" ) - pkgBase = os.path.join( pkgBase, "locales" ) - - with self.prefix(src=pkgBase, dst=os.path.join('bin', 'locales')): + with self.prefix(src=os.path.join(pkgdir, 'resources', 'locales'), dst=os.path.join('bin', 'locales')): self.path("am.pak") self.path("ar.pak") self.path("bg.pak") @@ -2028,10 +2001,10 @@ class LinuxManifest(ViewerManifest): #self.path("libGLOD.so") #self.fs_path("libminizip.so") self.path("libuuid.so*") - self.path("libSDL*") - #self.path("libdirectfb*.so*") - #self.path("libfusion*.so*") - #self.path("libdirect*.so*") + self.path("libSDL-1.2.so*") + self.path("libdirectfb*.so*") + self.path("libfusion*.so*") + self.path("libdirect*.so*") self.fs_try_path("libopenjpeg.so*") self.path("libhunspell-1.3.so*") self.path("libalut.so*") @@ -2041,7 +2014,7 @@ class LinuxManifest(ViewerManifest): self.path("libopenal.so", "libopenal.so.1") # Install as versioned file in case it's missing from the 3p- and won't get copied below self.path("libopenal.so*") #self.path("libnotify.so.1.1.2", "libnotify.so.1") # LO - uncomment when testing libnotify(growl) on linux - self.fs_try_path("libpangox-1.0.so*") + self.path("libpangox-1.0.so*") # KLUDGE: As of 2012-04-11, the 'fontconfig' package installs # libfontconfig.so.1.4.4, along with symlinks libfontconfig.so.1 # and libfontconfig.so. Before we added support for library-file @@ -2084,15 +2057,9 @@ class LinuxManifest(ViewerManifest): installer_name = "_".join(installer_name_components) #installer_name = self.installer_base_name() - createTar = True - if os.environ.get( "FS_CREATE_NO_TAR" ): - createTar = False - - - if createTar: - self.fs_delete_linux_symbols() # Delete old syms - self.strip_binaries() - self.fs_save_linux_symbols() # Package symbols, add debug link + self.fs_delete_linux_symbols() # Delete old syms + self.strip_binaries() + self.fs_save_linux_symbols() # Package symbols, add debug link # Fix access permissions self.run_command(['find', self.get_dst_prefix(), @@ -2101,39 +2068,30 @@ class LinuxManifest(ViewerManifest): self.run_command(['find', self.get_dst_prefix(), '-type', 'f', '-perm', old, '-exec', 'chmod', new, '{}', ';']) - - if os.environ.get( "SNAPCRAFT_STAGE" ) or os.environ.get( "FLATPAK_DEST" ): - print( "Building snap package, not calling tar to bundle" ) - self.package_file = "" - return - self.package_file = installer_name + '.tar.xz' - if createTar: - # temporarily move directory tree so that it has the right - # name in the tarfile - realname = self.get_dst_prefix() - tempname = self.build_path_of(installer_name) - self.run_command(["mv", realname, tempname]) - try: - # only create tarball if it's a release build. - if self.args['buildtype'].lower() == 'release': - # --numeric-owner hides the username of the builder for - # security etc. - self.run_command(['tar', '-C', self.get_build_prefix(), - '--numeric-owner', self.fs_linux_tar_excludes(), '-caf', - tempname + '.tar.xz', installer_name]) - else: - print( "Skipping %s.tar.xz for non-Release build (%s)" ) % \ - (installer_name, self.args['buildtype']) - finally: - self.run_command(["mv", tempname, realname]) + # temporarily move directory tree so that it has the right + # name in the tarfile + realname = self.get_dst_prefix() + tempname = self.build_path_of(installer_name) + self.run_command(["mv", realname, tempname]) + try: + # only create tarball if it's a release build. + if self.args['buildtype'].lower() == 'release': + # --numeric-owner hides the username of the builder for + # security etc. + self.run_command(['tar', '-C', self.get_build_prefix(), + '--numeric-owner', self.fs_linux_tar_excludes(), '-caf', + tempname + '.tar.xz', installer_name]) + else: + print ("Skipping %s.tar.xz for non-Release build (%s)" % \ + (installer_name, self.args['buildtype'])) + finally: + self.run_command(["mv", tempname, realname]) def strip_binaries(self): if self.args['buildtype'].lower() == 'release' and self.is_packaging_viewer(): print ("* Going strip-crazy on the packaged binaries, since this is a RELEASE build") - if not os.path.isdir( os.path.join( self.get_dst_prefix(), "lib") ): - os.mkdir( os.path.join( self.get_dst_prefix(), "lib") ) # makes some small assumptions about our packaged dir structure self.run_command( ["find"] + @@ -2165,7 +2123,7 @@ class Linux_i686_Manifest(LinuxManifest): self.path("libexpat.so.*") self.path("libGLOD.so") self.path("libuuid.so*") - self.path("libSDL*") + self.path("libSDL-1.2.so.*") self.path("libdirectfb-1.*.so.*") self.path("libfusion-1.*.so.*") self.path("libdirect-1.*.so.*") @@ -2244,7 +2202,7 @@ class Linux_x86_64_Manifest(LinuxManifest): if self.is_packaging_viewer(): with self.prefix(src=os.path.join(pkgdir, 'lib', 'release'), dst="lib"): - self.fs_try_path("libffi*.so*") + self.path("libffi*.so*") # vivox 32-bit hack. # one has to extract libopenal.so from the 32-bit openal package, or official LL viewer, and rename it to libopenal32.so # and place it in the prebuilt lib/release directory @@ -2263,7 +2221,6 @@ class Linux_x86_64_Manifest(LinuxManifest): with self.prefix(dst="bin"): self.path2basename("../llplugin/slplugin", "SLPlugin") - self.path("secondlife-i686.supp")