diff options
author | Geenz <geenz@geenzo.com> | 2013-01-01 11:32:53 -0500 |
---|---|---|
committer | Geenz <geenz@geenzo.com> | 2013-01-01 11:32:53 -0500 |
commit | ddb48d51d996b18063b111faa3b7e709160074d9 (patch) | |
tree | f64cab16299cec07756dea34823ab3749b4d1ec3 /indra | |
parent | 7a1593c083a7ed6e3d6589d5dd656354d748b8ce (diff) |
More things in this commit:
- Removed the callback system in favor of simply defining functions in a header to later be implemented in whichever file is most convenient for what we want to do (i.e., calling LLWindow callbacks within LLWindowMacOSX, setting cursors in llwindowmacosx-objc.mm, etc.)
- Viewer shutdown now works appropriately
- Added a bit of debugging code to test if a key has been handled by the UI or not (useful for tracking down the mystery of the enter key not being handled)
- Setup a cocoa quit handler within the application delegate that intercepts any termination requests
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llwindow/llopenglview-objc.h | 30 | ||||
-rw-r--r-- | indra/llwindow/llopenglview-objc.mm | 214 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx-objc.h | 38 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx-objc.mm | 74 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx.cpp | 73 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx.h | 2 | ||||
-rw-r--r-- | indra/newview/llappviewermacosx-delegate.mm | 18 | ||||
-rw-r--r-- | indra/newview/llappviewermacosx-objc.h | 2 | ||||
-rw-r--r-- | indra/newview/llappviewermacosx.cpp | 32 | ||||
-rw-r--r-- | indra/newview/llviewerkeyboard.cpp | 2 |
10 files changed, 201 insertions, 284 deletions
diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h index 6b055bc665..20589e321d 100644 --- a/indra/llwindow/llopenglview-objc.h +++ b/indra/llwindow/llopenglview-objc.h @@ -15,7 +15,6 @@ @interface LLOpenGLView : NSOpenGLView { NSPoint mousePos; - ResizeCallback mResizeCallback; } - (id) initWithFrame:(NSRect)frame withSamples:(NSUInteger)samples andVsync:(BOOL)vsync; @@ -33,42 +32,13 @@ - (CGLContextObj) getCGLContextObj; - (CGLPixelFormatObj*)getCGLPixelFormatObj; -- (void) registerResizeCallback:(ResizeCallback)callback; @end @interface LLNSWindow : NSWindow { float mMousePos[2]; unsigned int mModifiers; - - KeyCallback mKeyDownCallback; - KeyCallback mKeyUpCallback; - UnicodeCallback mUnicodeCallback; - ModifierCallback mModifierCallback; - MouseCallback mMouseDownCallback; - MouseCallback mMouseUpCallback; - MouseCallback mMouseDoubleClickCallback; - MouseCallback mRightMouseDownCallback; - MouseCallback mRightMouseUpCallback; - MouseCallback mMouseMovedCallback; - ScrollWheelCallback mScrollWhellCallback; - VoidCallback mMouseExitCallback; - MouseCallback mDeltaUpdateCallback; } -- (void) registerKeyDownCallback:(KeyCallback)callback; -- (void) registerKeyUpCallback:(KeyCallback)callback; -- (void) registerUnicodeCallback:(UnicodeCallback)callback; -- (void) registerModifierCallback:(ModifierCallback)callback; -- (void) registerMouseDownCallback:(MouseCallback)callback; -- (void) registerMouseUpCallback:(MouseCallback)callback; -- (void) registerRightMouseDownCallback:(MouseCallback)callback; -- (void) registerRightMouseUpCallback:(MouseCallback)callback; -- (void) registerDoubleClickCallback:(MouseCallback)callback; -- (void) registerMouseMovedCallback:(MouseCallback)callback; -- (void) registerScrollCallback:(ScrollWheelCallback)callback; -- (void) registerMouseExitCallback:(VoidCallback)callback; -- (void) registerDeltaUpdateCallback:(MouseCallback)callback; - @end void setLLNSWindowRef(LLNSWindow* window); diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 7c148f4acd..cb8d7b315f 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -19,12 +19,9 @@ - (void)windowResized:(NSNotification *)notification; { - if (mResizeCallback != nil) - { - NSSize size = [[self window] frame].size; - - mResizeCallback(size.width, size.height); - } + NSSize size = [self frame].size; + + callResize(size.width, size.height); } - (void)dealloc @@ -125,11 +122,6 @@ return (CGLPixelFormatObj*)[fmt CGLPixelFormatObj]; } -- (void) registerResizeCallback:(ResizeCallback)callback -{ - mResizeCallback = callback; -} - // Various events can be intercepted by our view, thus not reaching our window. // Intercept these events, and pass them to the window as needed. - Geenz @@ -183,6 +175,16 @@ [super flagsChanged:theEvent]; } +- (BOOL) becomeFirstResponder +{ + return [super becomeFirstResponder]; +} + +- (BOOL) resignFirstResponder +{ + return [super resignFirstResponder]; +} + @end // We use a custom NSWindow for our event handling. @@ -196,30 +198,19 @@ return self; } -- (void) keyDown:(NSEvent *)theEvent { - if (mKeyDownCallback != nil && mUnicodeCallback != nil) +- (void) keyDown:(NSEvent *)theEvent +{ + callKeyDown([theEvent keyCode], [theEvent modifierFlags]); + + NSString *chars = [theEvent characters]; + for (uint i = 0; i < [chars length]; i++) { - mKeyDownCallback([theEvent keyCode], [theEvent modifierFlags]); - - NSString *chars = [theEvent charactersIgnoringModifiers]; - for (uint i = 0; i < [chars length]; i++) - { - mUnicodeCallback([chars characterAtIndex:i], [theEvent modifierFlags]); - } - - // The viewer expects return to be submitted separately as a unicode character. - if ([theEvent keyCode] == 3 || [theEvent keyCode] == 13) - { - mUnicodeCallback([theEvent keyCode], [theEvent modifierFlags]); - } + callUnicodeCallback([chars characterAtIndex:i], [theEvent modifierFlags]); } } - (void) keyUp:(NSEvent *)theEvent { - if (mKeyUpCallback != nil) - { - mKeyUpCallback([theEvent keyCode], [theEvent modifierFlags]); - } + callKeyUp([theEvent keyCode], [theEvent modifierFlags]); } - (void)flagsChanged:(NSEvent *)theEvent { @@ -228,59 +219,42 @@ - (void) mouseDown:(NSEvent *)theEvent { - if (mMouseDoubleClickCallback != nil && mMouseDownCallback != nil) + if ([theEvent clickCount] >= 2) { - if ([theEvent clickCount] == 2) - { - mMouseDoubleClickCallback(mMousePos, [theEvent modifierFlags]); - } else if ([theEvent clickCount] == 1) { - mMouseDownCallback(mMousePos, [theEvent modifierFlags]); - } + callDoubleClick(mMousePos, [theEvent modifierFlags]); + } else if ([theEvent clickCount] == 1) { + callLeftMouseDown(mMousePos, [theEvent modifierFlags]); } } - (void) mouseUp:(NSEvent *)theEvent { - if (mMouseUpCallback != nil) - { - mMouseUpCallback(mMousePos, [theEvent modifierFlags]); - } + callLeftMouseUp(mMousePos, [theEvent modifierFlags]); } - (void) rightMouseDown:(NSEvent *)theEvent { - if (mRightMouseDownCallback != nil) - { - mRightMouseDownCallback(mMousePos, [theEvent modifierFlags]); - } + callRightMouseDown(mMousePos, [theEvent modifierFlags]); } - (void) rightMouseUp:(NSEvent *)theEvent { - if (mRightMouseUpCallback != nil) - { - mRightMouseUpCallback(mMousePos, [theEvent modifierFlags]); - } + callRightMouseUp(mMousePos, [theEvent modifierFlags]); } -- (void)mouseMoved:(NSEvent *)theEvent { - if (mDeltaUpdateCallback != nil && mMouseMovedCallback != nil) - { - float mouseDeltas[2] = { - [theEvent deltaX], - [theEvent deltaZ] - }; - - mDeltaUpdateCallback(mouseDeltas, 0); - - NSPoint mPoint = [theEvent locationInWindow]; - mMousePos[0] = mPoint.x; - mMousePos[1] = mPoint.y; - if (mMouseMovedCallback != nil) - { - mMouseMovedCallback(mMousePos, 0); - } - } +- (void)mouseMoved:(NSEvent *)theEvent +{ + float mouseDeltas[2] = { + [theEvent deltaX], + [theEvent deltaY] + }; + + callDeltaUpdate(mouseDeltas, 0); + + NSPoint mPoint = [theEvent locationInWindow]; + mMousePos[0] = mPoint.x; + mMousePos[1] = mPoint.y; + callMouseMoved(mMousePos, 0); } // NSWindow doesn't trigger mouseMoved when the mouse is being clicked and dragged. @@ -288,101 +262,59 @@ - (void) mouseDragged:(NSEvent *)theEvent { - if (mDeltaUpdateCallback != nil && mMouseMovedCallback != nil) - { - float mouseDeltas[2] = { - [theEvent deltaX], - [theEvent deltaZ] - }; - - mDeltaUpdateCallback(mouseDeltas, 0); - - NSPoint mPoint = [theEvent locationInWindow]; - mMousePos[0] = mPoint.x; - mMousePos[1] = mPoint.y; - mMouseMovedCallback(mMousePos, 0); - } -} - -- (void) scrollWheel:(NSEvent *)theEvent -{ - if (mScrollWhellCallback != nil) - { - mScrollWhellCallback(-[theEvent deltaY]); - } -} - -- (void) mouseExited:(NSEvent *)theEvent -{ - if (mMouseExitCallback != nil) - { - mMouseExitCallback(); - } -} - -- (void) registerKeyDownCallback:(KeyCallback)callback -{ - mKeyDownCallback = callback; -} - -- (void) registerKeyUpCallback:(KeyCallback)callback -{ - mKeyUpCallback = callback; -} - -- (void) registerUnicodeCallback:(UnicodeCallback)callback -{ - mUnicodeCallback = callback; -} - -- (void) registerModifierCallback:(ModifierCallback)callback -{ - mModifierCallback = callback; -} - -- (void) registerMouseDownCallback:(MouseCallback)callback -{ - mMouseDownCallback = callback; -} - -- (void) registerMouseUpCallback:(MouseCallback)callback -{ - mMouseUpCallback = callback; + // Trust the deltas supplied by NSEvent. + // The old CoreGraphics APIs we previously relied on are now flagged as obsolete. + // NSEvent isn't obsolete, and provides us with the correct deltas. + float mouseDeltas[2] = { + [theEvent deltaX], + [theEvent deltaY] + }; + + callDeltaUpdate(mouseDeltas, 0); + + NSPoint mPoint = [theEvent locationInWindow]; + mMousePos[0] = mPoint.x; + mMousePos[1] = mPoint.y; + callMouseMoved(mMousePos, 0); } -- (void) registerRightMouseDownCallback:(MouseCallback)callback +- (void) otherMouseDown:(NSEvent *)theEvent { - mRightMouseDownCallback = callback; + callMiddleMouseDown(mMousePos, 0); } -- (void) registerRightMouseUpCallback:(MouseCallback)callback +- (void) otherMouseUp:(NSEvent *)theEvent { - mRightMouseUpCallback = callback; + callMiddleMouseUp(mMousePos, 0); } -- (void) registerDoubleClickCallback:(MouseCallback)callback +- (void) otherMouseDragged:(NSEvent *)theEvent { - mMouseDoubleClickCallback = callback; + } -- (void) registerMouseMovedCallback:(MouseCallback)callback +- (void) scrollWheel:(NSEvent *)theEvent { - mMouseMovedCallback = callback; + callScrollMoved(-[theEvent deltaY]); } -- (void) registerScrollCallback:(ScrollWheelCallback)callback +- (void) mouseExited:(NSEvent *)theEvent { - mScrollWhellCallback = callback; + callMouseExit(); } -- (void) registerMouseExitCallback:(VoidCallback)callback +- (BOOL) becomeFirstResponder { - mMouseExitCallback = callback; + NSLog(@"Window gained focus!"); + callFocus(); + return true; } -- (void) registerDeltaUpdateCallback:(MouseCallback)callback +- (BOOL) resignFirstResponder { - mDeltaUpdateCallback = callback; + NSLog(@"Window lost focus!"); + callFocus(); + return true; } @end diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index abaeda1f91..655d63ac12 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -65,21 +65,33 @@ void getCursorPos(NSWindowRef window, float* pos); void makeWindowOrderFront(NSWindowRef window); void convertScreenToWindow(NSWindowRef window, float *coord); void convertWindowToScreen(NSWindowRef window, float *coord); +void convertScreenToView(NSWindowRef window, float *coord); void setWindowPos(NSWindowRef window, float* pos); +void closeWindow(NSWindowRef window); +void removeGLView(GLViewRef view); + +// These are all implemented in llwindowmacosx.cpp. +// This is largely for easier interop between Obj-C and C++ (at least in the viewer's case due to the BOOL vs. BOOL conflict) +void callKeyUp(unsigned short key, unsigned int mask); +void callKeyDown(unsigned short key, unsigned int mask); +void callUnicodeCallback(wchar_t character, unsigned int mask); +void callRightMouseDown(float *pos, unsigned int mask); +void callRightMouseUp(float *pos, unsigned int mask); +void callLeftMouseDown(float *pos, unsigned int mask); +void callLeftMouseUp(float *pos, unsigned int mask); +void callDoubleClick(float *pos, unsigned int mask); +void callResize(unsigned int width, unsigned int height); +void callMouseMoved(float *pos, unsigned int mask); +void callScrollMoved(float delta); +void callMouseExit(); +void callWindowFocus(); +void callWindowUnfocus(); +void callDeltaUpdate(float *delta, unsigned int mask); +void callMiddleMouseDown(float *pos, unsigned int mask); +void callMiddleMouseUp(float *pos, unsigned int mask); +void callFocus(); +void callFocusLost(); -void registerKeyUpCallback(NSWindowRef window, KeyCallback callback); -void registerKeyDownCallback(NSWindowRef window, KeyCallback callback); -void registerUnicodeCallback(NSWindowRef window, UnicodeCallback callback); -void registerMouseUpCallback(NSWindowRef window, MouseCallback callback); -void registerMouseDownCallback(NSWindowRef window, MouseCallback callback); -void registerRightMouseUpCallback(NSWindowRef window, MouseCallback callback); -void registerRightMouseDownCallback(NSWindowRef window, MouseCallback callback); -void registerDoubleClickCallback(NSWindowRef window, MouseCallback callback); -void registerResizeEventCallback(GLViewRef window, ResizeCallback callback); -void registerMouseMovedCallback(NSWindowRef window, MouseCallback callback); -void registerScrollCallback(NSWindowRef window, ScrollWheelCallback callback); -void registerMouseExitCallback(NSWindowRef window, VoidCallback callback); -void registerDeltaUpdateCallback(NSWindowRef window, MouseCallback callback); NSWindowRef getMainAppWindow(); GLViewRef getGLView(NSWindowRef window); diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 07efc25ea6..f3972303f1 100644 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -255,6 +255,15 @@ void convertScreenToWindow(NSWindowRef window, float *coord) coord[1] = point.y; } +void convertScreenToView(NSWindowRef window, float *coord) +{ + NSRect point; + point.origin.x = coord[0]; + point.origin.y = coord[1]; + point.origin = [(LLNSWindow*)window convertScreenToBase:point.origin]; + point.origin = [[(LLNSWindow*)window contentView] convertPoint:point.origin fromView:nil]; +} + void convertWindowToScreen(NSWindowRef window, float *coord) { NSPoint point; @@ -265,73 +274,20 @@ void convertWindowToScreen(NSWindowRef window, float *coord) coord[1] = point.y; } -void registerKeyUpCallback(NSWindowRef window, std::tr1::function<void(unsigned short, unsigned int)> callback) -{ - [(LLNSWindow*)window registerKeyUpCallback:callback]; -} - -void registerKeyDownCallback(NSWindowRef window, std::tr1::function<void(unsigned short, unsigned int)> callback) -{ - [(LLNSWindow*)window registerKeyDownCallback:callback]; -} - -void registerUnicodeCallback(NSWindowRef window, std::tr1::function<void(wchar_t, unsigned int)> callback) -{ - [(LLNSWindow*)window registerUnicodeCallback:callback]; -} - -void registerMouseUpCallback(NSWindowRef window, MouseCallback callback) -{ - [(LLNSWindow*)window registerMouseUpCallback:callback]; -} - -void registerMouseDownCallback(NSWindowRef window, MouseCallback callback) -{ - [(LLNSWindow*)window registerMouseDownCallback:callback]; -} - -void registerRightMouseUpCallback(NSWindowRef window, MouseCallback callback) -{ - [(LLNSWindow*)window registerRightMouseUpCallback:callback]; -} - -void registerRightMouseDownCallback(NSWindowRef window, MouseCallback callback) -{ - [(LLNSWindow*)window registerRightMouseDownCallback:callback]; -} - -void registerDoubleClickCallback(NSWindowRef window, MouseCallback callback) -{ - [(LLNSWindow*)window registerDoubleClickCallback:callback]; -} - -void registerResizeEventCallback(GLViewRef glview, ResizeCallback callback) -{ - [(LLOpenGLView*)glview registerResizeCallback:callback]; -} - -void registerMouseMovedCallback(NSWindowRef window, MouseCallback callback) -{ - [(LLNSWindow*)window registerMouseMovedCallback:callback]; -} - -void registerScrollCallback(NSWindowRef window, ScrollWheelCallback callback) -{ - [(LLNSWindow*)window registerScrollCallback:callback]; -} - -void registerMouseExitCallback(NSWindowRef window, VoidCallback callback) +void closeWindow(NSWindowRef window) { - [(LLNSWindow*)window registerMouseExitCallback:callback]; + [(LLNSWindow*)window close]; } -void registerDeltaUpdateCallback(NSWindowRef window, MouseCallback callback) +void removeGLView(GLViewRef view) { - [(LLNSWindow*)window registerDeltaUpdateCallback:callback]; + [(LLOpenGLView*)view removeFromSuperview]; + [(LLOpenGLView*)view release]; } NSWindowRef getMainAppWindow() { + [(LLNSWindow*)winRef setAcceptsMouseMovedEvents:TRUE]; return winRef; } diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index a616b2df2d..cfdfbe2138 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -198,7 +198,7 @@ LLWindowMacOSX::LLWindowMacOSX(LLWindowCallbacks* callbacks, } -// These functions are used as callbacks for event handling within Cocoa. +// These functions are used as wrappers for our internal event handling callbacks. // It's a good idea to wrap these to avoid reworking more code than we need to within LLWindow. void callKeyUp(unsigned short key, unsigned int mask) @@ -216,9 +216,14 @@ void callUnicodeCallback(wchar_t character, unsigned int mask) gWindowImplementation->getCallbacks()->handleUnicodeChar(character, mask); } -void callModifierCallback(unsigned int mask) +void callFocus() { - + gWindowImplementation->getCallbacks()->handleFocus(gWindowImplementation); +} + +void callFocusLost() +{ + gWindowImplementation->getCallbacks()->handleFocusLost(gWindowImplementation); } void callRightMouseDown(float *pos, MASK mask) @@ -302,17 +307,41 @@ void callWindowUnfocus() void callDeltaUpdate(float *delta, MASK mask) { - gWindowImplementation->updateMouseDeltas(); + gWindowImplementation->updateMouseDeltas(delta); +} + +void callMiddleMouseDown(float *pos, MASK mask) +{ + LLCoordGL outCoords; + outCoords.mX = llround(pos[0]); + outCoords.mY = llround(pos[1]); + float deltas[2]; + gWindowImplementation->getMouseDeltas(deltas); + outCoords.mX += deltas[0]; + outCoords.mY += deltas[1]; + gWindowImplementation->getCallbacks()->handleMiddleMouseDown(gWindowImplementation, outCoords, mask); +} + +void callMiddleMouseUp(float *pos, MASK mask) +{ + LLCoordGL outCoords; + outCoords.mX = llround(pos[0]); + outCoords.mY = llround(pos[1]); + float deltas[2]; + gWindowImplementation->getMouseDeltas(deltas); + outCoords.mX += deltas[0]; + outCoords.mY += deltas[1]; + gWindowImplementation->getCallbacks()->handleMiddleMouseUp(gWindowImplementation, outCoords, mask); } -void LLWindowMacOSX::updateMouseDeltas() +void LLWindowMacOSX::updateMouseDeltas(float* deltas) { if (mCursorDecoupled) { - CGMouseDelta x, y; - CGGetLastMouseDelta( &x, &y ); - mCursorLastEventDeltaX = x; - mCursorLastEventDeltaY = y; + mCursorLastEventDeltaX = llround(deltas[0]); + mCursorLastEventDeltaY = llround(-deltas[1]); + + if (mCursorIgnoreNextDelta) { @@ -320,6 +349,7 @@ void LLWindowMacOSX::updateMouseDeltas() mCursorLastEventDeltaY = 0; mCursorIgnoreNextDelta = FALSE; } + LL_INFOS("Delta Update") << "Last event delta: " << mCursorLastEventDeltaX << ", " << mCursorLastEventDeltaY << LL_ENDL; } else { mCursorLastEventDeltaX = 0; mCursorLastEventDeltaY = 0; @@ -342,6 +372,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits { LL_INFOS("Window") << "Creating window..." << LL_ENDL; mWindow = getMainAppWindow(); + /* LL_INFOS("Window") << "Registering key callbacks..." << LL_ENDL; registerKeyDownCallback(mWindow, callKeyDown); registerKeyUpCallback(mWindow, callKeyUp); @@ -355,6 +386,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits registerScrollCallback(mWindow, callScrollMoved); registerDeltaUpdateCallback(mWindow, callDeltaUpdate); registerMouseExitCallback(mWindow, callMouseExit); + */ } if(mContext == NULL) @@ -363,7 +395,7 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits // Our OpenGL view is already defined within SecondLife.xib. // Get the view instead. mGLView = createOpenGLView(mWindow); - registerResizeEventCallback(mGLView, callResize); + //registerResizeEventCallback(mGLView, callResize); mContext = getCGLContextObj(mGLView); // Since we just created the context, it needs to be set up. glNeedsInit = TRUE; @@ -439,9 +471,7 @@ void LLWindowMacOSX::destroyContext() if(mContext != NULL) { LL_DEBUGS("Window") << "destroyContext: unhooking drawable " << LL_ENDL; - CGLSetCurrentContext(NULL); - mContext = NULL; } // Clean up remaining GL state before blowing away window @@ -454,16 +484,25 @@ void LLWindowMacOSX::destroyContext() mPixelFormat = NULL; } - // Close the window - if(mWindow != NULL) - { - } - // Clean up the GL context if(mContext != NULL) { CGLDestroyContext(mContext); } + + // Destroy our LLOpenGLView + if(mGLView != NULL) + { + removeGLView(mGLView); + mGLView = NULL; + } + + // Close the window + if(mWindow != NULL) + { + closeWindow(mWindow); + mWindow = NULL; + } } diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 487af7658f..c5e1b2290b 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -121,7 +121,7 @@ public: void* getWindow() { return mWindow; } LLWindowCallbacks* getCallbacks() { return mCallbacks; } - void updateMouseDeltas(); + void updateMouseDeltas(float* deltas); void getMouseDeltas(float* delta); diff --git a/indra/newview/llappviewermacosx-delegate.mm b/indra/newview/llappviewermacosx-delegate.mm index 80cc1010e9..2e25997d32 100644 --- a/indra/newview/llappviewermacosx-delegate.mm +++ b/indra/newview/llappviewermacosx-delegate.mm @@ -23,17 +23,26 @@ frameTimer = nil; setLLNSWindowRef([self window]); - setLLOpenGLViewRef([self glview]); + //setLLOpenGLViewRef([self glview]); if (initViewer()) { - frameTimer = [NSTimer scheduledTimerWithTimeInterval:1.0/60 target:self selector:@selector(mainLoop) userInfo:nil repeats:YES]; + frameTimer = [NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(mainLoop) userInfo:nil repeats:YES]; } else { handleQuit(); } } -- (void) applicationWillTerminate:(NSNotification *)notification +- (NSApplicationDelegateReply) applicationShouldTerminate:(NSApplication *)sender { + if (!runMainLoop()) + { + handleQuit(); + return NSTerminateCancel; + } else { + [frameTimer release]; + cleanupViewer(); + return NSTerminateNow; + } } - (void) mainLoop @@ -42,7 +51,8 @@ if (appExiting) { [frameTimer release]; - handleQuit(); + cleanupViewer(); + [[NSApplication sharedApplication] terminate:self]; } } diff --git a/indra/newview/llappviewermacosx-objc.h b/indra/newview/llappviewermacosx-objc.h index 9ece6a1a6a..ed9017ca5d 100644 --- a/indra/newview/llappviewermacosx-objc.h +++ b/indra/newview/llappviewermacosx-objc.h @@ -16,4 +16,4 @@ bool initViewer(); void handleQuit(); bool runMainLoop(); void initMainLoop(); -void destroyMainLoop();
\ No newline at end of file +void cleanupViewer();
\ No newline at end of file diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index a1c8b7699d..6e7b91347b 100644 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -55,15 +55,6 @@ namespace char** gArgV; LLAppViewerMacOSX* gViewerAppPtr; - - OSErr AEQuitHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn) - { - OSErr result = noErr; - - LLAppViewer::instance()->userQuit(); - - return(result); - } } bool initViewer() @@ -95,26 +86,33 @@ bool initViewer() void handleQuit() { - if(!LLApp::isError()) - { - gViewerAppPtr->cleanup(); - } - - delete gViewerAppPtr; - gViewerAppPtr = NULL; + LLAppViewer::instance()->userQuit(); } bool runMainLoop() { bool ret = LLApp::isQuitting(); - if (!ret) + if (!ret && gViewerAppPtr != NULL) { ret = gViewerAppPtr->mainLoop(); + } else { + ret = true; } return ret; } +void cleanupViewer() +{ + if(!LLApp::isError()) + { + gViewerAppPtr->cleanup(); + } + + delete gViewerAppPtr; + gViewerAppPtr = NULL; +} + int main( int argc, char **argv ) { // Store off the command line args for use later. diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp index 6d91dad70e..92d8f2937e 100644 --- a/indra/newview/llviewerkeyboard.cpp +++ b/indra/newview/llviewerkeyboard.cpp @@ -654,7 +654,6 @@ BOOL LLViewerKeyboard::modeFromString(const std::string& string, S32 *mode) BOOL LLViewerKeyboard::handleKey(KEY translated_key, MASK translated_mask, BOOL repeated) { LL_INFOS("Keyboard Handling") << "Handling key " << translated_key << LL_ENDL; - LL_INFOS("Keyboard Handling") << "Keyboard has focus? " << gFocusMgr.getKeyboardFocus() << LL_ENDL; // check for re-map EKeyboardMode mode = gViewerKeyboard.getMode(); U32 keyidx = (translated_mask<<16) | translated_key; @@ -677,6 +676,7 @@ BOOL LLViewerKeyboard::handleKey(KEY translated_key, MASK translated_mask, BOOL if(mKeysSkippedByUI.find(translated_key) != mKeysSkippedByUI.end()) { mKeyHandledByUI[translated_key] = FALSE; + LL_INFOS("Keyboard Handling") << "Key wasn't handled by UI!" << LL_ENDL; } else { |