aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llwindow/llwindowsdl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llwindow/llwindowsdl.cpp')
-rw-r--r--linden/indra/llwindow/llwindowsdl.cpp217
1 files changed, 101 insertions, 116 deletions
diff --git a/linden/indra/llwindow/llwindowsdl.cpp b/linden/indra/llwindow/llwindowsdl.cpp
index 5209e6f..4dd0550 100644
--- a/linden/indra/llwindow/llwindowsdl.cpp
+++ b/linden/indra/llwindow/llwindowsdl.cpp
@@ -1,6 +1,7 @@
1/** 1/**
2 * @file llwindowsdl.cpp 2 * @file llwindowsdl.cpp
3 * @brief SDL implementation of LLWindow class 3 * @brief SDL implementation of LLWindow class
4 * @author This module has many fathers, and it shows.
4 * 5 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 6 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 7 *
@@ -17,7 +18,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 18 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 19 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 20 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 21 * online at
22 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 23 *
22 * By copying, modifying or distributing this software, you acknowledge 24 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 25 * that you have read and understood your obligations described above,
@@ -83,8 +85,6 @@ static bool ATIbug = false;
83// be only one object of this class at any time. Currently this is true. 85// be only one object of this class at any time. Currently this is true.
84static LLWindowSDL *gWindowImplementation = NULL; 86static LLWindowSDL *gWindowImplementation = NULL;
85 87
86static BOOL was_fullscreen = FALSE;
87
88 88
89void maybe_lock_display(void) 89void maybe_lock_display(void)
90{ 90{
@@ -156,6 +156,8 @@ bool LLWindowSDL::ll_try_gtk_init(void)
156 llwarns << "- GTK COMPATIBILITY WARNING: " << 156 llwarns << "- GTK COMPATIBILITY WARNING: " <<
157 gtk_warning << llendl; 157 gtk_warning << llendl;
158 gtk_is_good = FALSE; 158 gtk_is_good = FALSE;
159 } else {
160 llinfos << "- GTK version is good." << llendl;
159 } 161 }
160 162
161 done_gtk_diag = TRUE; 163 done_gtk_diag = TRUE;
@@ -201,10 +203,6 @@ LLWindowSDL::LLWindowSDL(const std::string& title, S32 x, S32 y, S32 width,
201 203
202 // Ignore use_gl for now, only used for drones on PC 204 // Ignore use_gl for now, only used for drones on PC
203 mWindow = NULL; 205 mWindow = NULL;
204 mCursorDecoupled = FALSE;
205 mCursorLastEventDeltaX = 0;
206 mCursorLastEventDeltaY = 0;
207 mCursorIgnoreNextDelta = FALSE;
208 mNeedsResize = FALSE; 206 mNeedsResize = FALSE;
209 mOverrideAspectRatio = 0.f; 207 mOverrideAspectRatio = 0.f;
210 mGrabbyKeyFlags = 0; 208 mGrabbyKeyFlags = 0;
@@ -273,7 +271,7 @@ static SDL_Surface *Load_BMP_Resource(const char *basename)
273#if LL_X11 271#if LL_X11
274// This is an XFree86/XOrg-specific hack for detecting the amount of Video RAM 272// This is an XFree86/XOrg-specific hack for detecting the amount of Video RAM
275// on this machine. It works by searching /var/log/var/log/Xorg.?.log or 273// on this machine. It works by searching /var/log/var/log/Xorg.?.log or
276// /var/log/XFree86.?.log for a ': (VideoRAM|Memory): (%d+) kB' regex, where 274// /var/log/XFree86.?.log for a ': (VideoRAM ?|Memory): (%d+) kB' regex, where
277// '?' is the X11 display number derived from $DISPLAY 275// '?' is the X11 display number derived from $DISPLAY
278static int x11_detect_VRAM_kb_fp(FILE *fp, const char *prefix_str) 276static int x11_detect_VRAM_kb_fp(FILE *fp, const char *prefix_str)
279{ 277{
@@ -287,6 +285,8 @@ static int x11_detect_VRAM_kb_fp(FILE *fp, const char *prefix_str)
287 // favourite regex implementation - libboost_regex - is 285 // favourite regex implementation - libboost_regex - is
288 // quite a heavy and troublesome dependency for the client, so 286 // quite a heavy and troublesome dependency for the client, so
289 // it seems a shame to introduce it for such a simple task. 287 // it seems a shame to introduce it for such a simple task.
288 // *FIXME: libboost_regex is a dependency now anyway, so we may
289 // as well use it instead of this hand-rolled nonsense.
290 const char *part1_template = prefix_str; 290 const char *part1_template = prefix_str;
291 const char part2_template[] = " kB"; 291 const char part2_template[] = " kB";
292 char *part1 = strstr(line_buf, part1_template); 292 char *part1 = strstr(line_buf, part1_template);
@@ -324,8 +324,7 @@ static int x11_detect_VRAM_kb_fp(FILE *fp, const char *prefix_str)
324 324
325static int x11_detect_VRAM_kb() 325static int x11_detect_VRAM_kb()
326{ 326{
327#if LL_SOLARIS 327#if LL_SOLARIS && defined(__sparc)
328#error Can this be done without an explicit architecture test, ie a test FOR xorg? Was followed by: && defined(__sparc)
329 // NOTE: there's no Xorg server on SPARC so just return 0 328 // NOTE: there's no Xorg server on SPARC so just return 0
330 // and allow SDL to attempt to get the amount of VRAM 329 // and allow SDL to attempt to get the amount of VRAM
331 return(0); 330 return(0);
@@ -364,8 +363,17 @@ static int x11_detect_VRAM_kb()
364 fp = fopen(fname.c_str(), "r"); 363 fp = fopen(fname.c_str(), "r");
365 if (fp) 364 if (fp)
366 { 365 {
367 rtn = x11_detect_VRAM_kb_fp(fp, ": Memory: "); 366 rtn = x11_detect_VRAM_kb_fp(fp, ": Video RAM: ");
368 fclose(fp); 367 fclose(fp);
368 if (0 == rtn)
369 {
370 fp = fopen(fname.c_str(), "r");
371 if (fp)
372 {
373 rtn = x11_detect_VRAM_kb_fp(fp, ": Memory: ");
374 fclose(fp);
375 }
376 }
369 } 377 }
370 } 378 }
371 } 379 }
@@ -421,7 +429,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
421 if (SDL_Init(SDL_INIT_VIDEO) < 0) 429 if (SDL_Init(SDL_INIT_VIDEO) < 0)
422 { 430 {
423 llinfos << "sdl_init() failed! " << SDL_GetError() << llendl; 431 llinfos << "sdl_init() failed! " << SDL_GetError() << llendl;
424 setupFailure("window creation error", "error", OSMB_OK); 432 setupFailure("sdl_init() failure, window creation error", "error", OSMB_OK);
425 return false; 433 return false;
426 } 434 }
427 435
@@ -442,7 +450,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
442 if (!videoInfo) 450 if (!videoInfo)
443 { 451 {
444 llinfos << "SDL_GetVideoInfo() failed! " << SDL_GetError() << llendl; 452 llinfos << "SDL_GetVideoInfo() failed! " << SDL_GetError() << llendl;
445 setupFailure("Window creation error", "Error", OSMB_OK); 453 setupFailure("SDL_GetVideoInfo() failed, Window creation error", "Error", OSMB_OK);
446 return FALSE; 454 return FALSE;
447 } 455 }
448 456
@@ -498,7 +506,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
498 // *FIX: try to toggle vsync here? 506 // *FIX: try to toggle vsync here?
499 507
500 mFullscreen = fullscreen; 508 mFullscreen = fullscreen;
501 was_fullscreen = fullscreen;
502 509
503 int sdlflags = SDL_OPENGL | SDL_RESIZABLE | SDL_ANYFORMAT; 510 int sdlflags = SDL_OPENGL | SDL_RESIZABLE | SDL_ANYFORMAT;
504 511
@@ -574,7 +581,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
574 if (mWindow) 581 if (mWindow)
575 { 582 {
576 mFullscreen = TRUE; 583 mFullscreen = TRUE;
577 was_fullscreen = TRUE;
578 mFullscreenWidth = mWindow->w; 584 mFullscreenWidth = mWindow->w;
579 mFullscreenHeight = mWindow->h; 585 mFullscreenHeight = mWindow->h;
580 mFullscreenBits = mWindow->format->BitsPerPixel; 586 mFullscreenBits = mWindow->format->BitsPerPixel;
@@ -591,7 +597,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
591 llwarns << "createContext: fullscreen creation failure. SDL: " << SDL_GetError() << llendl; 597 llwarns << "createContext: fullscreen creation failure. SDL: " << SDL_GetError() << llendl;
592 // No fullscreen support 598 // No fullscreen support
593 mFullscreen = FALSE; 599 mFullscreen = FALSE;
594 was_fullscreen = FALSE;
595 mFullscreenWidth = -1; 600 mFullscreenWidth = -1;
596 mFullscreenHeight = -1; 601 mFullscreenHeight = -1;
597 mFullscreenBits = -1; 602 mFullscreenBits = -1;
@@ -673,8 +678,8 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
673 // fixme: actually, it's REALLY important for picking that we get at 678 // fixme: actually, it's REALLY important for picking that we get at
674 // least 8 bits each of red,green,blue. Alpha we can be a bit more 679 // least 8 bits each of red,green,blue. Alpha we can be a bit more
675 // relaxed about if we have to. 680 // relaxed about if we have to.
676#if LL_SOLARIS 681#if LL_SOLARIS && defined(__sparc)
677#error && defined(__sparc) 682// again the __sparc required because Xsun support, 32bit are very pricey on SPARC
678 if(colorBits < 24) //HACK: on SPARC allow 24-bit color 683 if(colorBits < 24) //HACK: on SPARC allow 24-bit color
679#else 684#else
680 if (colorBits < 32) 685 if (colorBits < 32)
@@ -682,8 +687,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
682 { 687 {
683 close(); 688 close();
684 setupFailure( 689 setupFailure(
685#if LL_SOLARIS 690#if LL_SOLARIS && defined(__sparc)
686#error && defined(__sparc)
687 "Second Life requires at least 24-bit color on SPARC to run in a window.\n" 691 "Second Life requires at least 24-bit color on SPARC to run in a window.\n"
688 "Please use fbconfig to set your default color depth to 24 bits.\n" 692 "Please use fbconfig to set your default color depth to 24 bits.\n"
689 "You may also need to adjust the X11 setting in SMF. To do so use\n" 693 "You may also need to adjust the X11 setting in SMF. To do so use\n"
@@ -927,7 +931,6 @@ BOOL LLWindowSDL::getSize(LLCoordScreen *size)
927 return (TRUE); 931 return (TRUE);
928 } 932 }
929 933
930 llwarns << "LLWindowSDL::getPosition(): no window and not fullscreen!" << llendl;
931 return (FALSE); 934 return (FALSE);
932} 935}
933 936
@@ -940,7 +943,6 @@ BOOL LLWindowSDL::getSize(LLCoordWindow *size)
940 return (TRUE); 943 return (TRUE);
941 } 944 }
942 945
943 llwarns << "LLWindowSDL::getPosition(): no window and not fullscreen!" << llendl;
944 return (FALSE); 946 return (FALSE);
945} 947}
946 948
@@ -959,11 +961,18 @@ BOOL LLWindowSDL::setSize(const LLCoordScreen size)
959{ 961{
960 if(mWindow) 962 if(mWindow)
961 { 963 {
962 // *FIX: (???) 964 // Push a resize event onto SDL's queue - we'll handle it
963 //SizeWindow(mWindow, size.mX, size.mY, true); 965 // when it comes out again.
964 } 966 SDL_Event event;
967 event.type = SDL_VIDEORESIZE;
968 event.resize.w = size.mX;
969 event.resize.h = size.mY;
970 SDL_PushEvent(&event); // copied into queue
965 971
966 return TRUE; 972 return TRUE;
973 }
974
975 return FALSE;
967} 976}
968 977
969void LLWindowSDL::swapBuffers() 978void LLWindowSDL::swapBuffers()
@@ -1013,11 +1022,7 @@ BOOL LLWindowSDL::isCursorHidden()
1013// Constrains the mouse to the window. 1022// Constrains the mouse to the window.
1014void LLWindowSDL::setMouseClipping( BOOL b ) 1023void LLWindowSDL::setMouseClipping( BOOL b )
1015{ 1024{
1016 //llinfos << "LLWindowSDL::setMouseClipping " << b << llendl;
1017 // Just stash the requested state. We'll simulate this when the cursor is hidden by decoupling.
1018 mIsMouseClipping = b;
1019 //SDL_WM_GrabInput(b ? SDL_GRAB_ON : SDL_GRAB_OFF); 1025 //SDL_WM_GrabInput(b ? SDL_GRAB_ON : SDL_GRAB_OFF);
1020 adjustCursorDecouple();
1021} 1026}
1022 1027
1023BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position) 1028BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position)
@@ -1032,10 +1037,10 @@ BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position)
1032 1037
1033 //llinfos << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << llendl; 1038 //llinfos << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << llendl;
1034 1039
1035 SDL_WarpMouse(screen_pos.mX, screen_pos.mY); 1040 // do the actual forced cursor move.
1036 1041 SDL_WarpMouse(screen_pos.mX, screen_pos.mY);
1037 // Under certain circumstances, this will trigger us to decouple the cursor. 1042
1038 adjustCursorDecouple(true); 1043 //llinfos << llformat("llcw %d,%d -> scr %d,%d", position.mX, position.mY, screen_pos.mX, screen_pos.mY) << llendl;
1039 1044
1040 return result; 1045 return result;
1041} 1046}
@@ -1055,33 +1060,6 @@ BOOL LLWindowSDL::getCursorPosition(LLCoordWindow *position)
1055 return convertCoords(screen_pos, position); 1060 return convertCoords(screen_pos, position);
1056} 1061}
1057 1062
1058void LLWindowSDL::adjustCursorDecouple(bool warpingMouse)
1059{
1060 if(mIsMouseClipping && mCursorHidden)
1061 {
1062 if(warpingMouse)
1063 {
1064 // The cursor should be decoupled. Make sure it is.
1065 if(!mCursorDecoupled)
1066 {
1067 // llinfos << "adjustCursorDecouple: decoupling cursor" << llendl;
1068 //CGAssociateMouseAndMouseCursorPosition(false);
1069 mCursorDecoupled = true;
1070 mCursorIgnoreNextDelta = TRUE;
1071 }
1072 }
1073 }
1074 else
1075 {
1076 // The cursor should not be decoupled. Make sure it isn't.
1077 if(mCursorDecoupled)
1078 {
1079 // llinfos << "adjustCursorDecouple: recoupling cursor" << llendl;
1080 //CGAssociateMouseAndMouseCursorPosition(true);
1081 mCursorDecoupled = false;
1082 }
1083 }
1084}
1085 1063
1086F32 LLWindowSDL::getNativeAspectRatio() 1064F32 LLWindowSDL::getNativeAspectRatio()
1087{ 1065{
@@ -1138,24 +1116,28 @@ F32 LLWindowSDL::getPixelAspectRatio()
1138} 1116}
1139 1117
1140 1118
1141// some of this stuff is to support 'temporarily windowed' mode so that 1119// This is to support 'temporarily windowed' mode so that
1142// dialogs are still usable in fullscreen. HOWEVER! - it's not enabled/working 1120// dialogs are still usable in fullscreen.
1143// yet.
1144static LLCoordScreen old_size;
1145static BOOL old_fullscreen;
1146void LLWindowSDL::beforeDialog() 1121void LLWindowSDL::beforeDialog()
1147{ 1122{
1123 bool running_x11 = false;
1124#if LL_X11
1125 running_x11 = (mSDL_XWindowID != None);
1126#endif //LL_X11
1127
1148 llinfos << "LLWindowSDL::beforeDialog()" << llendl; 1128 llinfos << "LLWindowSDL::beforeDialog()" << llendl;
1149 1129
1150 if (SDLReallyCaptureInput(FALSE) // must ungrab input so popup works! 1130 if (SDLReallyCaptureInput(FALSE)) // must ungrab input so popup works!
1151 && getSize(&old_size))
1152 { 1131 {
1153 old_fullscreen = was_fullscreen; 1132 if (mFullscreen)
1154
1155 if (old_fullscreen)
1156 { 1133 {
1157 // NOT YET WORKING 1134 // need to temporarily go non-fullscreen; bless SDL
1158 //switchContext(FALSE, old_size, TRUE); 1135 // for providing a SDL_WM_ToggleFullScreen() - though
1136 // it only works in X11
1137 if (running_x11 && mWindow)
1138 {
1139 SDL_WM_ToggleFullScreen(mWindow);
1140 }
1159 } 1141 }
1160 } 1142 }
1161 1143
@@ -1181,17 +1163,24 @@ void LLWindowSDL::beforeDialog()
1181 1163
1182void LLWindowSDL::afterDialog() 1164void LLWindowSDL::afterDialog()
1183{ 1165{
1166 bool running_x11 = false;
1167#if LL_X11
1168 running_x11 = (mSDL_XWindowID != None);
1169#endif //LL_X11
1170
1184 llinfos << "LLWindowSDL::afterDialog()" << llendl; 1171 llinfos << "LLWindowSDL::afterDialog()" << llendl;
1185 1172
1186 maybe_unlock_display(); 1173 maybe_unlock_display();
1187 1174
1188 if (old_fullscreen && !was_fullscreen) 1175 if (mFullscreen)
1189 { 1176 {
1190 // *FIX: NOT YET WORKING (see below) 1177 // need to restore fullscreen mode after dialog - only works
1191 //switchContext(TRUE, old_size, TRUE); 1178 // in X11
1179 if (running_x11 && mWindow)
1180 {
1181 SDL_WM_ToggleFullScreen(mWindow);
1182 }
1192 } 1183 }
1193 // *FIX: we need to restore the GL context using
1194 // LLViewerWindow::restoreGL() - but how??
1195} 1184}
1196 1185
1197 1186
@@ -1358,7 +1347,6 @@ BOOL LLWindowSDL::copyTextToPrimary(const LLWString &s)
1358{ 1347{
1359 return FALSE; // unsupported 1348 return FALSE; // unsupported
1360} 1349}
1361
1362#endif // LL_GTK 1350#endif // LL_GTK
1363 1351
1364LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_resolutions) 1352LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_resolutions)
@@ -1559,7 +1547,7 @@ U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain)
1559 /* part of the fix for SL-13243: Some popular window managers like 1547 /* part of the fix for SL-13243: Some popular window managers like
1560 to totally eat alt-drag for the purposes of moving windows. We 1548 to totally eat alt-drag for the purposes of moving windows. We
1561 spoil their day by acquiring the exclusive X11 mouse lock for as 1549 spoil their day by acquiring the exclusive X11 mouse lock for as
1562 long as LALT is held down, so the window manager can't easily 1550 long as ALT is held down, so the window manager can't easily
1563 see what's happening. Tested successfully with Metacity. 1551 see what's happening. Tested successfully with Metacity.
1564 And... do the same with CTRL, for other darn WMs. We don't 1552 And... do the same with CTRL, for other darn WMs. We don't
1565 care about other metakeys as SL doesn't use them with dragging 1553 care about other metakeys as SL doesn't use them with dragging
@@ -1574,10 +1562,12 @@ U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain)
1574 { 1562 {
1575 case SDLK_LALT: 1563 case SDLK_LALT:
1576 mask = 1U << 0; break; 1564 mask = 1U << 0; break;
1577 case SDLK_LCTRL: 1565 case SDLK_RALT:
1578 mask = 1U << 1; break; 1566 mask = 1U << 1; break;
1579 case SDLK_RCTRL: 1567 case SDLK_LCTRL:
1580 mask = 1U << 2; break; 1568 mask = 1U << 2; break;
1569 case SDLK_RCTRL:
1570 mask = 1U << 3; break;
1581 default: 1571 default:
1582 break; 1572 break;
1583 } 1573 }
@@ -1596,7 +1586,7 @@ U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain)
1596// virtual 1586// virtual
1597void LLWindowSDL::processMiscNativeEvents() 1587void LLWindowSDL::processMiscNativeEvents()
1598{ 1588{
1599#if LL_GTK && (LL_LLMOZLIB_ENABLED || LL_DBUS_ENABLED) 1589#if LL_GTK
1600 // Pump GTK events to avoid starvation for: 1590 // Pump GTK events to avoid starvation for:
1601 // * Embedded Gecko 1591 // * Embedded Gecko
1602 // * DBUS servicing 1592 // * DBUS servicing
@@ -1623,7 +1613,7 @@ void LLWindowSDL::processMiscNativeEvents()
1623 1613
1624 setlocale(LC_ALL, saved_locale.c_str() ); 1614 setlocale(LC_ALL, saved_locale.c_str() );
1625 } 1615 }
1626#endif // LL_GTK && (LL_LLMOZLIB_ENABLED || LL_DBUS_ENABLED) 1616#endif // LL_GTK
1627} 1617}
1628 1618
1629void LLWindowSDL::gatherInput() 1619void LLWindowSDL::gatherInput()
@@ -1717,10 +1707,9 @@ void LLWindowSDL::gatherInput()
1717 mCallbacks->handleMouseDown(this, openGlCoord, mask); 1707 mCallbacks->handleMouseDown(this, openGlCoord, mask);
1718 } 1708 }
1719 1709
1720 else if (event.button.button == SDL_BUTTON_RIGHT) // right ... yes, it's 3, not 2, in SDL... 1710 else if (event.button.button == SDL_BUTTON_RIGHT) // right
1721 { 1711 {
1722 // right double click isn't handled right now in Second Life ... if (isDoubleClick) 1712 mCallbacks->handleRightMouseDown(this, openGlCoord, mask);
1723 mCallbacks->handleRightMouseDown(this, openGlCoord, mask);
1724 } 1713 }
1725 1714
1726 else if (event.button.button == SDL_BUTTON_MIDDLE) // middle 1715 else if (event.button.button == SDL_BUTTON_MIDDLE) // middle
@@ -1743,13 +1732,11 @@ void LLWindowSDL::gatherInput()
1743 MASK mask = gKeyboard->currentMask(TRUE); 1732 MASK mask = gKeyboard->currentMask(TRUE);
1744 1733
1745 if (event.button.button == SDL_BUTTON_LEFT) // left 1734 if (event.button.button == SDL_BUTTON_LEFT) // left
1746 mCallbacks->handleMouseUp(this, openGlCoord, mask); 1735 mCallbacks->handleMouseUp(this, openGlCoord, mask);
1747 else if (event.button.button == SDL_BUTTON_RIGHT) // right ... yes, it's 3, not 2, in SDL... 1736 else if (event.button.button == SDL_BUTTON_RIGHT) // right
1748 mCallbacks->handleRightMouseUp(this, openGlCoord, mask); 1737 mCallbacks->handleRightMouseUp(this, openGlCoord, mask);
1749 else if (event.button.button == SDL_BUTTON_MIDDLE) // middle 1738 else if (event.button.button == SDL_BUTTON_MIDDLE) // middle
1750 {
1751 mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask); 1739 mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask);
1752 }
1753 // don't handle mousewheel here... 1740 // don't handle mousewheel here...
1754 1741
1755 break; 1742 break;
@@ -1793,12 +1780,12 @@ void LLWindowSDL::gatherInput()
1793 // which confuses the focus code [SL-24071]. 1780 // which confuses the focus code [SL-24071].
1794 if (event.active.gain != mHaveInputFocus) 1781 if (event.active.gain != mHaveInputFocus)
1795 { 1782 {
1796 if (event.active.gain) 1783 mHaveInputFocus = !!event.active.gain;
1784
1785 if (mHaveInputFocus)
1797 mCallbacks->handleFocus(this); 1786 mCallbacks->handleFocus(this);
1798 else 1787 else
1799 mCallbacks->handleFocusLost(this); 1788 mCallbacks->handleFocusLost(this);
1800
1801 mHaveInputFocus = !!event.active.gain;
1802 } 1789 }
1803 } 1790 }
1804 if (event.active.state & SDL_APPACTIVE) 1791 if (event.active.state & SDL_APPACTIVE)
@@ -1806,10 +1793,10 @@ void LLWindowSDL::gatherInput()
1806 // Change in iconification/minimization state. 1793 // Change in iconification/minimization state.
1807 if ((!event.active.gain) != mIsMinimized) 1794 if ((!event.active.gain) != mIsMinimized)
1808 { 1795 {
1809 mCallbacks->handleActivate(this, !!event.active.gain);
1810 llinfos << "SDL deiconification state switched to " << BOOL(event.active.gain) << llendl;
1811
1812 mIsMinimized = (!event.active.gain); 1796 mIsMinimized = (!event.active.gain);
1797
1798 mCallbacks->handleActivate(this, !mIsMinimized);
1799 llinfos << "SDL deiconification state switched to " << BOOL(event.active.gain) << llendl;
1813 } 1800 }
1814 else 1801 else
1815 { 1802 {
@@ -2057,8 +2044,6 @@ void LLWindowSDL::hideCursor()
2057 { 2044 {
2058 // llinfos << "hideCursor: already hidden" << llendl; 2045 // llinfos << "hideCursor: already hidden" << llendl;
2059 } 2046 }
2060
2061 adjustCursorDecouple();
2062} 2047}
2063 2048
2064void LLWindowSDL::showCursor() 2049void LLWindowSDL::showCursor()
@@ -2074,8 +2059,6 @@ void LLWindowSDL::showCursor()
2074 { 2059 {
2075 // llinfos << "showCursor: already visible" << llendl; 2060 // llinfos << "showCursor: already visible" << llendl;
2076 } 2061 }
2077
2078 adjustCursorDecouple();
2079} 2062}
2080 2063
2081void LLWindowSDL::showCursorFromMouseMove() 2064void LLWindowSDL::showCursorFromMouseMove()
@@ -2141,10 +2124,7 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ
2141 if(gWindowImplementation != NULL) 2124 if(gWindowImplementation != NULL)
2142 gWindowImplementation->beforeDialog(); 2125 gWindowImplementation->beforeDialog();
2143 2126
2144 if (LLWindowSDL::ll_try_gtk_init() 2127 if (LLWindowSDL::ll_try_gtk_init())
2145 // We can NOT expect to combine GTK and SDL's aggressive fullscreen
2146 && ((NULL==gWindowImplementation) || (!was_fullscreen))
2147 )
2148 { 2128 {
2149 GtkWidget *win = NULL; 2129 GtkWidget *win = NULL;
2150 2130
@@ -2248,10 +2228,7 @@ BOOL LLWindowSDL::dialog_color_picker ( F32 *r, F32 *g, F32 *b)
2248 2228
2249 beforeDialog(); 2229 beforeDialog();
2250 2230
2251 if (ll_try_gtk_init() 2231 if (ll_try_gtk_init())
2252 // We can NOT expect to combine GTK and SDL's aggressive fullscreen
2253 && !was_fullscreen
2254 )
2255 { 2232 {
2256 GtkWidget *win = NULL; 2233 GtkWidget *win = NULL;
2257 2234
@@ -2434,7 +2411,7 @@ void LLWindowSDL::bringToFront()
2434} 2411}
2435 2412
2436//static 2413//static
2437std::string LLWindowSDL::getFontListSans() 2414std::vector<std::string> LLWindowSDL::getDynamicFallbackFontList()
2438{ 2415{
2439 // Use libfontconfig to find us a nice ordered list of fallback fonts 2416 // Use libfontconfig to find us a nice ordered list of fallback fonts
2440 // specific to this system. 2417 // specific to this system.
@@ -2451,7 +2428,7 @@ std::string LLWindowSDL::getFontListSans()
2451 // renderable range if for some reason our FreeType actually fails 2428 // renderable range if for some reason our FreeType actually fails
2452 // to use some of the fonts we want it to. 2429 // to use some of the fonts we want it to.
2453 const bool elide_unicode_coverage = true; 2430 const bool elide_unicode_coverage = true;
2454 std::string rtn; 2431 std::vector<std::string> rtns;
2455 FcFontSet *fs = NULL; 2432 FcFontSet *fs = NULL;
2456 FcPattern *sortpat = NULL; 2433 FcPattern *sortpat = NULL;
2457 int font_count = 0; 2434 int font_count = 0;
@@ -2485,7 +2462,8 @@ std::string LLWindowSDL::getFontListSans()
2485 if (!FcInit()) 2462 if (!FcInit())
2486 { 2463 {
2487 llwarns << "FontConfig failed to initialize." << llendl; 2464 llwarns << "FontConfig failed to initialize." << llendl;
2488 return final_fallback; 2465 rtns.push_back(final_fallback);
2466 return rtns;
2489 } 2467 }
2490 2468
2491 sortpat = FcNameParse((FcChar8*) sort_order.c_str()); 2469 sortpat = FcNameParse((FcChar8*) sort_order.c_str());
@@ -2510,17 +2488,24 @@ std::string LLWindowSDL::getFontListSans()
2510 &filename) 2488 &filename)
2511 && filename) 2489 && filename)
2512 { 2490 {
2513 rtn += std::string((const char*)filename)+";"; 2491 rtns.push_back(std::string((const char*)filename));
2514 ++font_count; 2492 ++font_count;
2515 } 2493 }
2516 } 2494 }
2517 FcFontSetDestroy (fs); 2495 FcFontSetDestroy (fs);
2518 } 2496 }
2519 2497
2520 lldebugs << "Using font list: " << rtn << llendl; 2498 lldebugs << "Using font list: " << llendl;
2499 for (std::vector<std::string>::iterator it = rtns.begin();
2500 it != rtns.end();
2501 ++it)
2502 {
2503 lldebugs << " file: " << *it << llendl;
2504 }
2521 llinfos << "Using " << font_count << " system font(s)." << llendl; 2505 llinfos << "Using " << font_count << " system font(s)." << llendl;
2522 2506
2523 return rtn + final_fallback; 2507 rtns.push_back(final_fallback);
2508 return rtns;
2524} 2509}
2525 2510
2526#endif // LL_SDL 2511#endif // LL_SDL