summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/CMakeLists.txt19
-rw-r--r--indra/llwindow/llkeyboard.cpp8
-rw-r--r--indra/llwindow/llkeyboard.h14
-rw-r--r--indra/llwindow/llkeyboardheadless.cpp4
-rw-r--r--indra/llwindow/llkeyboardheadless.h4
-rw-r--r--indra/llwindow/llkeyboardsdl.cpp96
-rw-r--r--indra/llwindow/llkeyboardsdl.h17
-rw-r--r--indra/llwindow/llwindow.cpp22
-rw-r--r--indra/llwindow/llwindowcallbacks.cpp4
-rw-r--r--indra/llwindow/llwindowcallbacks.h1
-rw-r--r--indra/llwindow/llwindowsdl.cpp451
-rw-r--r--indra/llwindow/llwindowsdl.h157
12 files changed, 533 insertions, 264 deletions
diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt
index 7b1430c67c..1e3c517483 100644
--- a/indra/llwindow/CMakeLists.txt
+++ b/indra/llwindow/CMakeLists.txt
@@ -51,7 +51,7 @@ set(llwindow_LINK_LIBRARIES
llcommon
llimage
llmath
- llrender
+ #llrender
llfilesystem
llxml
ll::glh_linear
@@ -59,9 +59,12 @@ set(llwindow_LINK_LIBRARIES
ll::uilibraries
ll::SDL
)
+
+include_directories(${CMAKE_SOURCE_DIR}/llrender)
+
# Libraries on which this library depends, needed for Linux builds
# Sort by high-level to low-level
-if (LINUX)
+if (USESYSTEMLIBS)
list(APPEND viewer_SOURCE_FILES
llkeyboardsdl.cpp
llwindowsdl.cpp
@@ -84,9 +87,9 @@ if (LINUX)
)
endif (BUILD_HEADLESS)
-endif (LINUX)
+endif (USESYSTEMLIBS)
-if (DARWIN)
+if (DARWIN AND (NOT USESYSTEMLIBS))
list(APPEND llwindow_SOURCE_FILES
llkeyboardmacosx.cpp
llwindowmacosx.cpp
@@ -108,7 +111,7 @@ if (DARWIN)
PROPERTIES
COMPILE_FLAGS "-Wno-deprecated-declarations -fpascal-strings"
)
-endif (DARWIN)
+endif (DARWIN AND (NOT USESYSTEMLIBS))
if (WINDOWS)
@@ -180,8 +183,10 @@ endif (SDL_FOUND)
target_link_libraries (llwindow ${llwindow_LINK_LIBRARIES})
target_include_directories(llwindow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
-if (DARWIN)
+if (DARWIN AND (NOT USESYSTEMLIBS))
include(CMakeFindFrameworks)
find_library(CARBON_LIBRARY Carbon)
target_link_libraries(llwindow ${CARBON_LIBRARY})
-endif (DARWIN)
+endif (DARWIN AND (NOT USESYSTEMLIBS))
+
+include(LibraryInstall)
diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp
index b3dcac6222..f154351ce3 100644
--- a/indra/llwindow/llkeyboard.cpp
+++ b/indra/llwindow/llkeyboard.cpp
@@ -195,9 +195,9 @@ void LLKeyboard::resetKeys()
}
-BOOL LLKeyboard::translateKey(const U16 os_key, KEY *out_key)
+BOOL LLKeyboard::translateKey(const U32 os_key, KEY *out_key)
{
- std::map<U16, KEY>::iterator iter;
+ std::map<U32, KEY>::iterator iter;
// Only translate keys in the map, ignore all other keys for now
iter = mTranslateKeyMap.find(os_key);
@@ -215,9 +215,9 @@ BOOL LLKeyboard::translateKey(const U16 os_key, KEY *out_key)
}
-U16 LLKeyboard::inverseTranslateKey(const KEY translated_key)
+U32 LLKeyboard::inverseTranslateKey(const KEY translated_key)
{
- std::map<KEY, U16>::iterator iter;
+ std::map<KEY, U32>::iterator iter;
iter = mInvTranslateKeyMap.find(translated_key);
if (iter == mInvTranslateKeyMap.end())
{
diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h
index 2618f9f022..1a6292f29f 100644
--- a/indra/llwindow/llkeyboard.h
+++ b/indra/llwindow/llkeyboard.h
@@ -67,16 +67,16 @@ public:
BOOL getKeyDown(const KEY key) { return mKeyLevel[key]; }
BOOL getKeyRepeated(const KEY key) { return mKeyRepeated[key]; }
- BOOL translateKey(const U16 os_key, KEY *translated_key);
- U16 inverseTranslateKey(const KEY translated_key);
+ BOOL translateKey(const U32 os_key, KEY *translated_key);
+ U32 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
- virtual BOOL handleKeyUp(const U16 key, MASK mask) = 0;
- virtual BOOL handleKeyDown(const U16 key, MASK mask) = 0;
+ virtual BOOL handleKeyUp(const U32 key, MASK mask) = 0;
+ virtual BOOL handleKeyDown(const U32 key, MASK mask) = 0;
-#ifdef LL_DARWIN
+#if defined(LL_DARWIN) && !defined(LL_SDL)
// We only actually use this for OS X.
virtual void handleModifier(MASK mask) = 0;
#endif // LL_DARWIN
@@ -111,8 +111,8 @@ protected:
void addKeyName(KEY key, const std::string& name);
protected:
- std::map<U16, KEY> mTranslateKeyMap; // Map of translations from OS keys to Linden KEYs
- std::map<KEY, U16> mInvTranslateKeyMap; // Map of translations from Linden KEYs to OS keys
+ std::map<U32, KEY> mTranslateKeyMap; // Map of translations from OS keys to Linden KEYs
+ std::map<KEY, U32> 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 01ac26261b..3e81aff626 100644
--- a/indra/llwindow/llkeyboardheadless.cpp
+++ b/indra/llwindow/llkeyboardheadless.cpp
@@ -35,11 +35,11 @@ void LLKeyboardHeadless::resetMaskKeys()
{ }
-BOOL LLKeyboardHeadless::handleKeyDown(const U16 key, const U32 mask)
+BOOL LLKeyboardHeadless::handleKeyDown(const U32 key, const U32 mask)
{ return FALSE; }
-BOOL LLKeyboardHeadless::handleKeyUp(const U16 key, const U32 mask)
+BOOL LLKeyboardHeadless::handleKeyUp(const U32 key, const U32 mask)
{ return FALSE; }
MASK LLKeyboardHeadless::currentMask(BOOL for_mouse_event)
diff --git a/indra/llwindow/llkeyboardheadless.h b/indra/llwindow/llkeyboardheadless.h
index 8e067e6108..73910ed883 100644
--- a/indra/llwindow/llkeyboardheadless.h
+++ b/indra/llwindow/llkeyboardheadless.h
@@ -35,8 +35,8 @@ public:
LLKeyboardHeadless();
/*virtual*/ ~LLKeyboardHeadless() {};
- /*virtual*/ BOOL handleKeyUp(const U16 key, MASK mask);
- /*virtual*/ BOOL handleKeyDown(const U16 key, MASK mask);
+ /*virtual*/ BOOL handleKeyUp(const U32 key, MASK mask);
+ /*virtual*/ BOOL handleKeyDown(const U32 key, MASK mask);
/*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 3ee10f70cd..d1e5cd6c5a 100644
--- a/indra/llwindow/llkeyboardsdl.cpp
+++ b/indra/llwindow/llkeyboardsdl.cpp
@@ -29,7 +29,7 @@
#include "linden_common.h"
#include "llkeyboardsdl.h"
#include "llwindowcallbacks.h"
-#include "SDL/SDL.h"
+#include "SDL2/SDL.h"
LLKeyboardSDL::LLKeyboardSDL()
{
@@ -40,7 +40,7 @@ LLKeyboardSDL::LLKeyboardSDL()
// Virtual key mappings from SDL_keysym.h ...
// SDL maps the letter keys to the ASCII you'd expect, but it's lowercase...
- U16 cur_char;
+ U32 cur_char;
for (cur_char = 'A'; cur_char <= 'Z'; cur_char++)
{
mTranslateKeyMap[cur_char] = cur_char;
@@ -57,16 +57,16 @@ LLKeyboardSDL::LLKeyboardSDL()
// These ones are translated manually upon keydown/keyup because
// SDL doesn't handle their numlock transition.
- //mTranslateKeyMap[SDLK_KP4] = KEY_PAD_LEFT;
- //mTranslateKeyMap[SDLK_KP6] = KEY_PAD_RIGHT;
- //mTranslateKeyMap[SDLK_KP8] = KEY_PAD_UP;
- //mTranslateKeyMap[SDLK_KP2] = KEY_PAD_DOWN;
+ //mTranslateKeyMap[SDLK_KP_4] = KEY_PAD_LEFT;
+ //mTranslateKeyMap[SDLK_KP_6] = KEY_PAD_RIGHT;
+ //mTranslateKeyMap[SDLK_KP_8] = KEY_PAD_UP;
+ //mTranslateKeyMap[SDLK_KP_2] = KEY_PAD_DOWN;
//mTranslateKeyMap[SDLK_KP_PERIOD] = KEY_DELETE;
- //mTranslateKeyMap[SDLK_KP7] = KEY_HOME;
- //mTranslateKeyMap[SDLK_KP1] = KEY_END;
- //mTranslateKeyMap[SDLK_KP9] = KEY_PAGE_UP;
- //mTranslateKeyMap[SDLK_KP3] = KEY_PAGE_DOWN;
- //mTranslateKeyMap[SDLK_KP0] = KEY_INSERT;
+ //mTranslateKeyMap[SDLK_KP_7] = KEY_HOME;
+ //mTranslateKeyMap[SDLK_KP_1] = KEY_END;
+ //mTranslateKeyMap[SDLK_KP_9] = KEY_PAGE_UP;
+ //mTranslateKeyMap[SDLK_KP_3] = KEY_PAGE_DOWN;
+ //mTranslateKeyMap[SDLK_KP_0] = KEY_INSERT;
mTranslateKeyMap[SDLK_SPACE] = ' ';
mTranslateKeyMap[SDLK_RETURN] = KEY_RETURN;
@@ -124,23 +124,23 @@ LLKeyboardSDL::LLKeyboardSDL()
mTranslateKeyMap[SDLK_QUOTE] = '\'';
// Build inverse map
- std::map<U16, KEY>::iterator iter;
+ std::map<U32, KEY>::iterator iter;
for (iter = mTranslateKeyMap.begin(); iter != mTranslateKeyMap.end(); iter++)
{
mInvTranslateKeyMap[iter->second] = iter->first;
}
// numpad map
- 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_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_KP_PERIOD] = KEY_PAD_DEL;
// build inverse numpad map
@@ -154,7 +154,7 @@ LLKeyboardSDL::LLKeyboardSDL()
void LLKeyboardSDL::resetMaskKeys()
{
- SDLMod mask = SDL_GetModState();
+ SDL_Keymod 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.
@@ -165,7 +165,11 @@ void LLKeyboardSDL::resetMaskKeys()
mKeyLevel[KEY_SHIFT] = TRUE;
}
- if(mask & KMOD_CTRL)
+ if(mask & (KMOD_CTRL
+#ifdef LL_DARWIN
+ | KMOD_GUI
+#endif
+ ))
{
mKeyLevel[KEY_CONTROL] = TRUE;
}
@@ -187,7 +191,11 @@ MASK LLKeyboardSDL::updateModifiers(const U32 mask)
out_mask |= MASK_SHIFT;
}
- if(mask & KMOD_CTRL)
+ if(mask & (KMOD_CTRL
+#ifdef LL_DARWIN
+ | KMOD_GUI
+#endif
+ ))
{
out_mask |= MASK_CONTROL;
}
@@ -201,34 +209,34 @@ MASK LLKeyboardSDL::updateModifiers(const U32 mask)
}
-static U16 adjustNativekeyFromUnhandledMask(const U16 key, const U32 mask)
+static U32 adjustNativekeyFromUnhandledMask(const U32 key, const U32 mask)
{
// SDL doesn't automatically adjust the keysym according to
// whether NUMLOCK is engaged, so we massage the keysym manually.
- U16 rtn = key;
+ U32 rtn = key;
if (!(mask & KMOD_NUM))
{
switch (key)
{
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;
+ 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;
}
}
return rtn;
}
-BOOL LLKeyboardSDL::handleKeyDown(const U16 key, const U32 mask)
+BOOL LLKeyboardSDL::handleKeyDown(const U32 key, const U32 mask)
{
- U16 adjusted_nativekey;
+ U32 adjusted_nativekey;
KEY translated_key = 0;
U32 translated_mask = MASK_NONE;
BOOL handled = FALSE;
@@ -246,9 +254,9 @@ BOOL LLKeyboardSDL::handleKeyDown(const U16 key, const U32 mask)
}
-BOOL LLKeyboardSDL::handleKeyUp(const U16 key, const U32 mask)
+BOOL LLKeyboardSDL::handleKeyUp(const U32 key, const U32 mask)
{
- U16 adjusted_nativekey;
+ U32 adjusted_nativekey;
KEY translated_key = 0;
U32 translated_mask = MASK_NONE;
BOOL handled = FALSE;
@@ -268,7 +276,7 @@ BOOL LLKeyboardSDL::handleKeyUp(const U16 key, const U32 mask)
MASK LLKeyboardSDL::currentMask(BOOL for_mouse_event)
{
MASK result = MASK_NONE;
- SDLMod mask = SDL_GetModState();
+ SDL_Keymod mask = SDL_GetModState();
if (mask & KMOD_SHIFT) result |= MASK_SHIFT;
if (mask & KMOD_CTRL) result |= MASK_CONTROL;
@@ -277,7 +285,7 @@ MASK LLKeyboardSDL::currentMask(BOOL for_mouse_event)
// For keyboard events, consider Meta keys equivalent to Control
if (!for_mouse_event)
{
- if (mask & KMOD_META) result |= MASK_CONTROL;
+ if (mask & KMOD_GUI) result |= MASK_CONTROL;
}
return result;
@@ -310,12 +318,12 @@ void LLKeyboardSDL::scanKeyboard()
}
-BOOL LLKeyboardSDL::translateNumpadKey( const U16 os_key, KEY *translated_key)
+BOOL LLKeyboardSDL::translateNumpadKey( const U32 os_key, KEY *translated_key)
{
return translateKey(os_key, translated_key);
}
-U16 LLKeyboardSDL::inverseTranslateNumpadKey(const KEY translated_key)
+U32 LLKeyboardSDL::inverseTranslateNumpadKey(const KEY translated_key)
{
return inverseTranslateKey(translated_key);
}
diff --git a/indra/llwindow/llkeyboardsdl.h b/indra/llwindow/llkeyboardsdl.h
index 620f83e9b4..ac6e9f2cef 100644
--- a/indra/llwindow/llkeyboardsdl.h
+++ b/indra/llwindow/llkeyboardsdl.h
@@ -28,7 +28,10 @@
#define LL_LLKEYBOARDSDL_H
#include "llkeyboard.h"
-#include "SDL/SDL.h"
+#if !defined(__i386__) && !defined(__x86_64__)
+#define SDL_DISABLE_IMMINTRIN_H
+#endif
+#include "SDL2/SDL.h"
class LLKeyboardSDL : public LLKeyboard
{
@@ -36,8 +39,8 @@ public:
LLKeyboardSDL();
/*virtual*/ ~LLKeyboardSDL() {};
- /*virtual*/ BOOL handleKeyUp(const U16 key, MASK mask);
- /*virtual*/ BOOL handleKeyDown(const U16 key, MASK mask);
+ /*virtual*/ BOOL handleKeyUp(const U32 key, MASK mask);
+ /*virtual*/ BOOL handleKeyDown(const U32 key, MASK mask);
/*virtual*/ void resetMaskKeys();
/*virtual*/ MASK currentMask(BOOL for_mouse_event);
/*virtual*/ void scanKeyboard();
@@ -45,11 +48,11 @@ public:
protected:
MASK updateModifiers(const U32 mask);
void setModifierKeyLevel( KEY key, BOOL new_state );
- BOOL translateNumpadKey( const U16 os_key, KEY *translated_key );
- U16 inverseTranslateNumpadKey(const KEY translated_key);
+ BOOL translateNumpadKey( const U32 os_key, KEY *translated_key );
+ U32 inverseTranslateNumpadKey(const KEY translated_key);
private:
- std::map<U16, KEY> mTranslateNumpadMap; // special map for translating OS keys to numpad keys
- std::map<KEY, U16> mInvTranslateNumpadMap; // inverse of the above
+ std::map<U32, KEY> mTranslateNumpadMap; // special map for translating OS keys to numpad keys
+ std::map<KEY, U32> mInvTranslateNumpadMap; // inverse of the above
};
#endif
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp
index 9cc11091b6..b51b4fad82 100644
--- a/indra/llwindow/llwindow.cpp
+++ b/indra/llwindow/llwindow.cpp
@@ -33,8 +33,10 @@
#include "llwindowsdl.h"
#elif LL_WINDOWS
#include "llwindowwin32.h"
+/*
#elif LL_DARWIN
#include "llwindowmacosx.h"
+*/
#endif
#include "llerror.h"
@@ -74,12 +76,12 @@ S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type)
#if LL_MESA_HEADLESS // !!! *FIX: (?)
LL_WARNS() << "OSMessageBox: " << text << LL_ENDL;
return OSBTN_OK;
+#elif LL_SDL
+ result = OSMessageBoxSDL(text, caption, type);
#elif LL_WINDOWS
result = OSMessageBoxWin32(text, caption, type);
#elif LL_DARWIN
result = OSMessageBoxMacOSX(text, caption, type);
-#elif LL_SDL
- result = OSMessageBoxSDL(text, caption, type);
#else
#error("OSMessageBox not implemented for this platform!")
#endif
@@ -259,12 +261,12 @@ BOOL LLWindow::copyTextToPrimary(const LLWString &src)
// static
std::vector<std::string> LLWindow::getDynamicFallbackFontList()
{
-#if LL_WINDOWS
+#if LL_SDL
+ return LLWindowSDL::getDynamicFallbackFontList();
+#elif LL_WINDOWS
return LLWindowWin32::getDynamicFallbackFontList();
#elif LL_DARWIN
return LLWindowMacOSX::getDynamicFallbackFontList();
-#elif LL_SDL
- return LLWindowSDL::getDynamicFallbackFontList();
#else
return std::vector<std::string>();
#endif
@@ -273,12 +275,12 @@ std::vector<std::string> LLWindow::getDynamicFallbackFontList()
// static
std::vector<std::string> LLWindow::getDisplaysResolutionList()
{
-#if LL_WINDOWS
+#ifdef LL_SDL
+ return std::vector<std::string>();
+#elif LL_WINDOWS
return LLWindowWin32::getDisplaysResolutionList();
#elif LL_DARWIN
return LLWindowMacOSX::getDisplaysResolutionList();
-#else
- return std::vector<std::string>();
#endif
}
@@ -359,11 +361,13 @@ void LLSplashScreen::show()
{
if (!gSplashScreenp)
{
+#if !LL_SDL
#if LL_WINDOWS && !LL_MESA_HEADLESS
gSplashScreenp = new LLSplashScreenWin32;
#elif LL_DARWIN
gSplashScreenp = new LLSplashScreenMacOSX;
#endif
+#endif // !LL_SDL
if (gSplashScreenp)
{
gSplashScreenp->showImpl();
@@ -412,7 +416,7 @@ LLWindow* LLWindowManager::createWindow(
U32 max_vram,
F32 max_gl_version)
{
- LLWindow* new_window;
+ LLWindow* new_window = nullptr;
if (use_gl)
{
diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp
index a43d281d4c..ddf913045f 100644
--- a/indra/llwindow/llwindowcallbacks.cpp
+++ b/indra/llwindow/llwindowcallbacks.cpp
@@ -52,6 +52,10 @@ BOOL LLWindowCallbacks::handleUnicodeChar(llwchar uni_char, MASK mask)
return FALSE;
}
+BOOL LLWindowCallbacks::handleUnicodeString(char *uni_str, bool editing)
+{
+ return FALSE;
+}
BOOL LLWindowCallbacks::handleMouseDown(LLWindow *window, const LLCoordGL pos, MASK mask)
{
diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h
index d5681400a1..b7a843e748 100644
--- a/indra/llwindow/llwindowcallbacks.h
+++ b/indra/llwindow/llwindowcallbacks.h
@@ -37,6 +37,7 @@ public:
virtual BOOL handleTranslatedKeyUp(KEY key, MASK mask);
virtual void handleScanKey(KEY key, BOOL key_down, BOOL key_up, BOOL key_level);
virtual BOOL handleUnicodeChar(llwchar uni_char, MASK mask);
+ virtual BOOL handleUnicodeString(char *uni_str, bool editing);
virtual BOOL handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask);
virtual BOOL handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask);
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index df8b2ba5ab..5c0be53673 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -51,12 +51,14 @@ extern "C" {
# include "fontconfig/fontconfig.h"
}
-#if LL_LINUX
+#if LL_LINUX || LL_FREEBSD
// not necessarily available on random SDL platforms, so #if LL_LINUX
// for execv(), waitpid(), fork()
# include <unistd.h>
# include <sys/types.h>
# include <sys/wait.h>
+# define GLX_GLXEXT_PROTOTYPES 1
+# include <GL/glx.h>
#endif // LL_LINUX
extern BOOL gDebugWindowProc;
@@ -66,6 +68,41 @@ const S32 MAX_NUM_RESOLUTIONS = 200;
// static variable for ATI mouse cursor crash work-around:
static bool ATIbug = false;
+#if LL_DARWIN
+
+#include <OpenGL/OpenGL.h>
+#include <CoreGraphics/CGDirectDisplay.h>
+#include <CoreServices/CoreServices.h>
+
+BOOL gHiDPISupport = TRUE;
+
+namespace
+{
+ struct NativeKeyEventData {
+ enum EventType {
+ KEYUNKNOWN,
+ KEYUP,
+ KEYDOWN,
+ KEYCHAR
+ };
+
+ EventType mKeyEvent = KEYUNKNOWN;
+ uint32_t mEventType = 0;
+ uint32_t mEventModifiers = 0;
+ uint32_t mEventKeyCode = 0;
+ uint32_t mEventChars = 0;
+ uint32_t mEventUnmodChars = 0;
+ bool mEventRepeat = false;
+ } *mRawKeyEvent = NULL;
+}
+//
+// LLWindowMacOSX
+//
+
+BOOL LLWindowSDL::sUseMultGL = FALSE;
+
+#endif
+
//
// LLWindowSDL
//
@@ -119,7 +156,9 @@ bool LLWindowSDL::ll_try_gtk_init(void)
if (!tried_gtk_init)
{
tried_gtk_init = TRUE;
+#ifndef LL_USESYSTEMLIBS
if (!g_thread_supported ()) g_thread_init (NULL);
+#endif
maybe_lock_display();
gtk_is_good = gtk_init_check(NULL, NULL);
maybe_unlock_display();
@@ -267,7 +306,7 @@ static SDL_Surface *Load_BMP_Resource(const char *basename)
return SDL_LoadBMP(path_buffer);
}
-#if LL_X11
+#if 0
// This is an XFree86/XOrg-specific hack for detecting the amount of Video RAM
// on this machine. It works by searching /var/log/var/log/Xorg.?.log or
// /var/log/XFree86.?.log for a ': (VideoRAM ?|Memory): (%d+) kB' regex, where
@@ -430,44 +469,25 @@ 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;
- const SDL_version *r_sdl_version;
- r_sdl_version = SDL_Linked_Version();
+ SDL_version r_sdl_version;
+ SDL_GetVersion(&r_sdl_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;
- const SDL_VideoInfo *video_info = SDL_GetVideoInfo( );
- if (!video_info)
+ SDL_DisplayMode display_mode;
+ if (SDL_GetDesktopDisplayMode(0, &display_mode) < 0)
{
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;
- 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("ll_icon.BMP");
- if (bmpsurface)
+ if (display_mode.h > 0)
{
- // 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;
+ mOriginalAspectRatio = (float)display_mode.w / (float)display_mode.h;
+ LL_INFOS() << "Original aspect ratio was " << display_mode.w << ":" << display_mode.h << "=" << mOriginalAspectRatio << LL_ENDL;
}
// note: these SetAttributes make Tom's 9600-on-AMD64 fail to
@@ -487,7 +507,15 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
mFullscreen = fullscreen;
- int sdlflags = SDL_OPENGL | SDL_RESIZABLE | SDL_ANYFORMAT;
+ int sdlflags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;// | SDL_ANYFORMAT;
+
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
+#if LL_DARWIN
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
+#else
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6);
+#endif
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
@@ -551,19 +579,23 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
height = 768;
}
- mWindow = SDL_SetVideoMode(width, height, bits, sdlflags | SDL_FULLSCREEN);
+ mWindow = SDL_CreateWindow(mWindowTitle.c_str(),
+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
+ width, height, sdlflags | SDL_WINDOW_FULLSCREEN);
if (!mWindow && bits > 16)
{
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
- mWindow = SDL_SetVideoMode(width, height, bits, sdlflags | SDL_FULLSCREEN);
+ mWindow = SDL_CreateWindow(mWindowTitle.c_str(),
+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
+ width, height, sdlflags | SDL_WINDOW_FULLSCREEN);
}
if (mWindow)
{
+ SDL_GL_CreateContext(mWindow);
mFullscreen = TRUE;
- mFullscreenWidth = mWindow->w;
- mFullscreenHeight = mWindow->h;
- mFullscreenBits = mWindow->format->BitsPerPixel;
+ SDL_GetWindowSize(mWindow, &mFullscreenWidth, &mFullscreenHeight);
+ //mFullscreenBits = mWindow->format->BitsPerPixel;
mFullscreenRefresh = -1;
LL_INFOS() << "Running at " << mFullscreenWidth
@@ -595,11 +627,15 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
width = 768;
LL_INFOS() << "createContext: creating window " << width << "x" << height << "x" << bits << LL_ENDL;
- mWindow = SDL_SetVideoMode(width, height, bits, sdlflags);
+ mWindow = SDL_CreateWindow(mWindowTitle.c_str(),
+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
+ width, height, sdlflags);
if (!mWindow && bits > 16)
{
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
- mWindow = SDL_SetVideoMode(width, height, bits, sdlflags);
+ mWindow = SDL_CreateWindow(mWindowTitle.c_str(),
+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
+ width, height, sdlflags);
}
if (!mWindow)
@@ -608,29 +644,63 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
setupFailure("Window creation error", "Error", OSMB_OK);
return FALSE;
}
+ SDL_GL_CreateContext(mWindow);
} else if (!mFullscreen && (mWindow != NULL))
{
LL_INFOS() << "createContext: SKIPPING - !fullscreen, but +mWindow " << width << "x" << height << "x" << bits << LL_ENDL;
}
- // Detect video memory size.
-# if LL_X11
- gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024;
- if (gGLManager.mVRAM != 0)
+ //SDL_EnableUNICODE(1);
+ SDL_SetWindowTitle(mWindow, mWindowTitle.c_str());
+
+ // Set the application icon.
+ SDL_Surface *bmpsurface;
+ bmpsurface = Load_BMP_Resource("ll_icon.BMP");
+ if (bmpsurface)
{
- LL_INFOS() << "X11 log-parser detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL;
+ // This attempts to give a black-keyed mask to the icon.
+ SDL_SetColorKey(bmpsurface,
+ SDL_TRUE,
+ SDL_MapRGB(bmpsurface->format, 0,0,0) );
+ SDL_SetWindowIcon(mWindow, bmpsurface);
+ // The SDL examples cheerfully avoid freeing the icon
+ // surface, but I'm betting that's leaky.
+ SDL_FreeSurface(bmpsurface);
+ bmpsurface = NULL;
+ }
+
+ // Detect video memory size.
+#if LL_DARWIN
+ CGLRendererInfoObj info = 0;
+ GLint vram_megabytes = 0;
+ int num_renderers = 0;
+ auto err = CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
+ &info, &num_renderers);
+ if (!err) {
+ CGLDescribeRenderer(info, 0, kCGLRPVideoMemoryMegabytes, &vram_megabytes);
+ CGLDestroyRendererInfo(info);
} else
-# endif // LL_X11
- {
- // 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 = video_info->video_mem / 1024;
- if (gGLManager.mVRAM != 0)
- {
- LL_INFOS() << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL;
+ vram_megabytes = 256;
+ gGLManager.mVRAM = vram_megabytes;
+#else
+ PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger;
+ queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)
+ glXGetProcAddressARB((const GLubyte *)"glXQueryCurrentRendererIntegerMESA");
+ unsigned int vram_megabytes = 0;
+ queryInteger(GLX_RENDERER_VIDEO_MEMORY_MESA, &vram_megabytes);
+ if (!vram_megabytes) {
+ glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, (int *)&vram_megabytes);
+ vram_megabytes /= 1024;
}
- }
+ if (!vram_megabytes) {
+ glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, (int *)&vram_megabytes);
+ vram_megabytes /= 1024;
+ }
+
+ gGLManager.mVRAM = vram_megabytes;
+# endif // LL_DARWIN
+ if (gGLManager.mVRAM)
+ LL_INFOS() << "Detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL;
// If VRAM is not detected, that is handled later
// *TODO: Now would be an appropriate time to check for some
@@ -660,6 +730,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
// relaxed about if we have to.
if (colorBits < 32)
{
+#if LL_LINUX
close();
setupFailure(
"Second Life requires True Color (32-bit) to run in a window.\n"
@@ -670,6 +741,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
"Error",
OSMB_OK);
return FALSE;
+#endif // LL_LINUX
}
#if 0 // *FIX: we're going to brave it for now...
@@ -693,15 +765,17 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
/* Grab the window manager specific information */
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
- if ( SDL_GetWMInfo(&info) )
+ if ( SDL_GetWindowWMInfo(mWindow, &info) )
{
/* Save the information for later use */
if ( info.subsystem == SDL_SYSWM_X11 )
{
mSDL_Display = info.info.x11.display;
mSDL_XWindowID = info.info.x11.wmwindow;
+ /*
Lock_Display = info.info.x11.lock_func;
Unlock_Display = info.info.x11.unlock_func;
+ */
}
else
{
@@ -718,12 +792,16 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
//make sure multisampling is disabled by default
+#if GL_VERSION_1_3
glDisable(GL_MULTISAMPLE_ARB);
+#endif
// 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() <<LL_ENDL;
+ */
// Don't need to get the current gamma, since there's a call that restores it to the system defaults.
return TRUE;
@@ -896,8 +974,7 @@ BOOL LLWindowSDL::getSize(LLCoordScreen *size)
{
if (mWindow)
{
- size->mX = mWindow->w;
- size->mY = mWindow->h;
+ SDL_GetWindowSize(mWindow, &size->mX, &size->mY);
return (TRUE);
}
@@ -908,8 +985,7 @@ BOOL LLWindowSDL::getSize(LLCoordWindow *size)
{
if (mWindow)
{
- size->mX = mWindow->w;
- size->mY = mWindow->h;
+ SDL_GetWindowSize(mWindow, &size->mX, &size->mY);
return (TRUE);
}
@@ -934,9 +1010,10 @@ BOOL LLWindowSDL::setSizeImpl(const LLCoordScreen size)
// 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;
+ event.type = SDL_WINDOWEVENT;
+ event.window.event = SDL_WINDOWEVENT_RESIZED;
+ event.window.data1 = size.mX;
+ event.window.data2 = size.mY;
SDL_PushEvent(&event); // copied into queue
return TRUE;
@@ -952,9 +1029,10 @@ BOOL LLWindowSDL::setSizeImpl(const LLCoordWindow size)
// 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;
+ event.type = SDL_WINDOWEVENT;
+ event.window.event = SDL_WINDOWEVENT_RESIZED;
+ event.window.data1 = size.mX;
+ event.window.data2 = size.mY;
SDL_PushEvent(&event); // copied into queue
return TRUE;
@@ -968,7 +1046,7 @@ void LLWindowSDL::swapBuffers()
{
if (mWindow)
{
- SDL_GL_SwapBuffers();
+ SDL_GL_SwapWindow(mWindow);
}
}
@@ -990,7 +1068,9 @@ F32 LLWindowSDL::getGamma()
BOOL LLWindowSDL::restoreGamma()
{
//CGDisplayRestoreColorSyncSettings();
- SDL_SetGamma(1.0f, 1.0f, 1.0f);
+ Uint16 ramp;
+ SDL_CalculateGammaRamp(1.0f, &ramp);
+ SDL_SetWindowGammaRamp(mWindow, &ramp, &ramp, &ramp);
return true;
}
@@ -999,7 +1079,9 @@ BOOL LLWindowSDL::setGamma(const F32 gamma)
mGamma = gamma;
if (mGamma == 0) mGamma = 0.1f;
mGamma = 1/mGamma;
- SDL_SetGamma(mGamma, mGamma, mGamma);
+ Uint16 ramp;
+ SDL_CalculateGammaRamp(mGamma, &ramp);
+ SDL_SetWindowGammaRamp(mWindow, &ramp, &ramp, &ramp);
return true;
}
@@ -1035,6 +1117,27 @@ void LLWindowSDL::setMinSize(U32 min_width, U32 min_height, bool enforce_immedia
#endif
}
+void *LLWindowSDL::createSharedContext()
+{
+ // *FIX: What to do with SDL?
+ return nullptr;
+}
+
+void LLWindowSDL::makeContextCurrent(void* context)
+{
+ // *FIX: What to do with SDL?
+}
+
+void LLWindowSDL::destroySharedContext(void* context)
+{
+ // *FIX: What to do with SDL?
+}
+
+void LLWindowSDL::toggleVSync(bool enable_vsync)
+{
+ // *FIX: What to do with SDL?
+}
+
BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position)
{
BOOL result = TRUE;
@@ -1048,7 +1151,10 @@ BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position)
//LL_INFOS() << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << LL_ENDL;
// do the actual forced cursor move.
- SDL_WarpMouse(screen_pos.mX, screen_pos.mY);
+ if (mFullscreen)
+ SDL_WarpMouseGlobal(screen_pos.mX, screen_pos.mY);
+ else
+ SDL_WarpMouseInWindow(mWindow, 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;
@@ -1125,6 +1231,12 @@ F32 LLWindowSDL::getPixelAspectRatio()
return pixel_aspect;
}
+U32 LLWindowSDL::getAvailableVRAMMegabytes()
+{
+ static const U32 mb = 1024*1024;
+ static const U32 total_factor = 2;
+ return gGLManager.mVRAM - (LLImageGL::getTextureBytesAllocated() * total_factor/mb);
+}
// This is to support 'temporarily windowed' mode so that
// dialogs are still usable in fullscreen.
@@ -1146,7 +1258,7 @@ void LLWindowSDL::beforeDialog()
// it only works in X11
if (running_x11 && mWindow)
{
- SDL_WM_ToggleFullScreen(mWindow);
+ SDL_SetWindowFullscreen(mWindow, SDL_WINDOW_FULLSCREEN);
}
}
}
@@ -1188,7 +1300,7 @@ void LLWindowSDL::afterDialog()
// in X11
if (running_x11 && mWindow)
{
- SDL_WM_ToggleFullScreen(mWindow);
+ SDL_SetWindowFullscreen(mWindow, SDL_WINDOW_FULLSCREEN);
}
}
}
@@ -1331,17 +1443,24 @@ BOOL LLWindowSDL::copyTextToPrimary(const LLWString &text)
BOOL LLWindowSDL::isClipboardTextAvailable()
{
- return FALSE; // unsupported
+ return SDL_HasClipboardText();
}
BOOL LLWindowSDL::pasteTextFromClipboard(LLWString &dst)
{
- return FALSE; // unsupported
+ auto data = SDL_GetClipboardText();
+ if (data)
+ {
+ dst = LLWString(utf8str_to_wstring(data));
+ SDL_free(data);
+ return TRUE;
+ }
+ return FALSE;
}
BOOL LLWindowSDL::copyTextToClipboard(const LLWString &s)
{
- return FALSE; // unsupported
+ return !SDL_SetClipboardText(wstring_to_utf8str(s).c_str());
}
BOOL LLWindowSDL::isPrimaryTextAvailable()
@@ -1368,6 +1487,7 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso
mSupportedResolutions = new LLWindowResolution[MAX_NUM_RESOLUTIONS];
mNumSupportedResolutions = 0;
+ /*
SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
if ( (modes != NULL) && (modes != ((SDL_Rect **) -1)) )
{
@@ -1382,8 +1502,14 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso
{
modes--;
SDL_Rect *r = *modes;
- int w = r->w;
- int h = r->h;
+ */
+ static int display_in_use = 0; // Only using first display
+ auto display_mode_count = SDL_GetNumDisplayModes(display_in_use);
+ SDL_DisplayMode mode;
+ for (int i = 0; i < display_mode_count; ++i) {
+ SDL_GetDisplayMode(display_in_use, i, &mode);
+ int w = mode.w;
+ int h = mode.h;
if ((w >= 800) && (h >= 600))
{
// make sure we don't add the same resolution multiple times!
@@ -1397,7 +1523,7 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso
}
}
}
- }
+ //}
}
num_resolutions = mNumSupportedResolutions;
@@ -1410,7 +1536,9 @@ BOOL LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to)
return FALSE;
to->mX = from.mX;
- to->mY = mWindow->h - from.mY - 1;
+ int h;
+ SDL_GetWindowSize(mWindow, nullptr, &h);
+ to->mY = h - from.mY - 1;
return TRUE;
}
@@ -1421,7 +1549,9 @@ BOOL LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to)
return FALSE;
to->mX = from.mX;
- to->mY = mWindow->h - from.mY - 1;
+ int h;
+ SDL_GetWindowSize(mWindow, nullptr, &h);
+ to->mY = h - from.mY - 1;
return TRUE;
}
@@ -1482,13 +1612,13 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture)
else
mReallyCapturedCount = 0;
- SDL_GrabMode wantmode, newmode;
+ SDL_bool wantmode, newmode;
if (mReallyCapturedCount <= 0) // uncapture
{
- wantmode = SDL_GRAB_OFF;
+ wantmode = SDL_FALSE;
} else // capture
{
- wantmode = SDL_GRAB_ON;
+ wantmode = SDL_TRUE;
}
if (mReallyCapturedCount < 0) // yuck, imbalance.
@@ -1512,7 +1642,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture)
*keyboard* input from the window manager, which was
frustrating users. */
int result;
- if (wantmode == SDL_GRAB_ON)
+ if (wantmode == SDL_TRUE)
{
//LL_INFOS() << "X11 POINTER GRABBY" << LL_ENDL;
//newmode = SDL_WM_GrabInput(wantmode);
@@ -1523,13 +1653,13 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture)
None, None, CurrentTime);
maybe_unlock_display();
if (GrabSuccess == result)
- newmode = SDL_GRAB_ON;
+ newmode = SDL_TRUE;
else
- newmode = SDL_GRAB_OFF;
- } else if (wantmode == SDL_GRAB_OFF)
+ newmode = SDL_FALSE;
+ } else if (wantmode == SDL_FALSE)
{
//LL_INFOS() << "X11 POINTER UNGRABBY" << LL_ENDL;
- newmode = SDL_GRAB_OFF;
+ newmode = SDL_FALSE;
//newmode = SDL_WM_GrabInput(SDL_GRAB_OFF);
maybe_lock_display();
@@ -1539,7 +1669,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture)
maybe_unlock_display();
} else
{
- newmode = SDL_GRAB_QUERY; // neutral
+ //newmode = SDL_GRAB_QUERY; // neutral
}
} else // not actually running on X11, for some reason
newmode = wantmode;
@@ -1550,11 +1680,11 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture)
}
// return boolean success for whether we ended up in the desired state
- return (capture && SDL_GRAB_ON==newmode) ||
- (!capture && SDL_GRAB_OFF==newmode);
+ return (capture && SDL_TRUE==newmode) ||
+ (!capture && SDL_FALSE==newmode);
}
-U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain)
+U32 LLWindowSDL::SDLCheckGrabbyKeys(SDL_Keycode 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
@@ -1755,7 +1885,6 @@ void LLWindowSDL::gatherInput()
case SDL_KEYDOWN:
mKeyScanCode = event.key.keysym.scancode;
- mKeyVirtualKey = event.key.keysym.unicode;
mKeyModifiers = event.key.keysym.mod;
gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod);
@@ -1763,16 +1892,23 @@ void LLWindowSDL::gatherInput()
if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0)
SDLReallyCaptureInput(TRUE);
- if (event.key.keysym.unicode)
+ if (event.key.keysym.sym < SDLK_SPACE)
{
- handleUnicodeUTF16(event.key.keysym.unicode,
+ handleUnicodeUTF16(event.key.keysym.sym,
gKeyboard->currentMask(FALSE));
}
break;
+ case SDL_TEXTINPUT:
+ mCallbacks->handleUnicodeString(event.text.text, false);
+ break;
+
+ case SDL_TEXTEDITING:
+ mCallbacks->handleUnicodeString(event.edit.text, true);
+ break;
+
case SDL_KEYUP:
mKeyScanCode = event.key.keysym.scancode;
- mKeyVirtualKey = event.key.keysym.unicode;
mKeyModifiers = event.key.keysym.mod;
if (SDLCheckGrabbyKeys(event.key.keysym.sym, FALSE) == 0)
@@ -1837,14 +1973,17 @@ void LLWindowSDL::gatherInput()
{
mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask);
}
- else if (event.button.button == 4) // mousewheel up...thanks to X11 for making SDL consider these "buttons".
- mCallbacks->handleScrollWheel(this, -1);
- else if (event.button.button == 5) // mousewheel down...thanks to X11 for making SDL consider these "buttons".
- mCallbacks->handleScrollWheel(this, 1);
break;
}
+ case SDL_MOUSEWHEEL:
+ if (event.wheel.y > 0) // mousewheel up
+ mCallbacks->handleScrollWheel(this, -1);
+ else if (event.wheel.y < 0) // mousewheel down
+ mCallbacks->handleScrollWheel(this, 1);
+ break;
+
case SDL_MOUSEBUTTONUP:
{
LLCoordWindow winCoord(event.button.x, event.button.y);
@@ -1863,19 +2002,21 @@ void LLWindowSDL::gatherInput()
break;
}
- 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;
-
- case SDL_VIDEORESIZE: // *FIX: handle this?
+ case SDL_WINDOWEVENT:
{
- LL_INFOS() << "Handling a resize event: " << event.resize.w <<
- "x" << event.resize.h << LL_ENDL;
+ if (event.window.event == SDL_WINDOWEVENT_EXPOSED) { // VIDEOEXPOSE doesn't specify the damage, but hey, it's OpenGL...repaint the whole thing!
+ int w, h;
+ SDL_GetWindowSize(mWindow, &w, &h);
+ mCallbacks->handlePaint(this, 0, 0, w, h);
+ } else if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
+ LL_INFOS() << "Handling a resize event: " << event.window.data1 <<
+ "x" << event.window.data2 << LL_ENDL;
- S32 width = llmax(event.resize.w, (S32)mMinWindowWidth);
- S32 height = llmax(event.resize.h, (S32)mMinWindowHeight);
+ S32 width = llmax(event.window.data1, (S32)mMinWindowWidth);
+ S32 height = llmax(event.window.data2, (S32)mMinWindowHeight);
// *FIX: I'm not sure this is necessary!
+ /*
mWindow = SDL_SetVideoMode(width, height, 32, mSDLFlags);
if (!mWindow)
{
@@ -1889,10 +2030,13 @@ void LLWindowSDL::gatherInput()
}
break;
}
+ */
mCallbacks->handleResize(this, width, height);
+ }
break;
}
+ /*
case SDL_ACTIVEEVENT:
if (event.active.state & SDL_APPINPUTFOCUS)
{
@@ -1929,6 +2073,7 @@ void LLWindowSDL::gatherInput()
}
}
break;
+ */
case SDL_QUIT:
if(mCallbacks->handleCloseRequest(this))
@@ -2467,9 +2612,55 @@ BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b)
{
return (FALSE);
}
+
+#if LL_DARWIN
+
+LLSD LLWindowSDL::getNativeKeyData()
+{
+ LLSD result = LLSD::emptyMap();
+
+ if(mRawKeyEvent)
+ {
+ result["event_type"] = LLSD::Integer(mRawKeyEvent->mEventType);
+ result["event_modifiers"] = LLSD::Integer(mRawKeyEvent->mEventModifiers);
+ result["event_keycode"] = LLSD::Integer(mRawKeyEvent->mEventKeyCode);
+ result["event_chars"] = (mRawKeyEvent->mEventChars) ? LLSD(LLSD::Integer(mRawKeyEvent->mEventChars)) : LLSD();
+ result["event_umodchars"] = (mRawKeyEvent->mEventUnmodChars) ? LLSD(LLSD::Integer(mRawKeyEvent->mEventUnmodChars)) : LLSD();
+ result["event_isrepeat"] = LLSD::Boolean(mRawKeyEvent->mEventRepeat);
+ }
+
+ LL_DEBUGS() << "native key data is: " << result << LL_ENDL;
+
+ return result;
+}
+
+#else
+
+LLSD LLWindowSDL::getNativeKeyData()
+{
+ LLSD result = LLSD::emptyMap();
+
+ U32 modifiers = 0;
+ modifiers |= (mKeyModifiers & KMOD_LSHIFT) ? 0x0001 : 0;
+ modifiers |= (mKeyModifiers & KMOD_RSHIFT) ? 0x0001 : 0;
+ modifiers |= (mKeyModifiers & KMOD_CAPS) ? 0x0002 : 0;
+ modifiers |= (mKeyModifiers & KMOD_LCTRL) ? 0x0004 : 0;
+ modifiers |= (mKeyModifiers & KMOD_RCTRL) ? 0x0004 : 0;
+ modifiers |= (mKeyModifiers & KMOD_LALT) ? 0x0008 : 0;
+ modifiers |= (mKeyModifiers & KMOD_RALT) ? 0x0008 : 0;
+
+ result["scan_code"] = (S32)mKeyScanCode;
+ result["virtual_key"] = (S32)mKeyVirtualKey;
+ result["modifiers"] = (S32)modifiers;
+
+ return result;
+}
+
+#endif // LL_DARWIN
+
#endif // LL_GTK
-#if LL_LINUX
+#if LL_LINUX || LL_FREEBSD
// extracted from spawnWebBrowser for clarity and to eliminate
// compiler confusion regarding close(int fd) vs. LLWindow::close()
void exec_cmd(const std::string& cmd, const std::string& arg)
@@ -2525,7 +2716,7 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async)
LL_INFOS() << "spawn_web_browser: " << escaped_url << LL_ENDL;
-#if LL_LINUX
+#if LL_LINUX || LL_FREEBSD
# if LL_X11
if (mSDL_Display)
{
@@ -2537,13 +2728,53 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async)
# endif // LL_X11
std::string cmd, arg;
+#ifdef LL_USESYSTEMLIBS
+ cmd = gDirUtilp->getExecutableDir();
+#else
cmd = gDirUtilp->getAppRODataDir();
cmd += gDirUtilp->getDirDelimiter();
cmd += "etc";
+#endif
cmd += gDirUtilp->getDirDelimiter();
cmd += "launch_url.sh";
arg = escaped_url;
exec_cmd(cmd, arg);
+
+#elif LL_DARWIN
+
+ S32 result = 0;
+ CFURLRef urlRef = NULL;
+
+ LL_INFOS() << "Opening URL " << escaped_url << LL_ENDL;
+
+ CFStringRef stringRef = CFStringCreateWithCString(NULL, escaped_url.c_str(), kCFStringEncodingUTF8);
+ if (stringRef)
+ {
+ // This will succeed if the string is a full URL, including the http://
+ // Note that URLs specified this way need to be properly percent-escaped.
+ urlRef = CFURLCreateWithString(NULL, stringRef, NULL);
+
+ // Don't use CRURLCreateWithFileSystemPath -- only want valid URLs
+
+ CFRelease(stringRef);
+ }
+
+ if (urlRef)
+ {
+ result = LSOpenCFURLRef(urlRef, NULL);
+
+ if (result != noErr)
+ {
+ LL_INFOS() << "Error " << result << " on open." << LL_ENDL;
+ }
+
+ CFRelease(urlRef);
+ }
+ else
+ {
+ LL_INFOS() << "Error: couldn't create URL." << LL_ENDL;
+ }
+
#endif // LL_LINUX
LL_INFOS() << "spawn_web_browser returning." << LL_ENDL;
diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h
index e96fce92f5..0dbd94b1fe 100644
--- a/indra/llwindow/llwindowsdl.h
+++ b/indra/llwindow/llwindowsdl.h
@@ -32,12 +32,15 @@
#include "llwindow.h"
#include "lltimer.h"
-#include "SDL/SDL.h"
-#include "SDL/SDL_endian.h"
+#if !defined(__i386__) && !defined(__x86_64__)
+#define SDL_DISABLE_IMMINTRIN_H
+#endif
+#include "SDL2/SDL.h"
+#include "SDL2/SDL_endian.h"
#if LL_X11
// get X11-specific headers for use in low-level stuff like copy-and-paste support
-#include "SDL/SDL_syswm.h"
+#include "SDL2/SDL_syswm.h"
#endif
// AssertMacros.h does bad things.
@@ -49,80 +52,86 @@
class LLWindowSDL : public LLWindow
{
public:
- /*virtual*/ void show();
- /*virtual*/ void hide();
- /*virtual*/ void close();
- /*virtual*/ BOOL getVisible();
- /*virtual*/ BOOL getMinimized();
- /*virtual*/ BOOL getMaximized();
- /*virtual*/ BOOL maximize();
- /*virtual*/ void minimize();
- /*virtual*/ void restore();
+ void show() override;
+ void hide() override;
+ void close() override;
+ BOOL getVisible() override;
+ BOOL getMinimized() override;
+ BOOL getMaximized() override;
+ BOOL maximize() override;
+ void minimize() override;
+ void restore() override;
/*virtual*/ BOOL getFullscreen();
- /*virtual*/ BOOL getPosition(LLCoordScreen *position);
- /*virtual*/ BOOL getSize(LLCoordScreen *size);
- /*virtual*/ BOOL getSize(LLCoordWindow *size);
- /*virtual*/ BOOL setPosition(LLCoordScreen position);
- /*virtual*/ BOOL setSizeImpl(LLCoordScreen size);
- /*virtual*/ BOOL setSizeImpl(LLCoordWindow size);
- /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL);
- /*virtual*/ BOOL setCursorPosition(LLCoordWindow position);
- /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position);
- /*virtual*/ void showCursor();
- /*virtual*/ void hideCursor();
- /*virtual*/ void showCursorFromMouseMove();
- /*virtual*/ void hideCursorUntilMouseMove();
- /*virtual*/ BOOL isCursorHidden();
- /*virtual*/ void updateCursor();
- /*virtual*/ void captureMouse();
- /*virtual*/ void releaseMouse();
- /*virtual*/ void setMouseClipping( BOOL b );
- /*virtual*/ void setMinSize(U32 min_width, U32 min_height, bool enforce_immediately = true);
-
- /*virtual*/ BOOL isClipboardTextAvailable();
- /*virtual*/ BOOL pasteTextFromClipboard(LLWString &dst);
- /*virtual*/ BOOL copyTextToClipboard(const LLWString & src);
-
- /*virtual*/ BOOL isPrimaryTextAvailable();
- /*virtual*/ BOOL pasteTextFromPrimary(LLWString &dst);
- /*virtual*/ BOOL copyTextToPrimary(const LLWString & src);
-
- /*virtual*/ void flashIcon(F32 seconds);
- /*virtual*/ F32 getGamma();
- /*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
- /*virtual*/ U32 getFSAASamples();
- /*virtual*/ void setFSAASamples(const U32 samples);
- /*virtual*/ BOOL restoreGamma(); // Restore original gamma table (before updating gamma)
- /*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
- /*virtual*/ void processMiscNativeEvents();
- /*virtual*/ void gatherInput();
- /*virtual*/ void swapBuffers();
+ BOOL getPosition(LLCoordScreen *position) override;
+ BOOL getSize(LLCoordScreen *size) override;
+ BOOL getSize(LLCoordWindow *size) override;
+ BOOL setPosition(LLCoordScreen position) override;
+ BOOL setSizeImpl(LLCoordScreen size) override;
+ BOOL setSizeImpl(LLCoordWindow size) override;
+ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) override;
+ void* createSharedContext() override;
+ void makeContextCurrent(void* context) override;
+ void destroySharedContext(void* context) override;
+ void toggleVSync(bool enable_vsync) override;
+ BOOL setCursorPosition(LLCoordWindow position) override;
+ BOOL getCursorPosition(LLCoordWindow *position) override;
+ void showCursor() override;
+ void hideCursor() override;
+ void showCursorFromMouseMove() override;
+ void hideCursorUntilMouseMove() override;
+ BOOL isCursorHidden() override;
+ void updateCursor() override;
+ void captureMouse() override;
+ void releaseMouse() override;
+ void setMouseClipping( BOOL b ) override;
+ void setMinSize(U32 min_width, U32 min_height, bool enforce_immediately = true) override;
+
+ BOOL isClipboardTextAvailable() override;
+ BOOL pasteTextFromClipboard(LLWString &dst) override;
+ BOOL copyTextToClipboard(const LLWString & src) override;
+
+ BOOL isPrimaryTextAvailable() override;
+ BOOL pasteTextFromPrimary(LLWString &dst) override;
+ BOOL copyTextToPrimary(const LLWString & src) override;
+
+ void flashIcon(F32 seconds) override;
+ F32 getGamma() override;
+ BOOL setGamma(const F32 gamma) override; // Set the gamma
+ U32 getFSAASamples() override;
+ void setFSAASamples(const U32 samples) override;
+ BOOL restoreGamma() override; // Restore original gamma table (before updating gamma)
+ ESwapMethod getSwapMethod() override { return mSwapMethod; }
+ void processMiscNativeEvents() override;
+ void gatherInput() override;
+ void swapBuffers() override;
/*virtual*/ void restoreGLContext() {};
- /*virtual*/ void delayInputProcessing() { };
+ void delayInputProcessing() override { };
// handy coordinate space conversion routines
- /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);
- /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to);
- /*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordGL *to);
- /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordWindow *to);
- /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordGL *to);
- /*virtual*/ BOOL convertCoords(LLCoordGL from, LLCoordScreen *to);
+ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to) override;
+ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to) override;
+ BOOL convertCoords(LLCoordWindow from, LLCoordGL *to) override;
+ BOOL convertCoords(LLCoordGL from, LLCoordWindow *to) override;
+ BOOL convertCoords(LLCoordScreen from, LLCoordGL *to) override;
+ BOOL convertCoords(LLCoordGL from, LLCoordScreen *to) override;
+
+ LLWindowResolution* getSupportedResolutions(S32 &num_resolutions) override;
+ F32 getNativeAspectRatio() override;
+ F32 getPixelAspectRatio() override;
+ void setNativeAspectRatio(F32 ratio) override { mOverrideAspectRatio = ratio; }
- /*virtual*/ LLWindowResolution* getSupportedResolutions(S32 &num_resolutions);
- /*virtual*/ F32 getNativeAspectRatio();
- /*virtual*/ F32 getPixelAspectRatio();
- /*virtual*/ void setNativeAspectRatio(F32 ratio) { mOverrideAspectRatio = ratio; }
+ U32 getAvailableVRAMMegabytes() override;
- /*virtual*/ void beforeDialog();
- /*virtual*/ void afterDialog();
+ void beforeDialog() override;
+ void afterDialog() override;
- /*virtual*/ BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b);
+ BOOL dialogColorPicker(F32 *r, F32 *g, F32 *b) override;
- /*virtual*/ void *getPlatformWindow();
- /*virtual*/ void bringToFront();
+ void *getPlatformWindow() override;
+ void bringToFront() override;
- /*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async);
+ /*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async) override;
static std::vector<std::string> getDynamicFallbackFontList();
@@ -145,6 +154,10 @@ public:
static Display* get_SDL_Display(void);
#endif // LL_X11
+#if LL_DARWIN
+ static BOOL sUseMultGL;
+#endif
+
protected:
LLWindowSDL(LLWindowCallbacks* callbacks,
const std::string& title, int x, int y, int width, int height, U32 flags,
@@ -152,8 +165,8 @@ protected:
BOOL ignore_pixel_depth, U32 fsaa_samples);
~LLWindowSDL();
- /*virtual*/ BOOL isValid();
- /*virtual*/ LLSD getNativeKeyData();
+ BOOL isValid() override;
+ LLSD getNativeKeyData() override;
void initCursors();
void quitCursors();
@@ -177,7 +190,7 @@ protected:
void destroyContext();
void setupFailure(const std::string& text, const std::string& caption, U32 type);
void fixWindowSize(void);
- U32 SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain);
+ U32 SDLCheckGrabbyKeys(SDL_Keycode keysym, BOOL gain);
BOOL SDLReallyCaptureInput(BOOL capture);
//
@@ -185,7 +198,7 @@ protected:
//
U32 mGrabbyKeyFlags;
int mReallyCapturedCount;
- SDL_Surface * mWindow;
+ SDL_Window * mWindow;
std::string mWindowTitle;
double mOriginalAspectRatio;
BOOL mNeedsResize; // Constructor figured out the window is too big, it needs a resize.
@@ -211,7 +224,7 @@ private:
U32 mKeyScanCode;
U32 mKeyVirtualKey;
- SDLMod mKeyModifiers;
+ Uint16 mKeyModifiers;
};