From 089fc07d207c71ce1401e72f09c31ad8c45872e2 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:58 -0500 Subject: Second Life viewer sources 1.17.0.12 --- linden/indra/llwindow/llwindowsdl.cpp | 58 +++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 13 deletions(-) (limited to 'linden/indra/llwindow/llwindowsdl.cpp') 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) #if LL_X11 // This is an XFree86/XOrg-specific hack for detecting the amount of Video RAM // on this machine. It works by searching /var/log/var/log/Xorg.?.log or -// /var/log/XFree86.?.log for a ': VideoRAM: (%d+) kB' regex, where '?' is -// the X11 display number derived from $DISPLAY -static int x11_detect_VRAM_kb_fp(FILE *fp) +// /var/log/XFree86.?.log for a ': (VideoRAM|Memory): (%d+) kB' regex, where +// '?' is the X11 display number derived from $DISPLAY +static int x11_detect_VRAM_kb_fp(FILE *fp, const char *prefix_str) { const int line_buf_size = 1000; char line_buf[line_buf_size]; @@ -310,7 +310,7 @@ static int x11_detect_VRAM_kb_fp(FILE *fp) // favourite regex implementation - libboost_regex - is // quite a heavy and troublesome dependency for the client, so // it seems a shame to introduce it for such a simple task. - const char part1_template[] = ": VideoRAM: "; + const char *part1_template = prefix_str; const char part2_template[] = " kB"; char *part1 = strstr(line_buf, part1_template); if (part1) // found start of matching line @@ -325,7 +325,6 @@ static int x11_detect_VRAM_kb_fp(FILE *fp) int rtn = 0; for (; part1 < part2; ++part1) { - //lldebugs << "kB" << *part1 << llendl; if (*part1 < '0' || *part1 > '9') { // unexpected char, abort parse @@ -345,6 +344,7 @@ static int x11_detect_VRAM_kb_fp(FILE *fp) } return 0; // 'could not detect' } + static int x11_detect_VRAM_kb() { std::string x_log_location("/var/log/"); @@ -363,7 +363,7 @@ static int x11_detect_VRAM_kb() // *TODO: we could be smarter and see which of Xorg/XFree86 has the // freshest time-stamp. - // Try XOrg log first + // Try Xorg log first fname = x_log_location; fname += "Xorg."; fname += ('0' + display_num); @@ -371,12 +371,25 @@ static int x11_detect_VRAM_kb() fp = fopen(fname.c_str(), "r"); if (fp) { - rtn = x11_detect_VRAM_kb_fp(fp); + llinfos << "Looking in " << fname + << " for VRAM info..." << llendl; + rtn = x11_detect_VRAM_kb_fp(fp, ": VideoRAM: "); fclose(fp); + if (0 == rtn) + { + fp = fopen(fname.c_str(), "r"); + if (fp) + { + rtn = x11_detect_VRAM_kb_fp(fp, ": Memory: "); + fclose(fp); + } + } } - // Try old XFree86 log otherwise - if (rtn == 0) + else { + llinfos << "Could not open " << fname + << " - skipped." << llendl; + // Try old XFree86 log otherwise fname = x_log_location; fname += "XFree86."; fname += ('0' + display_num); @@ -384,8 +397,24 @@ static int x11_detect_VRAM_kb() fp = fopen(fname.c_str(), "r"); if (fp) { - rtn = x11_detect_VRAM_kb_fp(fp); + llinfos << "Looking in " << fname + << " for VRAM info..." << llendl; + rtn = x11_detect_VRAM_kb_fp(fp, ": VideoRAM: "); fclose(fp); + if (0 == rtn) + { + fp = fopen(fname.c_str(), "r"); + if (fp) + { + rtn = x11_detect_VRAM_kb_fp(fp, ": Memory: "); + fclose(fp); + } + } + } + else + { + llinfos << "Could not open " << fname + << " - skipped." << llendl; } } return rtn; @@ -2023,7 +2052,9 @@ void LLWindowSDL::gatherInput() } else if (event.button.button == SDL_BUTTON_MIDDLE) // middle - ; // Middle mouse isn't handled right now in Second Life ... mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask); + { + mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask); + } else if (event.button.button == 4) // mousewheel up...thanks to X11 for making SDL consider these "buttons". mCallbacks->handleScrollWheel(this, -1); else if (event.button.button == 5) // mousewheel down...thanks to X11 for making SDL consider these "buttons". @@ -2044,8 +2075,9 @@ void LLWindowSDL::gatherInput() else if (event.button.button == SDL_BUTTON_RIGHT) // right ... yes, it's 3, not 2, in SDL... mCallbacks->handleRightMouseUp(this, openGlCoord, mask); else if (event.button.button == SDL_BUTTON_MIDDLE) // middle - ; // UNUSED IN SECOND LIFE RIGHT NOW mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask); - + { + mCallbacks->handleMiddleMouseUp(this, openGlCoord, mask); + } // don't handle mousewheel here... break; -- cgit v1.1