summaryrefslogtreecommitdiff
path: root/indra/llwindow/llwindowsdl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow/llwindowsdl.cpp')
-rw-r--r--indra/llwindow/llwindowsdl.cpp83
1 files changed, 52 insertions, 31 deletions
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index c98913e8b5..e2ad6b2723 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -39,6 +39,7 @@
#include "llfindlocale.h"
#include "llpreeditor.h"
#include "llsdl.h"
+#include "llgamecontrol.h"
#if LL_LINUX || __FreeBSD__
#ifdef LL_GLIB
@@ -101,8 +102,6 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks,
: LLWindow(callbacks, fullscreen, flags),
mGamma(1.0f), mFlashing(false)
{
- SDL_GL_LoadLibrary(nullptr);
-
// Initialize the keyboard
gKeyboard = new LLKeyboardSDL();
gKeyboard->setCallbacks(callbacks);
@@ -215,7 +214,7 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b
if (width == 0)
width = 1024;
if (height == 0)
- width = 768;
+ height = 768;
if (x == 0)
x = SDL_WINDOWPOS_UNDEFINED;
if (y == 0)
@@ -644,7 +643,7 @@ bool LLWindowSDL::isValid()
return mWindow != nullptr;
}
-bool LLWindowSDL::getVisible()
+bool LLWindowSDL::getVisible() const
{
bool result = true;
if (mWindow)
@@ -658,7 +657,7 @@ bool LLWindowSDL::getVisible()
return result;
}
-bool LLWindowSDL::getMinimized()
+bool LLWindowSDL::getMinimized() const
{
bool result = false;
if (mWindow)
@@ -672,7 +671,7 @@ bool LLWindowSDL::getMinimized()
return result;
}
-bool LLWindowSDL::getMaximized()
+bool LLWindowSDL::getMaximized() const
{
bool result = false;
if (mWindow)
@@ -697,7 +696,7 @@ bool LLWindowSDL::maximize()
return false;
}
-bool LLWindowSDL::getPosition(LLCoordScreen *position)
+bool LLWindowSDL::getPosition(LLCoordScreen *position) const
{
if (mWindow)
{
@@ -707,7 +706,7 @@ bool LLWindowSDL::getPosition(LLCoordScreen *position)
return false;
}
-bool LLWindowSDL::getSize(LLCoordScreen *size)
+bool LLWindowSDL::getSize(LLCoordScreen *size) const
{
if (mWindow)
{
@@ -718,7 +717,7 @@ bool LLWindowSDL::getSize(LLCoordScreen *size)
return false;
}
-bool LLWindowSDL::getSize(LLCoordWindow *size)
+bool LLWindowSDL::getSize(LLCoordWindow *size) const
{
if (mWindow)
{
@@ -774,7 +773,7 @@ void LLWindowSDL::swapBuffers()
LL_PROFILER_GPU_COLLECT;
}
-U32 LLWindowSDL::getFSAASamples()
+U32 LLWindowSDL::getFSAASamples() const
{
return mFSAASamples;
}
@@ -784,7 +783,7 @@ void LLWindowSDL::setFSAASamples(const U32 samples)
mFSAASamples = samples;
}
-F32 LLWindowSDL::getGamma()
+F32 LLWindowSDL::getGamma() const
{
return 1.f / mGamma;
}
@@ -1010,9 +1009,11 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso
if ((w >= 800) && (h >= 600))
{
// make sure we don't add the same resolution multiple times!
+ // A row is "the same" only when both width AND height match the previous row;
+ // if either dimension differs we keep it.
if ( (mNumSupportedResolutions == 0) ||
- ((mSupportedResolutions[mNumSupportedResolutions-1].mWidth != w) &&
- (mSupportedResolutions[mNumSupportedResolutions-1].mHeight != h)) )
+ (mSupportedResolutions[mNumSupportedResolutions-1].mWidth != w) ||
+ (mSupportedResolutions[mNumSupportedResolutions-1].mHeight != h) )
{
mSupportedResolutions[mNumSupportedResolutions].mWidth = w;
mSupportedResolutions[mNumSupportedResolutions].mHeight = h;
@@ -1048,8 +1049,7 @@ std::vector<std::string> LLWindowSDL::getDisplaysResolutionList()
return ret;
}
-
-bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to)
+bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to) const
{
if (!to)
return false;
@@ -1068,7 +1068,7 @@ bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to)
return true;
}
-bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to)
+bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to) const
{
if (!to)
return false;
@@ -1086,7 +1086,7 @@ bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to)
return true;
}
-bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordWindow* to)
+bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordWindow* to) const
{
if (!to)
return false;
@@ -1097,7 +1097,7 @@ bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordWindow* to)
return true;
}
-bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordScreen *to)
+bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordScreen *to) const
{
if (!to)
return false;
@@ -1108,14 +1108,14 @@ bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordScreen *to)
return true;
}
-bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordGL *to)
+bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordGL *to) const
{
LLCoordWindow window_coord;
return convertCoords(from, &window_coord) && convertCoords(window_coord, to);
}
-bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordScreen *to)
+bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordScreen *to) const
{
LLCoordWindow window_coord;
@@ -1233,7 +1233,7 @@ void LLWindowSDL::processMiscNativeEvents()
}
}
-void LLWindowSDL::gatherInput()
+void LLWindowSDL::gatherInput(bool app_has_focus)
{
// This is for the case where SDL is not driving the main event loop
if(!gSDLMainHandled)
@@ -1243,12 +1243,14 @@ void LLWindowSDL::gatherInput()
// Handle all outstanding SDL events
while (SDL_PollEvent(&event))
{
- handleEvent(event);
+ handleEvent(event, app_has_focus);
}
}
updateCursor();
+ LLGameControl::processEvents(app_has_focus);
+
// This is a good time to stop flashing the icon if our mFlashTimer has
// expired.
if (mFlashing && mFlashTimer.hasExpired())
@@ -1258,7 +1260,7 @@ void LLWindowSDL::gatherInput()
}
}
-SDL_AppResult LLWindowSDL::handleEvent(const SDL_Event& event)
+SDL_AppResult LLWindowSDL::handleEvent(const SDL_Event& event, bool app_has_focus)
{
switch(event.type)
{
@@ -1294,17 +1296,35 @@ SDL_AppResult LLWindowSDL::handleEvent(const SDL_Event& event)
if (event.button.button == SDL_BUTTON_LEFT) // left
{
if (event.button.clicks == 2)
- mCallbacks->handleDoubleClick(this, openGlCoord, mask);
+ {
+ mCallbacks->handleLeftMouseDoubleClick(this, openGlCoord, mask);
+ }
else
+ {
mCallbacks->handleMouseDown(this, openGlCoord, mask);
+ }
}
else if (event.button.button == SDL_BUTTON_RIGHT)
{
- mCallbacks->handleRightMouseDown(this, openGlCoord, mask);
+ if (event.button.clicks == 2)
+ {
+ mCallbacks->handleRightMouseDoubleClick(this, openGlCoord, mask);
+ }
+ else
+ {
+ mCallbacks->handleRightMouseDown(this, openGlCoord, mask);
+ }
}
else if (event.button.button == SDL_BUTTON_MIDDLE) // middle
{
- mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask);
+ if (event.button.clicks == 2)
+ {
+ mCallbacks->handleMiddleMouseDoubleClick(this, openGlCoord, mask);
+ }
+ else
+ {
+ mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask);
+ }
}
else
{
@@ -1462,6 +1482,7 @@ SDL_AppResult LLWindowSDL::handleEvent(const SDL_Event& event)
break;
}
default:
+ LLGameControl::handleEvent(event, app_has_focus);
break;
}
@@ -1469,11 +1490,11 @@ SDL_AppResult LLWindowSDL::handleEvent(const SDL_Event& event)
}
// static
-SDL_AppResult LLWindowSDL::handleEvents(const SDL_Event& event)
+SDL_AppResult LLWindowSDL::handleEvents(const SDL_Event& event, bool app_has_focus)
{
if(!gWindowImplementation) return SDL_APP_CONTINUE;
- return gWindowImplementation->handleEvent(event);
+ return gWindowImplementation->handleEvent(event, app_has_focus);
}
static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty)
@@ -1807,7 +1828,7 @@ bool LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b)
Make the raw keyboard data available - used to poke through to LLQtWebKit so
that Qt/Webkit has access to the virtual keycodes etc. that it needs
*/
-LLSD LLWindowSDL::getNativeKeyData()
+LLSD LLWindowSDL::getNativeKeyData() const
{
LLSD result = LLSD::emptyMap();
@@ -1864,7 +1885,7 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async)
LL_INFOS() << "spawn_web_browser returning." << LL_ENDL;
}
-void* LLWindowSDL::getPlatformWindow()
+void* LLWindowSDL::getPlatformWindow() const
{
void* ret = nullptr;
if (mWindow)
@@ -1966,7 +1987,7 @@ void LLWindowSDL::setLanguageTextInput(const LLCoordGL& position)
SDL_SetTextInputArea(mWindow, &r, 0);
}
-F32 LLWindowSDL::getSystemUISize()
+F32 LLWindowSDL::getSystemUISize() const
{
if(mWindow)
{