diff options
author | Todd Stinson <stinson@lindenlab.com> | 2011-12-13 11:15:18 -0800 |
---|---|---|
committer | Todd Stinson <stinson@lindenlab.com> | 2011-12-13 11:15:18 -0800 |
commit | 9d1db4f19ae7ca044e47d0fe4e605e14882351c5 (patch) | |
tree | 2d499d53b60b2486f1e6666f8b9fe2063f984d22 /indra/llwindow | |
parent | 817c97c2f836948f210599a6f67e36a411b22c21 (diff) | |
parent | dbc91a7fac9513bdd879c5c2dc82208e08eaad2d (diff) |
Pull and merge from https://bitbucket.org/lindenlab/viewer-development.
Diffstat (limited to 'indra/llwindow')
-rw-r--r-- | indra/llwindow/llmousehandler.h | 2 | ||||
-rw-r--r-- | indra/llwindow/llwindow.cpp | 33 | ||||
-rw-r--r-- | indra/llwindow/llwindow.h | 11 | ||||
-rw-r--r-- | indra/llwindow/llwindowheadless.h | 4 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx.cpp | 231 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx.h | 4 | ||||
-rw-r--r-- | indra/llwindow/llwindowmesaheadless.h | 4 | ||||
-rw-r--r-- | indra/llwindow/llwindowsdl.cpp | 48 | ||||
-rw-r--r-- | indra/llwindow/llwindowsdl.h | 5 | ||||
-rw-r--r-- | indra/llwindow/llwindowwin32.cpp | 86 | ||||
-rw-r--r-- | indra/llwindow/llwindowwin32.h | 4 |
11 files changed, 280 insertions, 152 deletions
diff --git a/indra/llwindow/llmousehandler.h b/indra/llwindow/llmousehandler.h index bbbc3d4406..d825a3424c 100644 --- a/indra/llwindow/llmousehandler.h +++ b/indra/llwindow/llmousehandler.h @@ -65,7 +65,7 @@ public: virtual BOOL handleHover(S32 x, S32 y, MASK mask) = 0; virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks) = 0; virtual BOOL handleToolTip(S32 x, S32 y, MASK mask) = 0; - virtual std::string getName() const = 0; + virtual const std::string& getName() const = 0; virtual void onMouseCaptureLost() = 0; diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index dc3a1099b1..1351bed547 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -108,9 +108,12 @@ LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags) 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), @@ -179,6 +182,36 @@ void *LLWindow::getMediaWindow() return getPlatformWindow(); } +BOOL LLWindow::setSize(LLCoordScreen size) +{ + if (!getMaximized()) + { + size.mX = llmin(size.mX, mMinWindowWidth); + size.mY = llmin(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; + + 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() { diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index e8a86a1880..cab2d0a8fb 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -72,7 +72,8 @@ public: virtual BOOL getSize(LLCoordScreen *size) = 0; virtual BOOL getSize(LLCoordWindow *size) = 0; virtual BOOL setPosition(LLCoordScreen position) = 0; - virtual BOOL setSize(LLCoordScreen size) = 0; + BOOL setSize(LLCoordScreen size); + virtual void setMinSize(U32 min_width, U32 min_height, bool enforce_immediately = true); virtual BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) = 0; virtual BOOL setCursorPosition(LLCoordWindow position) = 0; virtual BOOL getCursorPosition(LLCoordWindow *position) = 0; @@ -91,8 +92,9 @@ public: virtual S32 getBusyCount() const; // Sets cursor, may set to arrow+hourglass - virtual void setCursor(ECursorType cursor) = 0; + virtual void setCursor(ECursorType cursor) { mNextCursor = cursor; }; virtual ECursorType getCursor() const; + virtual void updateCursor() = 0; virtual void captureMouse() = 0; virtual void releaseMouse() = 0; @@ -169,6 +171,8 @@ protected: // Defaults to true virtual BOOL canDelete(); + virtual BOOL setSizeImpl(LLCoordScreen size) = 0; + protected: LLWindowCallbacks* mCallbacks; @@ -181,6 +185,7 @@ protected: LLWindowResolution* mSupportedResolutions; S32 mNumSupportedResolutions; ECursorType mCurrentCursor; + ECursorType mNextCursor; BOOL mCursorHidden; S32 mBusyCount; // how deep is the "cursor busy" stack? BOOL mIsMouseClipping; // Is this window currently clipping the mouse @@ -188,6 +193,8 @@ protected: BOOL mHideCursorPermanent; U32 mFlags; U16 mHighSurrogate; + S32 mMinWindowWidth; + S32 mMinWindowHeight; // Handle a UTF-16 encoding unit received from keyboard. // Converting the series of UTF-16 encoding units to UTF-32 data, diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h index ac53e6a86e..d4a778cb85 100644 --- a/indra/llwindow/llwindowheadless.h +++ b/indra/llwindow/llwindowheadless.h @@ -46,7 +46,7 @@ public: /*virtual*/ BOOL getSize(LLCoordScreen *size) {return FALSE;}; /*virtual*/ BOOL getSize(LLCoordWindow *size) {return FALSE;}; /*virtual*/ BOOL setPosition(LLCoordScreen position) {return FALSE;}; - /*virtual*/ BOOL setSize(LLCoordScreen size) {return FALSE;}; + /*virtual*/ BOOL setSizeImpl(LLCoordScreen size) {return FALSE;}; /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) {return FALSE;}; /*virtual*/ BOOL setCursorPosition(LLCoordWindow position) {return FALSE;}; /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position) {return FALSE;}; @@ -55,7 +55,7 @@ public: /*virtual*/ void showCursorFromMouseMove() {}; /*virtual*/ void hideCursorUntilMouseMove() {}; /*virtual*/ BOOL isCursorHidden() {return FALSE;}; - /*virtual*/ void setCursor(ECursorType cursor) {}; + /*virtual*/ void updateCursor() {}; //virtual ECursorType getCursor() { return mCurrentCursor; }; /*virtual*/ void captureMouse() {}; /*virtual*/ void releaseMouse() {}; diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 4dd11541b9..c952f8bbcf 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llwindowmacosx.cpp * @brief Platform-dependent implementation of llwindow * * $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$ */ @@ -220,10 +220,10 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, // Route them to a dummy callback structure until the end of constructor. LLWindowCallbacks null_callbacks; mCallbacks = &null_callbacks; - + // Voodoo for calling cocoa from carbon (see llwindowmacosx-objc.mm). setupCocoa(); - + // Initialize the keyboard gKeyboard = new LLKeyboardMacOSX(); gKeyboard->setCallbacks(callbacks); @@ -254,10 +254,10 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, mRawKeyEvent = NULL; mFSAASamples = fsaa_samples; mForceRebuild = FALSE; - + // For reasons that aren't clear to me, LLTimers seem to be created in the "started" state. // Since the started state of this one is used to track whether the NMRec has been installed, it wants to start out in the "stopped" state. - mBounceTimer.stop(); + mBounceTimer.stop(); // Get the original aspect ratio of the main device. mOriginalAspectRatio = (double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay); @@ -270,7 +270,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, mMoveEventCampartorUPP = NewEventComparatorUPP(staticMoveEventComparator); mGlobalHandlerRef = NULL; mWindowHandlerRef = NULL; - + mDragOverrideCursor = -1; // We're not clipping yet @@ -445,7 +445,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits mFullscreenBits = -1; mFullscreenRefresh = -1; - std::string error= llformat("Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); + std::string error= llformat("Unable to run fullscreen at %d x %d.\nRunning in window.", width, height); OSMessageBox(error, "Error", OSMB_OK); } } @@ -477,7 +477,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits kFirstWindowOfClass, true, (long)this); - + if (!mWindow) { setupFailure("Window creation error", "Error", OSMB_OK); @@ -493,7 +493,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits InstallStandardEventHandler(GetWindowEventTarget(mWindow)); InstallWindowEventHandler(mWindow, mEventHandlerUPP, GetEventTypeCount (WindowHandlerEventList), WindowHandlerEventList, (void*)this, &mWindowHandlerRef); // add event handler #if LL_OS_DRAGDROP_ENABLED - InstallTrackingHandler( dragTrackingHandler, mWindow, (void*)this ); + InstallTrackingHandler( dragTrackingHandler, mWindow, (void*)this ); InstallReceiveHandler( dragReceiveHandler, mWindow, (void*)this ); #endif // LL_OS_DRAGDROP_ENABLED } @@ -790,7 +790,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits LL_DEBUGS("GLinit") << "Keeping vertical sync" << LL_ENDL; frames_per_swap = 1; } - aglSetInteger(mContext, AGL_SWAP_INTERVAL, &frames_per_swap); + aglSetInteger(mContext, AGL_SWAP_INTERVAL, &frames_per_swap); //enable multi-threaded OpenGL if (sUseMultGL) @@ -803,7 +803,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits if (cgl_err != kCGLNoError ) { LL_DEBUGS("GLInit") << "Multi-threaded OpenGL not available." << LL_ENDL; - } + } else { LL_DEBUGS("GLInit") << "Multi-threaded OpenGL enabled." << LL_ENDL; @@ -1109,7 +1109,7 @@ BOOL LLWindowMacOSX::maximize() { ZoomWindow(mWindow, inContent, true); } - + return mMaximized; } @@ -1164,6 +1164,8 @@ void LLWindowMacOSX::gatherInput() } } + + updateCursor(); } BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position) @@ -1254,7 +1256,7 @@ BOOL LLWindowMacOSX::setPosition(const LLCoordScreen position) return TRUE; } -BOOL LLWindowMacOSX::setSize(const LLCoordScreen size) +BOOL LLWindowMacOSX::setSizeImpl(const LLCoordScreen size) { if(mWindow) { @@ -1266,7 +1268,6 @@ BOOL LLWindowMacOSX::setSize(const LLCoordScreen size) void LLWindowMacOSX::swapBuffers() { - glFinish(); aglSwapBuffers(mContext); } @@ -1433,7 +1434,7 @@ static void fixOrigin(void) GrafPtr port; Rect portrect; - ::GetPort(&port); + ::GetPort(&port); ::GetPortBounds(port, &portrect); if((portrect.left != 0) || (portrect.top != 0)) { @@ -1447,17 +1448,17 @@ BOOL LLWindowMacOSX::getCursorPosition(LLCoordWindow *position) Point cursor_point; LLCoordScreen screen_pos; GrafPtr save; - + if(mWindow == NULL) return FALSE; - + ::GetPort(&save); ::SetPort(GetWindowPort(mWindow)); fixOrigin(); // gets the mouse location in local coordinates ::GetMouse(&cursor_point); - + // lldebugs << "getCursorPosition(): cursor is at " << cursor_point.h << ", " << cursor_point.v << " port origin: " << portrect.left << ", " << portrect.top << llendl; ::SetPort(save); @@ -1522,7 +1523,7 @@ F32 LLWindowMacOSX::getNativeAspectRatio() { // The constructor for this class grabs the aspect ratio of the monitor before doing any resolution // switching, and stashes it in mOriginalAspectRatio. Here, we just return it. - + if (mOverrideAspectRatio > 0.f) { return mOverrideAspectRatio; @@ -1997,7 +1998,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e if (mPreeditor && (result = GetEventParameter(event, kEventParamTextInputSendFixLen, typeLongInteger, ¶m_type, sizeof(fix_len), NULL, &fix_len)) == noErr - && typeLongInteger == param_type + && typeLongInteger == param_type && (result = GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText, ¶m_type, 0, &text_len, NULL)) == noErr && typeUnicodeText == param_type) @@ -2017,7 +2018,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e mPreeditor->markAsPreedit(location, length); } mPreeditor->resetPreedit(); - + // Receive the text from input method. U16 *const text = new U16[text_len / sizeof(U16)]; GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText, NULL, text_len, NULL, text); @@ -2056,11 +2057,11 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, NULL, text_range_array_size, NULL, text_range_array); - // WARNING: We assume ranges are in ascending order, + // WARNING: We assume ranges are in ascending order, // although the condition is undocumented. It seems // OK to assume this. I also assumed // the ranges are contiguous in previous versions, but I - // have heard a rumore that older versions os ATOK may + // have heard a rumore that older versions os ATOK may // return ranges with some _gap_. I don't know whether // it is true, but I'm preparing my code for the case. @@ -2124,7 +2125,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e } } break; - + case kEventTextInputUnicodeForKeyEvent: { UInt32 modifiers = 0; @@ -2133,7 +2134,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e // First, process the raw event. { EventRef rawEvent = NULL; - + // Get the original event and extract the modifier keys, so we can ignore command-key events. if (GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(rawEvent), NULL, &rawEvent) == noErr) { @@ -2142,7 +2143,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e // and call this function recursively to handle the raw key event. eventHandler (myHandler, rawEvent); - + // save the raw event until we're done processing the unicode input as well. mRawKeyEvent = rawEvent; } @@ -2173,7 +2174,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e else { MASK mask = LLWindowMacOSX::modifiersToMask(modifiers); - + llassert( actualType == typeUnicodeText ); // The result is a UTF16 buffer. Pass the characters in turn to handleUnicodeChar. @@ -2199,7 +2200,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e result = err; } break; - + case kEventTextInputOffsetToPos: { EventParamType param_type; @@ -2212,7 +2213,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e S32 preedit, preedit_length; mPreeditor->getPreeditRange(&preedit, &preedit_length); const LLWString & text = mPreeditor->getPreeditString(); - + LLCoordGL caret_coord; LLRect preedit_bounds; if (0 <= offset @@ -2226,10 +2227,10 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e qd_point.h = caret_base_coord_screen.mX; qd_point.v = caret_base_coord_screen.mY; SetEventParameter(event, kEventParamTextInputReplyPoint, typeQDPoint, sizeof(qd_point), &qd_point); - + short line_height = (short) preedit_bounds.getHeight(); SetEventParameter(event, kEventParamTextInputReplyLineHeight, typeShortInteger, sizeof(line_height), &line_height); - + result = noErr; } else @@ -2282,7 +2283,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e case kEventRawKeyRepeat: if (gDebugWindowProc) { - printf("key down, key code = 0x%08x, char code = 0x%02x (%c), modifiers = 0x%08x\n", + printf("key down, key code = 0x%08x, char code = 0x%02x (%c), modifiers = 0x%08x\n", (unsigned int)keyCode, charCode, (char)charCode, (unsigned int)modifiers); fflush(stdout); } @@ -2293,7 +2294,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e case kEventRawKeyUp: if (gDebugWindowProc) { - printf("key up, key code = 0x%08x, char code = 0x%02x (%c), modifiers = 0x%08x\n", + printf("key up, key code = 0x%08x, char code = 0x%02x (%c), modifiers = 0x%08x\n", (unsigned int)keyCode, charCode, (char)charCode, (unsigned int)modifiers); fflush(stdout); } @@ -2351,7 +2352,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e } // When the state of the 'Fn' key (the one that changes some of the mappings on a powerbook/macbook keyboard - // to an embedded keypad) changes, it may subsequently cause a key up event to be lost, which may lead to + // to an embedded keypad) changes, it may subsequently cause a key up event to be lost, which may lead to // a movement key getting "stuck" down. This is bad. // This is an OS bug -- even the GetKeys() API doesn't tell you the key has been released. // This workaround causes all held-down keys to be reset whenever the state of the Fn key changes. This isn't @@ -2361,14 +2362,14 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e if (gDebugWindowProc) printf("Fn key state change event\n"); gKeyboard->resetKeys(); } - + if (gDebugWindowProc) fflush(stdout); mLastModifiers = modifiers; result = eventNotHandledErr; break; } - + mRawKeyEvent = NULL; } break; @@ -2463,7 +2464,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e case kEventMouseButtonSecondary: mCallbacks->handleRightMouseDown(this, outCoords, mask); break; - + case kEventMouseButtonTertiary: mCallbacks->handleMiddleMouseDown(this, outCoords, mask); break; @@ -2525,7 +2526,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e case kEventClassWindow: switch(evtKind) - { + { case kEventWindowActivated: if (mTSMDocument) { @@ -2540,20 +2541,20 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e } mCallbacks->handleFocusLost(this); break; - + case kEventWindowBoundsChanging: { // This is where we would constrain move/resize to a particular screen - const S32 MIN_WIDTH = 320; - const S32 MIN_HEIGHT = 240; - + const S32 MIN_WIDTH = mMinWindowWidth; + const S32 MIN_HEIGHT = mMinWindowHeight; + Rect currentBounds; Rect previousBounds; GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, ¤tBounds); GetEventParameter(event, kEventParamPreviousBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &previousBounds); - + // Put an offset into window un-maximize operation since the kEventWindowGetIdealSize // event only allows the specification of size and not position. if (mMaximized) @@ -2561,7 +2562,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e short leftOffset = mPreviousWindowRect.left - currentBounds.left; currentBounds.left += leftOffset; currentBounds.right += leftOffset; - + short topOffset = mPreviousWindowRect.top - currentBounds.top; currentBounds.top += topOffset; currentBounds.bottom += topOffset; @@ -2581,7 +2582,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e { currentBounds.bottom = currentBounds.top + MIN_HEIGHT; } - + SetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, sizeof(Rect), ¤tBounds); result = noErr; } @@ -2592,38 +2593,38 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e // Get new window bounds Rect newBounds; GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &newBounds); - + // Get previous window bounds Rect oldBounds; GetEventParameter(event, kEventParamPreviousBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &oldBounds); - + // Determine if the new size is larger than the old bool newBoundsLarger = ((newBounds.right - newBounds.left) >= (oldBounds.right - oldBounds.left)); newBoundsLarger &= ((newBounds.bottom - newBounds.top) >= (oldBounds.bottom - oldBounds.top)); - + // Check to see if this is a zoom event (+ button on window pane) unsigned int eventParams; GetEventParameter(event, kEventParamAttributes, typeUInt32, NULL, sizeof(int), NULL, &eventParams); bool isZoomEvent = ((eventParams & kWindowBoundsChangeZoom) != 0); - + // Maximized flag is if zoom event and increasing window size mMaximized = (isZoomEvent && newBoundsLarger); - + aglUpdateContext(mContext); - + mCallbacks->handleResize(this, newBounds.right - newBounds.left, newBounds.bottom - newBounds.top); } break; - + case kEventWindowGetIdealSize: // Only recommend a new ideal size when un-maximizing if (mMaximized == TRUE) { Point nonMaximizedSize; - + nonMaximizedSize.v = mPreviousWindowRect.bottom - mPreviousWindowRect.top; nonMaximizedSize.h = mPreviousWindowRect.right - mPreviousWindowRect.left; - + SetEventParameter(event, kEventParamDimensions, typeQDPoint, sizeof(Point), &nonMaximizedSize); result = noErr; } @@ -2678,7 +2679,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e if (mPreeditor) { switch(evtKind) - { + { case kEventTSMDocumentAccessGetLength: { @@ -2697,14 +2698,14 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e { // Return the selected range, excluding preedit. // In our preeditor, preedit and selection are exclusive, so, - // when it has a preedit, there is no selection and the + // when it has a preedit, there is no selection and the // insertion point is on the preedit that corrupses into the // beginning of the preedit when the preedit was removed. S32 preedit, preedit_length; mPreeditor->getPreeditRange(&preedit, &preedit_length); const LLWString & text = mPreeditor->getPreeditString(); - + CFRange range; if (preedit_length) { @@ -2768,7 +2769,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e memcpy(target_pointer, text_utf16.c_str() + range.location, range.length * sizeof(UniChar)); // Note that result has already been set above. - } + } } break; @@ -2815,14 +2816,14 @@ const char* cursorIDToName(int id) case UI_CURSOR_TOOLPLAY: return "UI_CURSOR_TOOLPLAY"; case UI_CURSOR_TOOLPAUSE: return "UI_CURSOR_TOOLPAUSE"; case UI_CURSOR_TOOLMEDIAOPEN: return "UI_CURSOR_TOOLMEDIAOPEN"; - case UI_CURSOR_PIPETTE: return "UI_CURSOR_PIPETTE"; + case UI_CURSOR_PIPETTE: return "UI_CURSOR_PIPETTE"; case UI_CURSOR_TOOLSIT: return "UI_CURSOR_TOOLSIT"; case UI_CURSOR_TOOLBUY: return "UI_CURSOR_TOOLBUY"; case UI_CURSOR_TOOLOPEN: return "UI_CURSOR_TOOLOPEN"; } llerrs << "cursorIDToName: unknown cursor id" << id << llendl; - + return "UI_CURSOR_ARROW"; } @@ -2838,42 +2839,42 @@ static void initPixmapCursor(int cursorid, int hotspotX, int hotspotY) fullpath += gDirUtilp->getDirDelimiter(); fullpath += cursorIDToName(cursorid); fullpath += ".tif"; - + gCursors[cursorid] = createImageCursor(fullpath.c_str(), hotspotX, hotspotY); } -void LLWindowMacOSX::setCursor(ECursorType cursor) +void LLWindowMacOSX::updateCursor() { OSStatus result = noErr; - if (mDragOverrideCursor != -1) + if (mDragOverrideCursor != -1) { // A drag is in progress...remember the requested cursor and we'll // restore it when it is done - mCurrentCursor = cursor; + mCurrentCursor = mNextCursor; return; } - if (cursor == UI_CURSOR_ARROW + if (mNextCursor == UI_CURSOR_ARROW && mBusyCount > 0) { - cursor = UI_CURSOR_WORKING; + mNextCursor = UI_CURSOR_WORKING; } - if(mCurrentCursor == cursor) + if(mCurrentCursor == mNextCursor) return; // RN: replace multi-drag cursors with single versions - if (cursor == UI_CURSOR_ARROWDRAGMULTI) + if (mNextCursor == UI_CURSOR_ARROWDRAGMULTI) { - cursor = UI_CURSOR_ARROWDRAG; + mNextCursor = UI_CURSOR_ARROWDRAG; } - else if (cursor == UI_CURSOR_ARROWCOPYMULTI) + else if (mNextCursor == UI_CURSOR_ARROWCOPYMULTI) { - cursor = UI_CURSOR_ARROWCOPY; + mNextCursor = UI_CURSOR_ARROWCOPY; } - switch(cursor) + switch(mNextCursor) { default: case UI_CURSOR_ARROW: @@ -2924,7 +2925,7 @@ void LLWindowMacOSX::setCursor(ECursorType cursor) case UI_CURSOR_TOOLSIT: case UI_CURSOR_TOOLBUY: case UI_CURSOR_TOOLOPEN: - result = setImageCursor(gCursors[cursor]); + result = setImageCursor(gCursors[mNextCursor]); break; } @@ -2934,7 +2935,7 @@ void LLWindowMacOSX::setCursor(ECursorType cursor) InitCursor(); } - mCurrentCursor = cursor; + mCurrentCursor = mNextCursor; } ECursorType LLWindowMacOSX::getCursor() const @@ -3269,14 +3270,14 @@ void LLWindowMacOSX::spawnWebBrowser(const std::string& escaped_url, bool async) LLSD LLWindowMacOSX::getNativeKeyData() { LLSD result = LLSD::emptyMap(); - + if(mRawKeyEvent) { char char_code = 0; UInt32 key_code = 0; UInt32 modifiers = 0; UInt32 keyboard_type = 0; - + GetEventParameter (mRawKeyEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &char_code); GetEventParameter (mRawKeyEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &key_code); GetEventParameter (mRawKeyEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); @@ -3286,7 +3287,7 @@ LLSD LLWindowMacOSX::getNativeKeyData() result["key_code"] = (S32)key_code; result["modifiers"] = (S32)modifiers; result["keyboard_type"] = (S32)keyboard_type; - + #if 0 // This causes trouble for control characters -- apparently character codes less than 32 (escape, control-A, etc) // cause llsd serialization to create XML that the llsd deserializer won't parse! @@ -3295,7 +3296,7 @@ LLSD LLWindowMacOSX::getNativeKeyData() EventParamType actualType = typeUTF8Text; UInt32 actualSize = 0; char *buffer = NULL; - + err = GetEventParameter (mRawKeyEvent, kEventParamKeyUnicodes, typeUTF8Text, &actualType, 0, &actualSize, NULL); if(err == noErr) { @@ -3308,7 +3309,7 @@ LLSD LLWindowMacOSX::getNativeKeyData() } delete[] buffer; } - + result["unicode"] = unicode; #endif @@ -3316,7 +3317,7 @@ LLSD LLWindowMacOSX::getNativeKeyData() lldebugs << "native key data is: " << result << llendl; - + return result; } @@ -3363,17 +3364,17 @@ void *LLWindowMacOSX::getPlatformWindow() void *LLWindowMacOSX::getMediaWindow() { - /* - Mozilla needs to be initialized with a WindowRef to function properly. + /* + Mozilla needs to be initialized with a WindowRef to function properly. (There's no good reason for this, since it shouldn't be interacting with our window in any way, but that's another issue.) - If we're in windowed mode, we _could_ hand it our actual window pointer, but a subsequent switch to fullscreen will destroy that window, + If we're in windowed mode, we _could_ hand it our actual window pointer, but a subsequent switch to fullscreen will destroy that window, which trips up Mozilla. Instead of using our actual window, we create an invisible window which will persist for the lifetime of the application and pass that to Mozilla. This satisfies its deep-seated need to latch onto a WindowRef and solves the issue with switching between fullscreen and windowed modes. Note that we will never destroy this window (by design!), but since only one will ever be created per run of the application, that's okay. */ - + if(sMediaWindow == NULL) { Rect window_rect = {100, 100, 200, 200}; @@ -3382,13 +3383,13 @@ void *LLWindowMacOSX::getMediaWindow() NULL, &window_rect, (ConstStr255Param) "\p", - false, // Create the window invisible. + false, // Create the window invisible. zoomDocProc, // Window with a grow box and a zoom box kLastWindowOfClass, // create it behind other windows false, // no close box 0); } - + return (void*)sMediaWindow; } @@ -3438,7 +3439,7 @@ void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) } UseInputWindow(mTSMDocument, !b); - + // Take care of old and new preeditors. if (preeditor != mPreeditor || !b) { @@ -3457,7 +3458,7 @@ void LLWindowMacOSX::allowLanguageTextInput(LLPreeditor *preeditor, BOOL b) return; } mLanguageTextInputAllowed = b; - + if (b) { if (mTSMScriptCode != smRoman) @@ -3506,7 +3507,7 @@ MASK LLWindowMacOSX::modifiersToMask(SInt16 modifiers) if(modifiers & (cmdKey | controlKey)) { mask |= MASK_CONTROL; } if(modifiers & optionKey) { mask |= MASK_ALT; } return mask; -} +} #if LL_OS_DRAGDROP_ENABLED @@ -3517,53 +3518,53 @@ OSErr LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; lldebugs << "drag tracking handler, message = " << message << llendl; - + switch(message) { case kDragTrackingInWindow: result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_TRACK); break; - + case kDragTrackingEnterHandler: result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_START_TRACKING); break; - + case kDragTrackingLeaveHandler: result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_STOP_TRACKING); break; - + default: break; } - + return result; } -OSErr LLWindowMacOSX::dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, +OSErr LLWindowMacOSX::dragReceiveHandler(WindowRef theWindow, void * handlerRefCon, DragRef drag) -{ +{ LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon; return self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_DROPPED); } OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDropAction action) -{ +{ OSErr result = dragNotAcceptedErr; // overall function result OSErr err = noErr; // for local error handling - + // Get the mouse position and modifiers of this drag. SInt16 modifiers, mouseDownModifiers, mouseUpModifiers; ::GetDragModifiers(drag, &modifiers, &mouseDownModifiers, &mouseUpModifiers); MASK mask = LLWindowMacOSX::modifiersToMask(modifiers); - + Point mouse_point; // This will return the mouse point in global screen coords ::GetDragMouse(drag, &mouse_point, NULL); LLCoordScreen screen_coords(mouse_point.h, mouse_point.v); LLCoordGL gl_pos; convertCoords(screen_coords, &gl_pos); - + // Look at the pasteboard and try to extract an URL from it PasteboardRef pasteboard; if(GetDragPasteboard(drag, &pasteboard) == noErr) @@ -3571,22 +3572,22 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop ItemCount num_items = 0; // Treat an error here as an item count of 0 (void)PasteboardGetItemCount(pasteboard, &num_items); - + // Only deal with single-item drags. if(num_items == 1) { PasteboardItemID item_id = NULL; CFArrayRef flavors = NULL; CFDataRef data = NULL; - + err = PasteboardGetItemIdentifier(pasteboard, 1, &item_id); // Yes, this really is 1-based. - + // Try to extract an URL from the pasteboard if(err == noErr) { err = PasteboardCopyItemFlavors( pasteboard, item_id, &flavors); } - + if(err == noErr) { if(CFArrayContainsValue(flavors, CFRangeMake(0, CFArrayGetCount(flavors)), kUTTypeURL)) @@ -3599,9 +3600,9 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop // This is a string that might be an URL. err = PasteboardCopyItemFlavorData(pasteboard, item_id, kUTTypeUTF8PlainText, &data); } - + } - + if(flavors != NULL) { CFRelease(flavors); @@ -3612,12 +3613,12 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop std::string url; url.assign((char*)CFDataGetBytePtr(data), CFDataGetLength(data)); CFRelease(data); - + if(!url.empty()) { - LLWindowCallbacks::DragNDropResult res = + LLWindowCallbacks::DragNDropResult res = mCallbacks->handleDragNDrop(this, gl_pos, mask, action, url); - + switch (res) { case LLWindowCallbacks::DND_NONE: // No drop allowed if (action == LLWindowCallbacks::DNDA_TRACK) @@ -3652,7 +3653,7 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop // Restore the cursor ECursorType temp_cursor = mCurrentCursor; // get around the "setting the same cursor" code in setCursor() - mCurrentCursor = UI_CURSOR_COUNT; + mCurrentCursor = UI_CURSOR_COUNT; setCursor(temp_cursor); } else { @@ -3664,7 +3665,7 @@ OSErr LLWindowMacOSX::handleDragNDrop(DragRef drag, LLWindowCallbacks::DragNDrop } } } - + return result; } diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 6c9e075a21..073f294b54 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -58,7 +58,7 @@ public: /*virtual*/ BOOL getSize(LLCoordScreen *size); /*virtual*/ BOOL getSize(LLCoordWindow *size); /*virtual*/ BOOL setPosition(LLCoordScreen position); - /*virtual*/ BOOL setSize(LLCoordScreen size); + /*virtual*/ BOOL setSizeImpl(LLCoordScreen size); /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL); /*virtual*/ BOOL setCursorPosition(LLCoordWindow position); /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position); @@ -67,7 +67,7 @@ public: /*virtual*/ void showCursorFromMouseMove(); /*virtual*/ void hideCursorUntilMouseMove(); /*virtual*/ BOOL isCursorHidden(); - /*virtual*/ void setCursor(ECursorType cursor); + /*virtual*/ void updateCursor(); /*virtual*/ ECursorType getCursor() const; /*virtual*/ void captureMouse(); /*virtual*/ void releaseMouse(); diff --git a/indra/llwindow/llwindowmesaheadless.h b/indra/llwindow/llwindowmesaheadless.h index fd4bd635e2..8f70aee4f6 100644 --- a/indra/llwindow/llwindowmesaheadless.h +++ b/indra/llwindow/llwindowmesaheadless.h @@ -50,7 +50,7 @@ public: /*virtual*/ BOOL getSize(LLCoordScreen *size) {return FALSE;}; /*virtual*/ BOOL getSize(LLCoordWindow *size) {return FALSE;}; /*virtual*/ BOOL setPosition(LLCoordScreen position) {return FALSE;}; - /*virtual*/ BOOL setSize(LLCoordScreen size) {return FALSE;}; + /*virtual*/ BOOL setSizeImpl(LLCoordScreen size) {return FALSE;}; /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL) {return FALSE;}; /*virtual*/ BOOL setCursorPosition(LLCoordWindow position) {return FALSE;}; /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position) {return FALSE;}; @@ -59,7 +59,7 @@ public: /*virtual*/ void showCursorFromMouseMove() {}; /*virtual*/ void hideCursorUntilMouseMove() {}; /*virtual*/ BOOL isCursorHidden() {return FALSE;}; - /*virtual*/ void setCursor(ECursorType cursor) {}; + /*virtual*/ void updateCursor() {}; //virtual ECursorType getCursor() { return mCurrentCursor; }; /*virtual*/ void captureMouse() {}; /*virtual*/ void releaseMouse() {}; diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index e41aa9820f..5f5baceef8 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -963,7 +963,7 @@ BOOL LLWindowSDL::setPosition(const LLCoordScreen position) return TRUE; } -BOOL LLWindowSDL::setSize(const LLCoordScreen size) +BOOL LLWindowSDL::setSizeImpl(const LLCoordScreen size) { if(mWindow) { @@ -985,7 +985,6 @@ void LLWindowSDL::swapBuffers() { if (mWindow) { - glFinish(); SDL_GL_SwapBuffers(); } } @@ -1034,6 +1033,25 @@ void LLWindowSDL::setMouseClipping( BOOL b ) //SDL_WM_GrabInput(b ? SDL_GRAB_ON : SDL_GRAB_OFF); } +// virtual +void LLWindowSDL::setMinSize(U32 min_width, U32 min_height, bool enforce_immediately) +{ + LLWindow::setMinSize(min_width, min_height, enforce_immediately); + +#if LL_X11 + // Set the minimum size limits for X11 window + // so the window manager doesn't allow resizing below those limits. + XSizeHints* hints = XAllocSizeHints(); + hints->flags |= PMinSize; + hints->min_width = mMinWindowWidth; + hints->min_height = mMinWindowHeight; + + XSetWMNormalHints(mSDL_Display, mSDL_XWindowID, hints); + + XFree(hints); +#endif +} + BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position) { BOOL result = TRUE; @@ -1843,11 +1861,15 @@ void LLWindowSDL::gatherInput() break; case SDL_VIDEORESIZE: // *FIX: handle this? + { llinfos << "Handling a resize event: " << event.resize.w << "x" << event.resize.h << llendl; + S32 width = llmax(event.resize.w, (S32)mMinWindowWidth); + S32 height = llmax(event.resize.h, (S32)mMinWindowHeight); + // *FIX: I'm not sure this is necessary! - mWindow = SDL_SetVideoMode(event.resize.w, event.resize.h, 32, mSDLFlags); + mWindow = SDL_SetVideoMode(width, height, 32, mSDLFlags); if (!mWindow) { // *FIX: More informative dialog? @@ -1860,10 +1882,10 @@ void LLWindowSDL::gatherInput() } break; } - - mCallbacks->handleResize(this, event.resize.w, event.resize.h ); - break; + mCallbacks->handleResize(this, width, height); + break; + } case SDL_ACTIVEEVENT: if (event.active.state & SDL_APPINPUTFOCUS) { @@ -1914,6 +1936,8 @@ void LLWindowSDL::gatherInput() break; } } + + updateCursor(); #if LL_X11 // This is a good time to stop flashing the icon if our mFlashTimer has @@ -2000,7 +2024,7 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty return sdlcursor; } -void LLWindowSDL::setCursor(ECursorType cursor) +void LLWindowSDL::updateCursor() { if (ATIbug) { // cursor-updating is very flaky when this bug is @@ -2008,11 +2032,11 @@ void LLWindowSDL::setCursor(ECursorType cursor) return; } - if (mCurrentCursor != cursor) + if (mCurrentCursor != mNextCursor) { - if (cursor < UI_CURSOR_COUNT) + if (mNextCursor < UI_CURSOR_COUNT) { - SDL_Cursor *sdlcursor = mSDLCursors[cursor]; + SDL_Cursor *sdlcursor = mSDLCursors[mNextCursor]; // Try to default to the arrow for any cursors that // did not load correctly. if (!sdlcursor && mSDLCursors[UI_CURSOR_ARROW]) @@ -2020,9 +2044,9 @@ void LLWindowSDL::setCursor(ECursorType cursor) if (sdlcursor) SDL_SetCursor(sdlcursor); } else { - llwarns << "Tried to set invalid cursor number " << cursor << llendl; + llwarns << "Tried to set invalid cursor number " << mNextCursor << llendl; } - mCurrentCursor = cursor; + mCurrentCursor = mNextCursor; } } diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index fa544b16ce..59719e4046 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -63,7 +63,7 @@ public: /*virtual*/ BOOL getSize(LLCoordScreen *size); /*virtual*/ BOOL getSize(LLCoordWindow *size); /*virtual*/ BOOL setPosition(LLCoordScreen position); - /*virtual*/ BOOL setSize(LLCoordScreen size); + /*virtual*/ BOOL setSizeImpl(LLCoordScreen size); /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL); /*virtual*/ BOOL setCursorPosition(LLCoordWindow position); /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position); @@ -72,10 +72,11 @@ public: /*virtual*/ void showCursorFromMouseMove(); /*virtual*/ void hideCursorUntilMouseMove(); /*virtual*/ BOOL isCursorHidden(); - /*virtual*/ void setCursor(ECursorType cursor); + /*virtual*/ void updateCursor(); /*virtual*/ void captureMouse(); /*virtual*/ void releaseMouse(); /*virtual*/ void setMouseClipping( BOOL b ); + /*virtual*/ void setMinSize(U32 min_width, U32 min_height, bool enforce_immediately = true); /*virtual*/ BOOL isClipboardTextAvailable(); /*virtual*/ BOOL pasteTextFromClipboard(LLWString &dst); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 121c7880df..52c27b6736 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -41,6 +41,7 @@ #include "llgl.h" #include "llstring.h" #include "lldir.h" +#include "llglslshader.h" // System includes #include <commdlg.h> @@ -861,7 +862,7 @@ BOOL LLWindowWin32::setPosition(const LLCoordScreen position) return TRUE; } -BOOL LLWindowWin32::setSize(const LLCoordScreen size) +BOOL LLWindowWin32::setSizeImpl(const LLCoordScreen size) { LLCoordScreen position; @@ -1031,6 +1032,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO mhInstance, NULL); + LL_INFOS("Window") << "window is created." << llendl ; + //----------------------------------------------------------------------- // Create GL drawing context //----------------------------------------------------------------------- @@ -1120,8 +1123,10 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO return FALSE; } - gGLManager.initWGL(); + LL_INFOS("Window") << "Drawing context is created." << llendl ; + gGLManager.initWGL(); + if (wglChoosePixelFormatARB) { // OK, at this point, use the ARB wglChoosePixelFormatsARB function to see if we @@ -1256,7 +1261,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO LL_INFOS("Window") << "Choosing pixel formats: " << num_formats << " pixel formats returned" << LL_ENDL; } - + LL_INFOS("Window") << "pixel formats done." << llendl ; S32 swap_method = 0; S32 cur_format = num_formats-1; @@ -1306,6 +1311,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO mhInstance, NULL); + LL_INFOS("Window") << "recreate window done." << llendl ; + if (!(mhDC = GetDC(mWindowHandle))) { close(); @@ -1378,7 +1385,53 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO return FALSE; } - if (!(mhRC = wglCreateContext(mhDC))) + mhRC = 0; + if (wglCreateContextAttribsARB) + { //attempt to create a specific versioned context + S32 attribs[] = + { //start at 4.2 + WGL_CONTEXT_MAJOR_VERSION_ARB, 4, + WGL_CONTEXT_MINOR_VERSION_ARB, 2, + WGL_CONTEXT_PROFILE_MASK_ARB, LLRender::sGLCoreProfile ? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + WGL_CONTEXT_FLAGS_ARB, gDebugGL ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, + 0 + }; + + bool done = false; + while (!done) + { + mhRC = wglCreateContextAttribsARB(mhDC, mhRC, attribs); + + if (!mhRC) + { + if (attribs[3] > 0) + { //decrement minor version + attribs[3]--; + } + else if (attribs[1] > 3) + { //decrement major version and start minor version over at 3 + attribs[1]--; + attribs[3] = 3; + } + else + { //we reached 3.0 and still failed, bail out + done = true; + } + } + else + { + llinfos << "Created OpenGL " << llformat("%d.%d", attribs[1], attribs[3]) << " context." << llendl; + done = true; + + if (LLRender::sGLCoreProfile) + { + LLGLSLShader::sNoFixedFunction = true; + } + } + } + } + + if (!mhRC && !(mhRC = wglCreateContext(mhDC))) { close(); OSMessageBox(mCallbacks->translateString("MBGLContextErr"), mCallbacks->translateString("MBError"), OSMB_OK); @@ -1398,7 +1451,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO OSMessageBox(mCallbacks->translateString("MBVideoDrvErr"), mCallbacks->translateString("MBError"), OSMB_OK); return FALSE; } - + // Disable vertical sync for swap if (disable_vsync && wglSwapIntervalEXT) { @@ -1614,18 +1667,18 @@ void LLWindowWin32::initCursors() -void LLWindowWin32::setCursor(ECursorType cursor) +void LLWindowWin32::updateCursor() { - if (cursor == UI_CURSOR_ARROW + if (mNextCursor == UI_CURSOR_ARROW && mBusyCount > 0) { - cursor = UI_CURSOR_WORKING; + mNextCursor = UI_CURSOR_WORKING; } - if( mCurrentCursor != cursor ) + if( mCurrentCursor != mNextCursor ) { - mCurrentCursor = cursor; - SetCursor( mCursor[cursor] ); + mCurrentCursor = mNextCursor; + SetCursor( mCursor[mNextCursor] ); } } @@ -1707,6 +1760,8 @@ void LLWindowWin32::gatherInput() mInputProcessingPaused = FALSE; + updateCursor(); + // clear this once we've processed all mouse messages that might have occurred after // we slammed the mouse position mMousePositionModified = FALSE; @@ -2354,6 +2409,14 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ return 0; } + case WM_GETMINMAXINFO: + { + LPMINMAXINFO min_max = (LPMINMAXINFO)l_param; + min_max->ptMinTrackSize.x = window_imp->mMinWindowWidth; + min_max->ptMinTrackSize.y = window_imp->mMinWindowHeight; + return 0; + } + case WM_SIZE: { window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_SIZE"); @@ -2896,7 +2959,6 @@ BOOL LLWindowWin32::resetDisplayResolution() void LLWindowWin32::swapBuffers() { - glFinish(); SwapBuffers(mhDC); } diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h index 387e4cbdb6..b3602be8b7 100644 --- a/indra/llwindow/llwindowwin32.h +++ b/indra/llwindow/llwindowwin32.h @@ -57,7 +57,7 @@ public: /*virtual*/ BOOL getSize(LLCoordScreen *size); /*virtual*/ BOOL getSize(LLCoordWindow *size); /*virtual*/ BOOL setPosition(LLCoordScreen position); - /*virtual*/ BOOL setSize(LLCoordScreen size); + /*virtual*/ BOOL setSizeImpl(LLCoordScreen size); /*virtual*/ BOOL switchContext(BOOL fullscreen, const LLCoordScreen &size, BOOL disable_vsync, const LLCoordScreen * const posp = NULL); /*virtual*/ BOOL setCursorPosition(LLCoordWindow position); /*virtual*/ BOOL getCursorPosition(LLCoordWindow *position); @@ -66,7 +66,7 @@ public: /*virtual*/ void showCursorFromMouseMove(); /*virtual*/ void hideCursorUntilMouseMove(); /*virtual*/ BOOL isCursorHidden(); - /*virtual*/ void setCursor(ECursorType cursor); + /*virtual*/ void updateCursor(); /*virtual*/ ECursorType getCursor() const; /*virtual*/ void captureMouse(); /*virtual*/ void releaseMouse(); |