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 requestsmaster
parent
7a1593c083
commit
ddb48d51d9
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
// 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) otherMouseDown:(NSEvent *)theEvent
|
||||
{
|
||||
callMiddleMouseDown(mMousePos, 0);
|
||||
}
|
||||
|
||||
- (void) otherMouseUp:(NSEvent *)theEvent
|
||||
{
|
||||
callMiddleMouseUp(mMousePos, 0);
|
||||
}
|
||||
|
||||
- (void) otherMouseDragged:(NSEvent *)theEvent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void) scrollWheel:(NSEvent *)theEvent
|
||||
{
|
||||
if (mScrollWhellCallback != nil)
|
||||
{
|
||||
mScrollWhellCallback(-[theEvent deltaY]);
|
||||
}
|
||||
callScrollMoved(-[theEvent deltaY]);
|
||||
}
|
||||
|
||||
- (void) mouseExited:(NSEvent *)theEvent
|
||||
{
|
||||
if (mMouseExitCallback != nil)
|
||||
{
|
||||
mMouseExitCallback();
|
||||
}
|
||||
callMouseExit();
|
||||
}
|
||||
|
||||
- (void) registerKeyDownCallback:(KeyCallback)callback
|
||||
- (BOOL) becomeFirstResponder
|
||||
{
|
||||
mKeyDownCallback = callback;
|
||||
NSLog(@"Window gained focus!");
|
||||
callFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
- (void) registerKeyUpCallback:(KeyCallback)callback
|
||||
- (BOOL) resignFirstResponder
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
- (void) registerRightMouseDownCallback:(MouseCallback)callback
|
||||
{
|
||||
mRightMouseDownCallback = callback;
|
||||
}
|
||||
|
||||
- (void) registerRightMouseUpCallback:(MouseCallback)callback
|
||||
{
|
||||
mRightMouseUpCallback = callback;
|
||||
}
|
||||
|
||||
- (void) registerDoubleClickCallback:(MouseCallback)callback
|
||||
{
|
||||
mMouseDoubleClickCallback = callback;
|
||||
}
|
||||
|
||||
- (void) registerMouseMovedCallback:(MouseCallback)callback
|
||||
{
|
||||
mMouseMovedCallback = callback;
|
||||
}
|
||||
|
||||
- (void) registerScrollCallback:(ScrollWheelCallback)callback
|
||||
{
|
||||
mScrollWhellCallback = callback;
|
||||
}
|
||||
|
||||
- (void) registerMouseExitCallback:(VoidCallback)callback
|
||||
{
|
||||
mMouseExitCallback = callback;
|
||||
}
|
||||
|
||||
- (void) registerDeltaUpdateCallback:(MouseCallback)callback
|
||||
{
|
||||
mDeltaUpdateCallback = callback;
|
||||
NSLog(@"Window lost focus!");
|
||||
callFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
void closeWindow(NSWindowRef window)
|
||||
{
|
||||
[(LLNSWindow*)window registerKeyUpCallback:callback];
|
||||
[(LLNSWindow*)window close];
|
||||
}
|
||||
|
||||
void registerKeyDownCallback(NSWindowRef window, std::tr1::function<void(unsigned short, unsigned int)> callback)
|
||||
void removeGLView(GLViewRef view)
|
||||
{
|
||||
[(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)
|
||||
{
|
||||
[(LLNSWindow*)window registerMouseExitCallback:callback];
|
||||
}
|
||||
|
||||
void registerDeltaUpdateCallback(NSWindowRef window, MouseCallback callback)
|
||||
{
|
||||
[(LLNSWindow*)window registerDeltaUpdateCallback:callback];
|
||||
[(LLOpenGLView*)view removeFromSuperview];
|
||||
[(LLOpenGLView*)view release];
|
||||
}
|
||||
|
||||
NSWindowRef getMainAppWindow()
|
||||
{
|
||||
[(LLNSWindow*)winRef setAcceptsMouseMovedEvents:TRUE];
|
||||
return winRef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 LLWindowMacOSX::updateMouseDeltas()
|
||||
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(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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ public:
|
|||
void* getWindow() { return mWindow; }
|
||||
LLWindowCallbacks* getCallbacks() { return mCallbacks; }
|
||||
|
||||
void updateMouseDeltas();
|
||||
void updateMouseDeltas(float* deltas);
|
||||
void getMouseDeltas(float* delta);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ bool initViewer();
|
|||
void handleQuit();
|
||||
bool runMainLoop();
|
||||
void initMainLoop();
|
||||
void destroyMainLoop();
|
||||
void cleanupViewer();
|
||||
|
|
@ -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()
|
||||
|
|
@ -94,6 +85,24 @@ bool initViewer()
|
|||
}
|
||||
|
||||
void handleQuit()
|
||||
{
|
||||
LLAppViewer::instance()->userQuit();
|
||||
}
|
||||
|
||||
bool runMainLoop()
|
||||
{
|
||||
bool ret = LLApp::isQuitting();
|
||||
if (!ret && gViewerAppPtr != NULL)
|
||||
{
|
||||
ret = gViewerAppPtr->mainLoop();
|
||||
} else {
|
||||
ret = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void cleanupViewer()
|
||||
{
|
||||
if(!LLApp::isError())
|
||||
{
|
||||
|
|
@ -104,17 +113,6 @@ void handleQuit()
|
|||
gViewerAppPtr = NULL;
|
||||
}
|
||||
|
||||
bool runMainLoop()
|
||||
{
|
||||
bool ret = LLApp::isQuitting();
|
||||
if (!ret)
|
||||
{
|
||||
ret = gViewerAppPtr->mainLoop();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
// Store off the command line args for use later.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue