summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/cmake/LLWindow.cmake8
-rw-r--r--indra/llwindow/llkeyboard.cpp8
-rw-r--r--indra/llwindow/llkeyboard.h12
-rw-r--r--indra/llwindow/llkeyboardheadless.cpp4
-rw-r--r--indra/llwindow/llkeyboardheadless.h4
-rw-r--r--indra/llwindow/llkeyboardsdl.cpp84
-rw-r--r--indra/llwindow/llkeyboardsdl.h14
-rw-r--r--indra/llwindow/llwindowsdl.cpp206
-rw-r--r--indra/llwindow/llwindowsdl.h14
9 files changed, 202 insertions, 152 deletions
diff --git a/indra/cmake/LLWindow.cmake b/indra/cmake/LLWindow.cmake
index f952383a27..09b8fdb83d 100644
--- a/indra/cmake/LLWindow.cmake
+++ b/indra/cmake/LLWindow.cmake
@@ -9,11 +9,11 @@ add_library( ll::SDL INTERFACE IMPORTED )
if (NOT (USE_AUTOBUILD_3P OR USE_CONAN) AND NOT DARWIN)
include(FindPkgConfig)
- pkg_check_modules(Sdl REQUIRED sdl)
+ pkg_check_modules(Sdl2 REQUIRED sdl2)
target_compile_definitions( ll::SDL INTERFACE LL_SDL=1)
- target_include_directories(ll::SDL SYSTEM INTERFACE ${Sdl_INCLUDE_DIRS})
- target_link_directories(ll::SDL INTERFACE ${Sdl_LIBRARY_DIRS})
- target_link_libraries(ll::SDL INTERFACE ${Sdl_LIBRARIES} X11)
+ target_include_directories(ll::SDL SYSTEM INTERFACE ${Sdl2_INCLUDE_DIRS})
+ target_link_directories(ll::SDL INTERFACE ${Sdl2_LIBRARY_DIRS})
+ target_link_libraries(ll::SDL INTERFACE ${Sdl2_LIBRARIES} X11)
return ()
endif ()
diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp
index e65cc7563e..ac8c97d34e 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 fb1ae10f50..2a700ce8e9 100644
--- a/indra/llwindow/llkeyboard.h
+++ b/indra/llwindow/llkeyboard.h
@@ -67,14 +67,14 @@ 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
// We only actually use this for OS X.
@@ -109,8 +109,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 a1b6b294e0..3ca421f9f9 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 8ed28ace90..929751586c 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 7c9aa1d340..872b58e2ec 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.
@@ -201,34 +201,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 +246,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 +268,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 +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_META) result |= MASK_CONTROL;
+ if (mask & KMOD_GUI) result |= MASK_CONTROL;
}
return result;
@@ -310,12 +310,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 02a71425f1..2b1ac5af2b 100644
--- a/indra/llwindow/llkeyboardsdl.h
+++ b/indra/llwindow/llkeyboardsdl.h
@@ -28,7 +28,7 @@
#define LL_LLKEYBOARDSDL_H
#include "llkeyboard.h"
-#include "SDL/SDL.h"
+#include "SDL2/SDL.h"
class LLKeyboardSDL : public LLKeyboard
{
@@ -36,8 +36,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 +45,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/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index 9c8fadb968..11605804c0 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -432,44 +432,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)
+ if (display_mode.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)
- {
- // 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
@@ -489,7 +470,7 @@ 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_DOUBLEBUFFER, 1);
@@ -553,19 +534,24 @@ 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
@@ -597,11 +583,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)
@@ -610,11 +600,32 @@ 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;
}
+
+ //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)
+ {
+ // 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_X11
gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024;
@@ -633,6 +644,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
LL_INFOS() << "SDL 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
@@ -695,15 +707,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;
+ mSDL_XWindowID = info.info.x11.window;
+ /*
Lock_Display = info.info.x11.lock_func;
Unlock_Display = info.info.x11.unlock_func;
+ */
}
else
{
@@ -723,9 +737,11 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
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() <<LL_ENDL;
+ */
// Don't need to get the current gamma, since there's a call that restores it to the system defaults.
return TRUE;
@@ -898,8 +914,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);
}
@@ -910,8 +925,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);
}
@@ -936,9 +950,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;
@@ -954,9 +969,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;
@@ -970,7 +986,7 @@ void LLWindowSDL::swapBuffers()
{
if (mWindow)
{
- SDL_GL_SwapBuffers();
+ SDL_GL_SwapWindow(mWindow);
}
}
@@ -992,7 +1008,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;
}
@@ -1001,7 +1019,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;
}
@@ -1071,7 +1091,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_WarpMouse(screen_pos.mX, screen_pos.mY);
+ SDL_WarpMouseGlobal(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;
@@ -1160,6 +1180,7 @@ void LLWindowSDL::beforeDialog()
LL_INFOS() << "LLWindowSDL::beforeDialog()" << LL_ENDL;
+ /*
if (SDLReallyCaptureInput(FALSE)) // must ungrab input so popup works!
{
if (mFullscreen)
@@ -1173,6 +1194,7 @@ void LLWindowSDL::beforeDialog()
}
}
}
+ */
#if LL_X11
if (mSDL_Display)
@@ -1211,7 +1233,7 @@ void LLWindowSDL::afterDialog()
// in X11
if (running_x11 && mWindow)
{
- SDL_WM_ToggleFullScreen(mWindow);
+ SDL_SetWindowFullscreen(mWindow, SDL_WINDOW_FULLSCREEN);
}
}
}
@@ -1391,6 +1413,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)) )
{
@@ -1405,8 +1428,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!
@@ -1420,7 +1449,7 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso
}
}
}
- }
+ //}
}
num_resolutions = mNumSupportedResolutions;
@@ -1433,7 +1462,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;
}
@@ -1444,7 +1475,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;
}
@@ -1495,6 +1528,7 @@ void LLWindowSDL::setupFailure(const std::string& text, const std::string& capti
OSMessageBox(text, caption, type);
}
+/*
BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture)
{
// note: this used to be safe to call nestedly, but in the
@@ -1520,12 +1554,12 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture)
LL_WARNS() << "ReallyCapture count was < 0" << LL_ENDL;
}
- if (!mFullscreen) /* only bother if we're windowed anyway */
+ 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
+ // we dirtily mix raw X11 with SDL so that our pointer
isn't (as often) constrained to the limits of the
window while grabbed, which feels nicer and
hopefully eliminates some reported 'sticky pointer'
@@ -1533,7 +1567,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture)
SDL_WM_GrabInput() because the latter constrains
the pointer to the window and also steals all
*keyboard* input from the window manager, which was
- frustrating users. */
+ frustrating users. *
int result;
if (wantmode == SDL_GRAB_ON)
{
@@ -1576,8 +1610,9 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture)
return (capture && SDL_GRAB_ON==newmode) ||
(!capture && SDL_GRAB_OFF==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
@@ -1778,28 +1813,36 @@ 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);
// part of the fix for SL-13243
+ /*
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:
+ mKeyVirtualKey = *event.text.text;
+ handleUnicodeUTF16(mKeyVirtualKey,
+ gKeyboard->currentMask(FALSE));
+ 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)
SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243
+ */
gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod);
break;
@@ -1886,19 +1929,22 @@ 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;
-
- S32 width = llmax(event.resize.w, (S32)mMinWindowWidth);
- S32 height = llmax(event.resize.h, (S32)mMinWindowHeight);
-
+ 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.window.data1, (S32)mMinWindowWidth);
+ S32 height = llmax(event.window.data2, (S32)mMinWindowHeight);
+
+ // *FIX: handle this?
// *FIX: I'm not sure this is necessary!
+ /*
mWindow = SDL_SetVideoMode(width, height, 32, mSDLFlags);
if (!mWindow)
{
@@ -1912,10 +1958,13 @@ void LLWindowSDL::gatherInput()
}
break;
}
+ */
mCallbacks->handleResize(this, width, height);
+ }
break;
}
+ /*
case SDL_ACTIVEEVENT:
if (event.active.state & SDL_APPINPUTFOCUS)
{
@@ -1952,6 +2001,7 @@ void LLWindowSDL::gatherInput()
}
}
break;
+ */
case SDL_QUIT:
if(mCallbacks->handleCloseRequest(this))
diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h
index 57885907b4..e8a93247f3 100644
--- a/indra/llwindow/llwindowsdl.h
+++ b/indra/llwindow/llwindowsdl.h
@@ -32,12 +32,12 @@
#include "llwindow.h"
#include "lltimer.h"
-#include "SDL/SDL.h"
-#include "SDL/SDL_endian.h"
+#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.
@@ -181,15 +181,15 @@ protected:
void destroyContext();
void setupFailure(const std::string& text, const std::string& caption, U32 type);
void fixWindowSize(void);
- U32 SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain);
- BOOL SDLReallyCaptureInput(BOOL capture);
+ U32 SDLCheckGrabbyKeys(SDL_Keycode keysym, BOOL gain);
+ //BOOL SDLReallyCaptureInput(BOOL capture);
//
// Platform specific variables
//
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.
@@ -215,7 +215,7 @@ private:
U32 mKeyScanCode;
U32 mKeyVirtualKey;
- SDLMod mKeyModifiers;
+ Uint16 mKeyModifiers;
};