aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llwindow/llwindowsdl.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llwindow/llwindowsdl.cpp58
1 files changed, 45 insertions, 13 deletions
diff --git a/linden/indra/llwindow/llwindowsdl.cpp b/linden/indra/llwindow/llwindowsdl.cpp
index f7b4071..a1cdeb3 100644
--- a/linden/indra/llwindow/llwindowsdl.cpp
+++ b/linden/indra/llwindow/llwindowsdl.cpp
@@ -296,9 +296,9 @@ static SDL_Surface *Load_BMP_Resource(const char *basename)
296#if LL_X11 296#if LL_X11
297// This is an XFree86/XOrg-specific hack for detecting the amount of Video RAM 297// This is an XFree86/XOrg-specific hack for detecting the amount of Video RAM
298// on this machine. It works by searching /var/log/var/log/Xorg.?.log or 298// on this machine. It works by searching /var/log/var/log/Xorg.?.log or
299// /var/log/XFree86.?.log for a ': VideoRAM: (%d+) kB' regex, where '?' is 299// /var/log/XFree86.?.log for a ': (VideoRAM|Memory): (%d+) kB' regex, where
300// the X11 display number derived from $DISPLAY 300// '?' is the X11 display number derived from $DISPLAY
301static int x11_detect_VRAM_kb_fp(FILE *fp) 301static int x11_detect_VRAM_kb_fp(FILE *fp, const char *prefix_str)
302{ 302{
303 const int line_buf_size = 1000; 303 const int line_buf_size = 1000;
304 char line_buf[line_buf_size]; 304 char line_buf[line_buf_size];
@@ -310,7 +310,7 @@ static int x11_detect_VRAM_kb_fp(FILE *fp)
310 // favourite regex implementation - libboost_regex - is 310 // favourite regex implementation - libboost_regex - is
311 // quite a heavy and troublesome dependency for the client, so 311 // quite a heavy and troublesome dependency for the client, so
312 // it seems a shame to introduce it for such a simple task. 312 // it seems a shame to introduce it for such a simple task.
313 const char part1_template[] = ": VideoRAM: "; 313 const char *part1_template = prefix_str;
314 const char part2_template[] = " kB"; 314 const char part2_template[] = " kB";
315 char *part1 = strstr(line_buf, part1_template); 315 char *part1 = strstr(line_buf, part1_template);
316 if (part1) // found start of matching line 316 if (part1) // found start of matching line
@@ -325,7 +325,6 @@ static int x11_detect_VRAM_kb_fp(FILE *fp)
325 int rtn = 0; 325 int rtn = 0;
326 for (; part1 < part2; ++part1) 326 for (; part1 < part2; ++part1)
327 { 327 {
328 //lldebugs << "kB" << *part1 << llendl;
329 if (*part1 < '0' || *part1 > '9') 328 if (*part1 < '0' || *part1 > '9')
330 { 329 {
331 // unexpected char, abort parse 330 // unexpected char, abort parse
@@ -345,6 +344,7 @@ static int x11_detect_VRAM_kb_fp(FILE *fp)
345 } 344 }
346 return 0; // 'could not detect' 345 return 0; // 'could not detect'
347} 346}
347
348static int x11_detect_VRAM_kb() 348static int x11_detect_VRAM_kb()
349{ 349{
350 std::string x_log_location("/var/log/"); 350 std::string x_log_location("/var/log/");
@@ -363,7 +363,7 @@ static int x11_detect_VRAM_kb()
363 // *TODO: we could be smarter and see which of Xorg/XFree86 has the 363 // *TODO: we could be smarter and see which of Xorg/XFree86 has the
364 // freshest time-stamp. 364 // freshest time-stamp.
365 365
366 // Try XOrg log first 366 // Try Xorg log first
367 fname = x_log_location; 367 fname = x_log_location;
368 fname += "Xorg."; 368 fname += "Xorg.";
369 fname += ('0' + display_num); 369 fname += ('0' + display_num);
@@ -371,12 +371,25 @@ static int x11_detect_VRAM_kb()
371 fp = fopen(fname.c_str(), "r"); 371 fp = fopen(fname.c_str(), "r");
372 if (fp) 372 if (fp)
373 { 373 {
374 rtn = x11_detect_VRAM_kb_fp(fp); 374 llinfos << "Looking in " << fname
375 << " for VRAM info..." << llendl;
376 rtn = x11_detect_VRAM_kb_fp(fp, ": VideoRAM: ");
375 fclose(fp); 377 fclose(fp);
378 if (0 == rtn)
379 {
380 fp = fopen(fname.c_str(), "r");
381 if (fp)
382 {
383 rtn = x11_detect_VRAM_kb_fp(fp, ": Memory: ");
384 fclose(fp);
385 }
386 }
376 } 387 }
377 // Try old XFree86 log otherwise 388 else
378 if (rtn == 0)
379 { 389 {
390 llinfos << "Could not open " << fname
391 << " - skipped." << llendl;
392 // Try old XFree86 log otherwise
380 fname = x_log_location; 393 fname = x_log_location;
381 fname += "XFree86."; 394 fname += "XFree86.";
382 fname += ('0' + display_num); 395 fname += ('0' + display_num);
@@ -384,8 +397,24 @@ static int x11_detect_VRAM_kb()
384 fp = fopen(fname.c_str(), "r"); 397 fp = fopen(fname.c_str(), "r");
385 if (fp) 398 if (fp)
386 { 399 {
387 rtn = x11_detect_VRAM_kb_fp(fp); 400 llinfos << "Looking in " << fname
401 << " for VRAM info..." << llendl;
402 rtn = x11_detect_VRAM_kb_fp(fp, ": VideoRAM: ");
388 fclose(fp); 403 fclose(fp);
404 if (0 == rtn)
405 {
406 fp = fopen(fname.c_str(), "r");
407 if (fp)
408 {
409 rtn = x11_detect_VRAM_kb_fp(fp, ": Memory: ");
410 fclose(fp);
411 }
412 }
413 }
414 else
415 {
416 llinfos << "Could not open " << fname
417 << " - skipped." << llendl;
389 } 418 }
390 } 419 }
391 return rtn; 420 return rtn;
@@ -2023,7 +2052,9 @@ void LLWindowSDL::gatherInput()
2023 } 2052 }
2024 2053
2025 else if (event.button.button == SDL_BUTTON_MIDDLE) // middle 2054 else if (event.button.button == SDL_BUTTON_MIDDLE) // middle
2026 ; // Middle mouse isn't handled right now in Second Life ... mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask); 2055 {
2056 mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask);
2057 }
2027 else if (event.button.button == 4) // mousewheel up...thanks to X11 for making SDL consider these "buttons". 2058 else if (event.button.button == 4) // mousewheel up...thanks to X11 for making SDL consider these "buttons".
2028 mCallbacks->handleScrollWheel(this, -1); 2059 mCallbacks->handleScrollWheel(this, -1);
2029 else if (event.button.button == 5) // mousewheel down...thanks to X11 for making SDL consider these "buttons". 2060 else if (event.button.button == 5) // mousewheel down...thanks to X11 for making SDL consider these "buttons".
@@ -2044,8 +2075,9 @@ void LLWindowSDL::gatherInput()
2044 else if (event.button.button == SDL_BUTTON_RIGHT) // right ... yes, it's 3, not 2, in SDL... 2075 else if (event.button.button == SDL_BUTTON_RIGHT) // right ... yes, it's 3, not 2, in SDL...
2045 mCallbacks->handleRightMouseUp(this, openGlCoord, mask); 2076 mCallbacks->handleRightMouseUp(this, openGlCoord, mask);
2046 else if (event.button.button == SDL_BUTTON_MIDDLE) // middle 2077 else if (event.button.button == SDL_BUTTON_MIDDLE) // middle
2047 ; // UNUSED IN SECOND LIFE RIGHT NOW mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask); 2078 {
2048 2079 mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask);
2080 }
2049 // don't handle mousewheel here... 2081 // don't handle mousewheel here...
2050 2082
2051 break; 2083 break;