diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-05-16 13:52:40 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-05-16 13:52:40 +0800 |
commit | 6d51e91895a7f2435c46a876410ccc6c63fe8c82 (patch) | |
tree | f2b48ebd99cb414227bf365f47665b8d4baa752b /indra/llwindow/llwindow.cpp | |
parent | d1b5917bb9c92e4e47eba19b43781e4d1328b1ca (diff) | |
parent | 094dcc07f8c1d90ae723dbe60eddacb90a09eae8 (diff) |
Merge tag '7.1.7-release'
source for viewer 7.1.7.8974243247
Diffstat (limited to 'indra/llwindow/llwindow.cpp')
-rw-r--r-- | indra/llwindow/llwindow.cpp | 456 |
1 files changed, 228 insertions, 228 deletions
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index b4fd7c6387..b51b4fad82 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llwindow.cpp * @brief Basic graphical window class * * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -55,43 +55,43 @@ const S32 gURLProtocolWhitelistCount = 5; const std::string gURLProtocolWhitelist[] = { "secondlife:", "http:", "https:", "data:", "mailto:" }; // CP: added a handler list - this is what's used to open the protocol and is based on registry entry -// only meaningful difference currently is that file: protocols are opened using http: -// since no protocol handler exists in registry for file: +// only meaningful difference currently is that file: protocols are opened using http: +// since no protocol handler exists in registry for file: // Important - these lists should match - protocol to handler // Maestro: This list isn't referenced anywhere that I could find -//const std::string gURLProtocolWhitelistHandler[] = { "http", "http", "https" }; +//const std::string gURLProtocolWhitelistHandler[] = { "http", "http", "https" }; S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) { - // Properly hide the splash screen when displaying the message box - BOOL was_visible = FALSE; - if (LLSplashScreen::isVisible()) - { - was_visible = TRUE; - LLSplashScreen::hide(); - } + // Properly hide the splash screen when displaying the message box + BOOL was_visible = FALSE; + if (LLSplashScreen::isVisible()) + { + was_visible = TRUE; + LLSplashScreen::hide(); + } - S32 result = 0; + S32 result = 0; #if LL_MESA_HEADLESS // !!! *FIX: (?) - LL_WARNS() << "OSMessageBox: " << text << LL_ENDL; - return OSBTN_OK; + LL_WARNS() << "OSMessageBox: " << text << LL_ENDL; + return OSBTN_OK; #elif LL_SDL - result = OSMessageBoxSDL(text, caption, type); + result = OSMessageBoxSDL(text, caption, type); #elif LL_WINDOWS - result = OSMessageBoxWin32(text, caption, type); + result = OSMessageBoxWin32(text, caption, type); #elif LL_DARWIN - result = OSMessageBoxMacOSX(text, caption, type); + result = OSMessageBoxMacOSX(text, caption, type); #else #error("OSMessageBox not implemented for this platform!") #endif - if (was_visible) - { - LLSplashScreen::show(); - } + if (was_visible) + { + LLSplashScreen::show(); + } - return result; + return result; } @@ -100,27 +100,27 @@ S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) // LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags) - : mCallbacks(callbacks), - mPostQuit(TRUE), - mFullscreen(fullscreen), - mFullscreenWidth(0), - mFullscreenHeight(0), - mFullscreenBits(0), - mFullscreenRefresh(0), - mSupportedResolutions(NULL), - mNumSupportedResolutions(0), - mCurrentCursor(UI_CURSOR_ARROW), - mNextCursor(UI_CURSOR_ARROW), - mCursorHidden(FALSE), - mBusyCount(0), - mIsMouseClipping(FALSE), - mMinWindowWidth(0), - mMinWindowHeight(0), - mSwapMethod(SWAP_METHOD_UNDEFINED), - mHideCursorPermanent(FALSE), - mFlags(flags), - mHighSurrogate(0), - mRefreshRate(0) + : mCallbacks(callbacks), + mPostQuit(TRUE), + mFullscreen(fullscreen), + mFullscreenWidth(0), + mFullscreenHeight(0), + mFullscreenBits(0), + mFullscreenRefresh(0), + mSupportedResolutions(NULL), + mNumSupportedResolutions(0), + mCurrentCursor(UI_CURSOR_ARROW), + mNextCursor(UI_CURSOR_ARROW), + mCursorHidden(FALSE), + mBusyCount(0), + mIsMouseClipping(FALSE), + mMinWindowWidth(0), + mMinWindowHeight(0), + mSwapMethod(SWAP_METHOD_UNDEFINED), + mHideCursorPermanent(FALSE), + mFlags(flags), + mHighSurrogate(0), + mRefreshRate(0) { } @@ -131,13 +131,13 @@ LLWindow::~LLWindow() //virtual BOOL LLWindow::isValid() { - return TRUE; + return TRUE; } //virtual BOOL LLWindow::canDelete() { - return TRUE; + return TRUE; } //virtual @@ -149,126 +149,126 @@ void LLWindow::setTitle(const std::string title) // virtual void LLWindow::incBusyCount() { - ++mBusyCount; + ++mBusyCount; } // virtual void LLWindow::decBusyCount() { - if (mBusyCount > 0) - { - --mBusyCount; - } + if (mBusyCount > 0) + { + --mBusyCount; + } } //virtual void LLWindow::resetBusyCount() { - mBusyCount = 0; + mBusyCount = 0; } //virtual S32 LLWindow::getBusyCount() const { - return mBusyCount; + return mBusyCount; } //virtual ECursorType LLWindow::getCursor() const { - return mCurrentCursor; + return mCurrentCursor; } //virtual BOOL LLWindow::dialogColorPicker(F32 *r, F32 *g, F32 *b) { - return FALSE; + return FALSE; } void *LLWindow::getMediaWindow() { - // Default to returning the platform window. - return getPlatformWindow(); + // Default to returning the platform window. + return getPlatformWindow(); } BOOL LLWindow::setSize(LLCoordScreen size) { - if (!getMaximized()) - { - size.mX = llmax(size.mX, mMinWindowWidth); - size.mY = llmax(size.mY, mMinWindowHeight); - } - return setSizeImpl(size); + if (!getMaximized()) + { + size.mX = llmax(size.mX, mMinWindowWidth); + size.mY = llmax(size.mY, mMinWindowHeight); + } + return setSizeImpl(size); } BOOL LLWindow::setSize(LLCoordWindow size) { - //HACK: we are inconsistently using minimum window dimensions - // in this case, we are constraining the inner "client" rect and other times - // we constrain the outer "window" rect - // There doesn't seem to be a good way to do this consistently without a bunch of platform - // specific code - if (!getMaximized()) - { - size.mX = llmax(size.mX, mMinWindowWidth); - size.mY = llmax(size.mY, mMinWindowHeight); - } - return setSizeImpl(size); + //HACK: we are inconsistently using minimum window dimensions + // in this case, we are constraining the inner "client" rect and other times + // we constrain the outer "window" rect + // There doesn't seem to be a good way to do this consistently without a bunch of platform + // specific code + if (!getMaximized()) + { + size.mX = llmax(size.mX, mMinWindowWidth); + size.mY = llmax(size.mY, mMinWindowHeight); + } + return setSizeImpl(size); } // virtual void LLWindow::setMinSize(U32 min_width, U32 min_height, bool enforce_immediately) { - mMinWindowWidth = min_width; - mMinWindowHeight = min_height; + mMinWindowWidth = min_width; + mMinWindowHeight = min_height; - if (enforce_immediately) - { - LLCoordScreen cur_size; - if (!getMaximized() && getSize(&cur_size)) - { - if (cur_size.mX < mMinWindowWidth || cur_size.mY < mMinWindowHeight) - { - setSizeImpl(LLCoordScreen(llmin(cur_size.mX, mMinWindowWidth), llmin(cur_size.mY, mMinWindowHeight))); - } - } - } + if (enforce_immediately) + { + LLCoordScreen cur_size; + if (!getMaximized() && getSize(&cur_size)) + { + if (cur_size.mX < mMinWindowWidth || cur_size.mY < mMinWindowHeight) + { + setSizeImpl(LLCoordScreen(llmin(cur_size.mX, mMinWindowWidth), llmin(cur_size.mY, mMinWindowHeight))); + } + } + } } //virtual void LLWindow::processMiscNativeEvents() { - // do nothing unless subclassed + // do nothing unless subclassed } //virtual BOOL LLWindow::isPrimaryTextAvailable() { - return FALSE; // no + return FALSE; // no } //virtual BOOL LLWindow::pasteTextFromPrimary(LLWString &dst) { - return FALSE; // fail + return FALSE; // fail } // virtual BOOL LLWindow::copyTextToPrimary(const LLWString &src) { - return FALSE; // fail + return FALSE; // fail } // static std::vector<std::string> LLWindow::getDynamicFallbackFontList() { #if LL_SDL - return LLWindowSDL::getDynamicFallbackFontList(); + return LLWindowSDL::getDynamicFallbackFontList(); #elif LL_WINDOWS - return LLWindowWin32::getDynamicFallbackFontList(); + return LLWindowWin32::getDynamicFallbackFontList(); #elif LL_DARWIN - return LLWindowMacOSX::getDynamicFallbackFontList(); + return LLWindowMacOSX::getDynamicFallbackFontList(); #else - return std::vector<std::string>(); + return std::vector<std::string>(); #endif } @@ -276,11 +276,11 @@ std::vector<std::string> LLWindow::getDynamicFallbackFontList() std::vector<std::string> LLWindow::getDisplaysResolutionList() { #ifdef LL_SDL - return std::vector<std::string>(); + return std::vector<std::string>(); #elif LL_WINDOWS - return LLWindowWin32::getDisplaysResolutionList(); + return LLWindowWin32::getDisplaysResolutionList(); #elif LL_DARWIN - return LLWindowMacOSX::getDisplaysResolutionList(); + return LLWindowMacOSX::getDisplaysResolutionList(); #endif } @@ -290,45 +290,45 @@ std::vector<std::string> LLWindow::getDisplaysResolutionList() void LLWindow::handleUnicodeUTF16(U16 utf16, MASK mask) { - // Note that we could discard unpaired surrogates, but I'm - // following the Unicode Consortium's recommendation here; - // that is, to preserve those unpaired surrogates in UTF-32 - // values. _To_preserve_ means to pass to the callback in our - // context. - - if (mHighSurrogate == 0) - { - if (UTF16_IS_HIGH_SURROGATE(utf16)) - { - mHighSurrogate = utf16; - } - else - { - mCallbacks->handleUnicodeChar(utf16, mask); - } - } - else - { - if (UTF16_IS_LOW_SURROGATE(utf16)) - { - /* A legal surrogate pair. */ - mCallbacks->handleUnicodeChar(UTF16_SURROGATE_PAIR_TO_UTF32(mHighSurrogate, utf16), mask); - mHighSurrogate = 0; - } - else if (UTF16_IS_HIGH_SURROGATE(utf16)) - { - /* Two consecutive high surrogates. */ - mCallbacks->handleUnicodeChar(mHighSurrogate, mask); - mHighSurrogate = utf16; - } - else - { - /* A non-low-surrogate preceeded by a high surrogate. */ - mCallbacks->handleUnicodeChar(mHighSurrogate, mask); - mHighSurrogate = 0; - mCallbacks->handleUnicodeChar(utf16, mask); - } - } + // Note that we could discard unpaired surrogates, but I'm + // following the Unicode Consortium's recommendation here; + // that is, to preserve those unpaired surrogates in UTF-32 + // values. _To_preserve_ means to pass to the callback in our + // context. + + if (mHighSurrogate == 0) + { + if (UTF16_IS_HIGH_SURROGATE(utf16)) + { + mHighSurrogate = utf16; + } + else + { + mCallbacks->handleUnicodeChar(utf16, mask); + } + } + else + { + if (UTF16_IS_LOW_SURROGATE(utf16)) + { + /* A legal surrogate pair. */ + mCallbacks->handleUnicodeChar(UTF16_SURROGATE_PAIR_TO_UTF32(mHighSurrogate, utf16), mask); + mHighSurrogate = 0; + } + else if (UTF16_IS_HIGH_SURROGATE(utf16)) + { + /* Two consecutive high surrogates. */ + mCallbacks->handleUnicodeChar(mHighSurrogate, mask); + mHighSurrogate = utf16; + } + else + { + /* A non-low-surrogate preceeded by a high surrogate. */ + mCallbacks->handleUnicodeChar(mHighSurrogate, mask); + mHighSurrogate = 0; + mCallbacks->handleUnicodeChar(utf16, mask); + } + } } // @@ -338,18 +338,18 @@ void LLWindow::handleUnicodeUTF16(U16 utf16, MASK mask) // static bool LLSplashScreen::isVisible() { - return gSplashScreenp ? true: false; + return gSplashScreenp ? true: false; } // static LLSplashScreen *LLSplashScreen::create() { #if LL_MESA_HEADLESS || LL_SDL // !!! *FIX: (?) - return 0; + return 0; #elif LL_WINDOWS - return new LLSplashScreenWin32; + return new LLSplashScreenWin32; #elif LL_DARWIN - return new LLSplashScreenMacOSX; + return new LLSplashScreenMacOSX; #else #error("LLSplashScreen not implemented on this platform!") #endif @@ -359,41 +359,41 @@ LLSplashScreen *LLSplashScreen::create() //static void LLSplashScreen::show() { - if (!gSplashScreenp) - { + if (!gSplashScreenp) + { #if !LL_SDL #if LL_WINDOWS && !LL_MESA_HEADLESS - gSplashScreenp = new LLSplashScreenWin32; + gSplashScreenp = new LLSplashScreenWin32; #elif LL_DARWIN - gSplashScreenp = new LLSplashScreenMacOSX; + gSplashScreenp = new LLSplashScreenMacOSX; #endif #endif // !LL_SDL - if (gSplashScreenp) - { - gSplashScreenp->showImpl(); - } - } + if (gSplashScreenp) + { + gSplashScreenp->showImpl(); + } + } } //static void LLSplashScreen::update(const std::string& str) { - LLSplashScreen::show(); - if (gSplashScreenp) - { - gSplashScreenp->updateImpl(str); - } + LLSplashScreen::show(); + if (gSplashScreenp) + { + gSplashScreenp->updateImpl(str); + } } //static void LLSplashScreen::hide() { - if (gSplashScreenp) - { - gSplashScreenp->hideImpl(); - } - delete gSplashScreenp; - gSplashScreenp = NULL; + if (gSplashScreenp) + { + gSplashScreenp->hideImpl(); + } + delete gSplashScreenp; + gSplashScreenp = NULL; } // @@ -404,111 +404,111 @@ void LLSplashScreen::hide() static std::set<LLWindow*> sWindowList; LLWindow* LLWindowManager::createWindow( - LLWindowCallbacks* callbacks, - const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, - BOOL fullscreen, - BOOL clearBg, - BOOL enable_vsync, - BOOL use_gl, - BOOL ignore_pixel_depth, - U32 fsaa_samples, + LLWindowCallbacks* callbacks, + const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height, U32 flags, + BOOL fullscreen, + BOOL clearBg, + BOOL enable_vsync, + BOOL use_gl, + BOOL ignore_pixel_depth, + U32 fsaa_samples, U32 max_cores, U32 max_vram, F32 max_gl_version) { - LLWindow* new_window = nullptr; + LLWindow* new_window = nullptr; - if (use_gl) - { + if (use_gl) + { #if LL_MESA_HEADLESS - new_window = new LLWindowMesaHeadless(callbacks, - title, name, x, y, width, height, flags, - fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth); + new_window = new LLWindowMesaHeadless(callbacks, + title, name, x, y, width, height, flags, + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth); #elif LL_SDL - new_window = new LLWindowSDL(callbacks, - title, x, y, width, height, flags, - fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); + new_window = new LLWindowSDL(callbacks, + title, x, y, width, height, flags, + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #elif LL_WINDOWS - new_window = new LLWindowWin32(callbacks, - title, name, x, y, width, height, flags, - fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples, max_cores, max_vram, max_gl_version); + new_window = new LLWindowWin32(callbacks, + title, name, x, y, width, height, flags, + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples, max_cores, max_vram, max_gl_version); #elif LL_DARWIN - new_window = new LLWindowMacOSX(callbacks, - title, name, x, y, width, height, flags, - fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); + new_window = new LLWindowMacOSX(callbacks, + title, name, x, y, width, height, flags, + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); #endif - } - else - { - new_window = new LLWindowHeadless(callbacks, - title, name, x, y, width, height, flags, - fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth); - } - - if (FALSE == new_window->isValid()) - { - delete new_window; - LL_WARNS() << "LLWindowManager::create() : Error creating window." << LL_ENDL; - return NULL; - } - sWindowList.insert(new_window); - return new_window; + } + else + { + new_window = new LLWindowHeadless(callbacks, + title, name, x, y, width, height, flags, + fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth); + } + + if (FALSE == new_window->isValid()) + { + delete new_window; + LL_WARNS() << "LLWindowManager::create() : Error creating window." << LL_ENDL; + return NULL; + } + sWindowList.insert(new_window); + return new_window; } BOOL LLWindowManager::destroyWindow(LLWindow* window) { - if (sWindowList.find(window) == sWindowList.end()) - { - LL_ERRS() << "LLWindowManager::destroyWindow() : Window pointer not valid, this window doesn't exist!" - << LL_ENDL; - return FALSE; - } + if (sWindowList.find(window) == sWindowList.end()) + { + LL_ERRS() << "LLWindowManager::destroyWindow() : Window pointer not valid, this window doesn't exist!" + << LL_ENDL; + return FALSE; + } - window->close(); + window->close(); - sWindowList.erase(window); + sWindowList.erase(window); - delete window; + delete window; - return TRUE; + return TRUE; } BOOL LLWindowManager::isWindowValid(LLWindow *window) { - return sWindowList.find(window) != sWindowList.end(); + return sWindowList.find(window) != sWindowList.end(); } //coordinate conversion utility funcs that forward to llwindow LLCoordCommon LL_COORD_TYPE_WINDOW::convertToCommon() const { - const LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this); + const LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this); - LLCoordGL out; - LLWindow::instance_snapshot().begin()->convertCoords(self, &out); - return out.convert(); + LLCoordGL out; + LLWindow::instance_snapshot().begin()->convertCoords(self, &out); + return out.convert(); } void LL_COORD_TYPE_WINDOW::convertFromCommon(const LLCoordCommon& from) { - LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this); + LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this); - LLCoordGL from_gl(from); - LLWindow::instance_snapshot().begin()->convertCoords(from_gl, &self); + LLCoordGL from_gl(from); + LLWindow::instance_snapshot().begin()->convertCoords(from_gl, &self); } LLCoordCommon LL_COORD_TYPE_SCREEN::convertToCommon() const { - const LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this); + const LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this); - LLCoordGL out; - LLWindow::instance_snapshot().begin()->convertCoords(self, &out); - return out.convert(); + LLCoordGL out; + LLWindow::instance_snapshot().begin()->convertCoords(self, &out); + return out.convert(); } void LL_COORD_TYPE_SCREEN::convertFromCommon(const LLCoordCommon& from) { - LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this); + LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this); - LLCoordGL from_gl(from); - LLWindow::instance_snapshot().begin()->convertCoords(from_gl, &self); + LLCoordGL from_gl(from); + LLWindow::instance_snapshot().begin()->convertCoords(from_gl, &self); } |