aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llwindow/llwindowsdl.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-12-01 17:39:58 -0600
committerJacek Antonelli2008-12-01 17:40:06 -0600
commit7abecb48babe6a6f09bf6692ba55076546cfced9 (patch)
tree8d18a88513fb97adf32c10aae78f4be1984942db /linden/indra/llwindow/llwindowsdl.cpp
parentSecond Life viewer sources 1.21.6 (diff)
downloadmeta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.zip
meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.gz
meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.bz2
meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.xz
Second Life viewer sources 1.22.0-RC
Diffstat (limited to 'linden/indra/llwindow/llwindowsdl.cpp')
-rw-r--r--linden/indra/llwindow/llwindowsdl.cpp65
1 files changed, 37 insertions, 28 deletions
diff --git a/linden/indra/llwindow/llwindowsdl.cpp b/linden/indra/llwindow/llwindowsdl.cpp
index e5d15c4..361126d 100644
--- a/linden/indra/llwindow/llwindowsdl.cpp
+++ b/linden/indra/llwindow/llwindowsdl.cpp
@@ -104,7 +104,8 @@ void maybe_unlock_display(void)
104 104
105#if LL_GTK 105#if LL_GTK
106// Lazily initialize and check the runtime GTK version for goodness. 106// Lazily initialize and check the runtime GTK version for goodness.
107BOOL ll_try_gtk_init(void) 107// static
108bool LLWindowSDL::ll_try_gtk_init(void)
108{ 109{
109 static BOOL done_gtk_diag = FALSE; 110 static BOOL done_gtk_diag = FALSE;
110 static BOOL gtk_is_good = FALSE; 111 static BOOL gtk_is_good = FALSE;
@@ -166,7 +167,8 @@ BOOL ll_try_gtk_init(void)
166 167
167 168
168#if LL_X11 169#if LL_X11
169Window get_SDL_XWindowID(void) 170// static
171Window LLWindowSDL::get_SDL_XWindowID(void)
170{ 172{
171 if (gWindowImplementation) { 173 if (gWindowImplementation) {
172 return gWindowImplementation->mSDL_XWindowID; 174 return gWindowImplementation->mSDL_XWindowID;
@@ -174,7 +176,8 @@ Window get_SDL_XWindowID(void)
174 return None; 176 return None;
175} 177}
176 178
177Display* get_SDL_Display(void) 179//static
180Display* LLWindowSDL::get_SDL_Display(void)
178{ 181{
179 if (gWindowImplementation) { 182 if (gWindowImplementation) {
180 return gWindowImplementation->mSDL_Display; 183 return gWindowImplementation->mSDL_Display;
@@ -1235,7 +1238,7 @@ typedef Atom x11clipboard_type;
1235 */ 1238 */
1236static x11clipboard_type get_x11_readwrite_clipboard_type(void) 1239static x11clipboard_type get_x11_readwrite_clipboard_type(void)
1237{ 1240{
1238 return XInternAtom(get_SDL_Display(), "CLIPBOARD", False); 1241 return XInternAtom(LLWindowSDL::get_SDL_Display(), "CLIPBOARD", False);
1239} 1242}
1240 1243
1241static x11clipboard_type get_x11_write_clipboard_type(void) 1244static x11clipboard_type get_x11_write_clipboard_type(void)
@@ -1248,18 +1251,18 @@ static x11clipboard_type get_x11_write_clipboard_type(void)
1248 storage because their use isn't really defined for holding UTF8. */ 1251 storage because their use isn't really defined for holding UTF8. */
1249static x11clipboard_type get_x11_cutbuffer_clipboard_type(void) 1252static x11clipboard_type get_x11_cutbuffer_clipboard_type(void)
1250{ 1253{
1251 return XInternAtom(get_SDL_Display(), "SECONDLIFE_CUTBUFFER", False); 1254 return XInternAtom(LLWindowSDL::get_SDL_Display(), "SECONDLIFE_CUTBUFFER", False);
1252} 1255}
1253 1256
1254/* Some X11 atom-generators */ 1257/* Some X11 atom-generators */
1255static Atom get_x11_targets_atom(void) 1258static Atom get_x11_targets_atom(void)
1256{ 1259{
1257 return XInternAtom(get_SDL_Display(), "TARGETS", False); 1260 return XInternAtom(LLWindowSDL::get_SDL_Display(), "TARGETS", False);
1258} 1261}
1259 1262
1260static Atom get_x11_text_atom(void) 1263static Atom get_x11_text_atom(void)
1261{ 1264{
1262 return XInternAtom(get_SDL_Display(), "TEXT", False); 1265 return XInternAtom(LLWindowSDL::get_SDL_Display(), "TEXT", False);
1263} 1266}
1264 1267
1265/* These defines, and convert_data/convert_x11clipboard, 1268/* These defines, and convert_data/convert_x11clipboard,
@@ -1544,7 +1547,7 @@ int clipboard_filter_callback(const SDL_Event *event)
1544 sevent.xselection.property = None; 1547 sevent.xselection.property = None;
1545 sevent.xselection.requestor = req->requestor; 1548 sevent.xselection.requestor = req->requestor;
1546 sevent.xselection.time = req->time; 1549 sevent.xselection.time = req->time;
1547 if ( XGetWindowProperty(get_SDL_Display(), DefaultRootWindow(get_SDL_Display()), 1550 if ( XGetWindowProperty(LLWindowSDL::get_SDL_Display(), DefaultRootWindow(LLWindowSDL::get_SDL_Display()),
1548 get_x11_cutbuffer_clipboard_type(), 0, INT_MAX/4, False, req->target, 1551 get_x11_cutbuffer_clipboard_type(), 0, INT_MAX/4, False, req->target,
1549 &sevent.xselection.target, &seln_format, 1552 &sevent.xselection.target, &seln_format,
1550 &nbytes, &overflow, &seln_data) == Success ) 1553 &nbytes, &overflow, &seln_data) == Success )
@@ -1558,7 +1561,7 @@ int clipboard_filter_callback(const SDL_Event *event)
1558 if ( seln_data[nbytes-1] == '\0' ) 1561 if ( seln_data[nbytes-1] == '\0' )
1559 --nbytes; 1562 --nbytes;
1560 } 1563 }
1561 XChangeProperty(get_SDL_Display(), req->requestor, req->property, 1564 XChangeProperty(LLWindowSDL::get_SDL_Display(), req->requestor, req->property,
1562 req->target, seln_format, PropModeReplace, 1565 req->target, seln_format, PropModeReplace,
1563 seln_data, nbytes); 1566 seln_data, nbytes);
1564 sevent.xselection.property = req->property; 1567 sevent.xselection.property = req->property;
@@ -1571,7 +1574,7 @@ int clipboard_filter_callback(const SDL_Event *event)
1571 get_x11_targets_atom() 1574 get_x11_targets_atom()
1572 }; 1575 };
1573 supported[0] = sevent.xselection.target; 1576 supported[0] = sevent.xselection.target;
1574 XChangeProperty(get_SDL_Display(), req->requestor, 1577 XChangeProperty(LLWindowSDL::get_SDL_Display(), req->requestor,
1575 req->property, XA_ATOM, 32, PropModeReplace, 1578 req->property, XA_ATOM, 32, PropModeReplace,
1576 (unsigned char*)supported, 1579 (unsigned char*)supported,
1577 num_supported); 1580 num_supported);
@@ -1584,10 +1587,10 @@ int clipboard_filter_callback(const SDL_Event *event)
1584 XFree(seln_data); 1587 XFree(seln_data);
1585 } 1588 }
1586 int sendret = 1589 int sendret =
1587 XSendEvent(get_SDL_Display(),req->requestor,False,0,&sevent); 1590 XSendEvent(LLWindowSDL::get_SDL_Display(),req->requestor,False,0,&sevent);
1588 if ((sendret==BadValue) || (sendret==BadWindow)) 1591 if ((sendret==BadValue) || (sendret==BadWindow))
1589 llwarns << "Clipboard SendEvent failed" << llendl; 1592 llwarns << "Clipboard SendEvent failed" << llendl;
1590 XSync(get_SDL_Display(), False); 1593 XSync(LLWindowSDL::get_SDL_Display(), False);
1591 } 1594 }
1592 break; 1595 break;
1593 } 1596 }
@@ -1959,17 +1962,14 @@ U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain)
1959 return mGrabbyKeyFlags; 1962 return mGrabbyKeyFlags;
1960} 1963}
1961 1964
1962void LLWindowSDL::gatherInput() 1965// virtual
1966void LLWindowSDL::processMiscNativeEvents()
1963{ 1967{
1964 const Uint32 CLICK_THRESHOLD = 300; // milliseconds 1968#if LL_GTK && (LL_LLMOZLIB_ENABLED || LL_DBUS_ENABLED)
1965 static int leftClick = 0; 1969 // Pump GTK events to avoid starvation for:
1966 static int rightClick = 0; 1970 // * Embedded Gecko
1967 static Uint32 lastLeftDown = 0; 1971 // * DBUS servicing
1968 static Uint32 lastRightDown = 0; 1972 // * Anything else which quietly hooks into the default glib/GTK loop
1969 SDL_Event event;
1970
1971#if LL_GTK && LL_LLMOZLIB_ENABLED
1972 // Pump GTK events so embedded Gecko doesn't starve.
1973 if (ll_try_gtk_init()) 1973 if (ll_try_gtk_init())
1974 { 1974 {
1975 // Yuck, Mozilla's GTK callbacks play with the locale - push/pop 1975 // Yuck, Mozilla's GTK callbacks play with the locale - push/pop
@@ -1992,7 +1992,17 @@ void LLWindowSDL::gatherInput()
1992 1992
1993 setlocale(LC_ALL, saved_locale.c_str() ); 1993 setlocale(LC_ALL, saved_locale.c_str() );
1994 } 1994 }
1995#endif // LL_GTK && LL_LLMOZLIB_ENABLED 1995#endif // LL_GTK && (LL_LLMOZLIB_ENABLED || LL_DBUS_ENABLED)
1996}
1997
1998void LLWindowSDL::gatherInput()
1999{
2000 const Uint32 CLICK_THRESHOLD = 300; // milliseconds
2001 static int leftClick = 0;
2002 static int rightClick = 0;
2003 static Uint32 lastLeftDown = 0;
2004 static Uint32 lastRightDown = 0;
2005 SDL_Event event;
1996 2006
1997 // Handle all outstanding SDL events 2007 // Handle all outstanding SDL events
1998 while (SDL_PollEvent(&event)) 2008 while (SDL_PollEvent(&event))
@@ -2497,12 +2507,10 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ
2497{ 2507{
2498 S32 rtn = OSBTN_CANCEL; 2508 S32 rtn = OSBTN_CANCEL;
2499 2509
2500 ll_try_gtk_init();
2501
2502 if(gWindowImplementation != NULL) 2510 if(gWindowImplementation != NULL)
2503 gWindowImplementation->beforeDialog(); 2511 gWindowImplementation->beforeDialog();
2504 2512
2505 if (ll_try_gtk_init() 2513 if (LLWindowSDL::ll_try_gtk_init()
2506 // We can NOT expect to combine GTK and SDL's aggressive fullscreen 2514 // We can NOT expect to combine GTK and SDL's aggressive fullscreen
2507 && ((NULL==gWindowImplementation) || (!was_fullscreen)) 2515 && ((NULL==gWindowImplementation) || (!was_fullscreen))
2508 ) 2516 )
@@ -2530,7 +2538,8 @@ S32 OSMessageBoxSDL(const std::string& text, const std::string& caption, U32 typ
2530 buttons = GTK_BUTTONS_YES_NO; 2538 buttons = GTK_BUTTONS_YES_NO;
2531 break; 2539 break;
2532 } 2540 }
2533 win = gtk_message_dialog_new(NULL,flags, messagetype, buttons, text.c_str()); 2541 win = gtk_message_dialog_new(NULL, flags, messagetype, buttons, "%s",
2542 text.c_str());
2534 2543
2535# if LL_X11 2544# if LL_X11
2536 // Make GTK tell the window manager to associate this 2545 // Make GTK tell the window manager to associate this
@@ -2754,7 +2763,7 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url)
2754void *LLWindowSDL::getPlatformWindow() 2763void *LLWindowSDL::getPlatformWindow()
2755{ 2764{
2756#if LL_GTK && LL_LLMOZLIB_ENABLED 2765#if LL_GTK && LL_LLMOZLIB_ENABLED
2757 if (ll_try_gtk_init()) 2766 if (LLWindowSDL::ll_try_gtk_init())
2758 { 2767 {
2759 maybe_lock_display(); 2768 maybe_lock_display();
2760 2769