summaryrefslogtreecommitdiff
path: root/indra/llwindow/llopenglview-objc.mm
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow/llopenglview-objc.mm')
-rw-r--r--indra/llwindow/llopenglview-objc.mm159
1 files changed, 55 insertions, 104 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 937c3c7a6e..f3aa164f92 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -28,6 +28,8 @@
#import "llwindowmacosx-objc.h"
#import "llappdelegate-objc.h"
+#import <Carbon/Carbon.h>
+
extern BOOL gHiDPISupport;
#pragma mark local functions
@@ -105,34 +107,10 @@ attributedStringInfo getSegments(NSAttributedString *str)
return screen;
}
-
-- (NSPoint)convertPointToScreenCoordinates:(NSPoint)aPoint
-{
- float normalizedX = fabs(fabs(self.frame.origin.x) - fabs(aPoint.x));
- float normalizedY = aPoint.y - self.frame.origin.y;
-
- return NSMakePoint(normalizedX, normalizedY);
-}
-
-- (NSPoint)flipPoint:(NSPoint)aPoint
-{
- return NSMakePoint(aPoint.x, self.frame.size.height - aPoint.y);
-}
-
@end
@implementation LLOpenGLView
-// Force a high quality update after live resizing
-- (void) viewDidEndLiveResize
-{
- if (mOldResize) //Maint-3135
- {
- NSSize size = [self frame].size;
- callResize(size.width, size.height);
- }
-}
-
- (unsigned long)getVramSize
{
CGLRendererInfoObj info = 0;
@@ -187,18 +165,10 @@ attributedStringInfo getSegments(NSAttributedString *str)
}
}
-- (void)setOldResize:(bool)oldresize
-{
- mOldResize = oldresize;
-}
-
- (void)windowResized:(NSNotification *)notification;
{
- if (!mOldResize) //Maint-3288
- {
- NSSize dev_sz = gHiDPISupport ? [self convertSizeToBacking:[self frame].size] : [self frame].size;
- callResize(dev_sz.width, dev_sz.height);
- }
+ NSSize dev_sz = [self convertSizeToBacking:[self frame].size];
+ callResize(dev_sz.width, dev_sz.height);
}
- (void)windowWillMiniaturize:(NSNotification *)notification;
@@ -242,9 +212,15 @@ attributedStringInfo getSegments(NSAttributedString *str)
return [self initWithFrame:[self bounds] withSamples:samples andVsync:vsync];
}
+#if LL_DARWIN
+// For setView and opengl deprecation
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
- (id) initWithFrame:(NSRect)frame withSamples:(NSUInteger)samples andVsync:(BOOL)vsync
{
- [self registerForDraggedTypes:[NSArray arrayWithObject:NSURLPboardType]];
+ [self registerForDraggedTypes:[NSArray arrayWithObject:NSPasteboardTypeURL]];
[self initWithFrame:frame];
// Initialize with a default "safe" pixel format that will work with versions dating back to OS X 10.6.
@@ -255,8 +231,8 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFAAccelerated,
- NSOpenGLPFASampleBuffers, static_cast<NSOpenGLPixelFormatAttribute>(samples > 0 ? 1 : 0),
- NSOpenGLPFASamples, static_cast<NSOpenGLPixelFormatAttribute>(samples),
+ NSOpenGLPFASampleBuffers, 0,
+ NSOpenGLPFASamples, 0,
NSOpenGLPFAStencilSize, 8,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAAlphaSize, 8,
@@ -295,17 +271,15 @@ attributedStringInfo getSegments(NSAttributedString *str)
if (vsync)
{
GLint value = 1;
- [glContext setValues:&value forParameter:NSOpenGLCPSwapInterval];
+ [glContext setValues:&value forParameter:NSOpenGLContextParameterSwapInterval];
} else {
// supress this error after move to Xcode 7:
// error: null passed to a callee that requires a non-null argument [-Werror,-Wnonnull]
// Tried using ObjC 'nonnull' keyword as per SO article but didn't build
GLint swapInterval=0;
- [glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
+ [glContext setValues:&swapInterval forParameter:NSOpenGLContextParameterSwapInterval];
}
-
- mOldResize = false;
-
+
return self;
}
@@ -333,6 +307,10 @@ attributedStringInfo getSegments(NSAttributedString *str)
return true;
}
+#if LL_DARWIN
+#pragma clang diagnostic pop
+#endif
+
- (CGLContextObj)getCGLContextObj
{
NSOpenGLContext *ctx = [self openGLContext];
@@ -350,18 +328,14 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) mouseDown:(NSEvent *)theEvent
{
- NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
- mMousePos[0] = mPoint.x;
- mMousePos[1] = mPoint.y;
-
// Apparently people still use this?
- if ([theEvent modifierFlags] & NSCommandKeyMask &&
- !([theEvent modifierFlags] & NSControlKeyMask) &&
- !([theEvent modifierFlags] & NSShiftKeyMask) &&
- !([theEvent modifierFlags] & NSAlternateKeyMask) &&
- !([theEvent modifierFlags] & NSAlphaShiftKeyMask) &&
- !([theEvent modifierFlags] & NSFunctionKeyMask) &&
- !([theEvent modifierFlags] & NSHelpKeyMask))
+ if ([theEvent modifierFlags] & NSEventModifierFlagCommand &&
+ !([theEvent modifierFlags] & NSEventModifierFlagControl) &&
+ !([theEvent modifierFlags] & NSEventModifierFlagShift) &&
+ !([theEvent modifierFlags] & NSEventModifierFlagOption) &&
+ !([theEvent modifierFlags] & NSEventModifierFlagCapsLock) &&
+ !([theEvent modifierFlags] & NSEventModifierFlagFunction) &&
+ !([theEvent modifierFlags] & NSEventModifierFlagHelp))
{
callRightMouseDown(mMousePos, [theEvent modifierFlags]);
mSimulatedRightClick = true;
@@ -382,7 +356,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
callRightMouseUp(mMousePos, [theEvent modifierFlags]);
mSimulatedRightClick = false;
} else {
- NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
+ NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
callLeftMouseUp(mMousePos, [theEvent modifierFlags]);
@@ -391,32 +365,26 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) rightMouseDown:(NSEvent *)theEvent
{
- NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
- mMousePos[0] = mPoint.x;
- mMousePos[1] = mPoint.y;
callRightMouseDown(mMousePos, [theEvent modifierFlags]);
}
- (void) rightMouseUp:(NSEvent *)theEvent
{
- NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
- mMousePos[0] = mPoint.x;
- mMousePos[1] = mPoint.y;
callRightMouseUp(mMousePos, [theEvent modifierFlags]);
}
- (void)mouseMoved:(NSEvent *)theEvent
{
- NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]);
+ NSPoint dev_delta = [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])];
float mouseDeltas[] = {
float(dev_delta.x),
float(dev_delta.y)
};
-
+
callDeltaUpdate(mouseDeltas, 0);
-
- NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
+
+ NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
callMouseMoved(mMousePos, 0);
@@ -431,7 +399,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
// The old CoreGraphics APIs we previously relied on are now flagged as obsolete.
// NSEvent isn't obsolete, and provides us with the correct deltas.
- NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]);
+ NSPoint dev_delta = [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])];
float mouseDeltas[] = {
float(dev_delta.x),
@@ -440,7 +408,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
callDeltaUpdate(mouseDeltas, 0);
- NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
+ NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
callMouseDragged(mMousePos, 0);
@@ -448,17 +416,11 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) otherMouseDown:(NSEvent *)theEvent
{
- NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
- mMousePos[0] = mPoint.x;
- mMousePos[1] = mPoint.y;
callOtherMouseDown(mMousePos, [theEvent modifierFlags], [theEvent buttonNumber]);
}
- (void) otherMouseUp:(NSEvent *)theEvent
{
- NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
- mMousePos[0] = mPoint.x;
- mMousePos[1] = mPoint.y;
callOtherMouseUp(mMousePos, [theEvent modifierFlags], [theEvent buttonNumber]);
}
@@ -511,7 +473,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
if (acceptsText &&
!mMarkedTextAllowed &&
- !(mModifiers & (NSControlKeyMask | NSCommandKeyMask)) && // commands don't invoke InputWindow
+ !(mModifiers & (NSEventModifierFlagControl | NSEventModifierFlagCommand)) && // commands don't invoke InputWindow
![(LLAppDelegate*)[NSApp delegate] romanScript] &&
ch > ' ' &&
ch != NSDeleteCharacter &&
@@ -534,14 +496,14 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSInteger mask = 0;
switch([theEvent keyCode])
{
- case 56:
- mask = NSShiftKeyMask;
+ case kVK_Shift:
+ mask = NSEventModifierFlagShift;
break;
- case 58:
- mask = NSAlternateKeyMask;
+ case kVK_Option:
+ mask = NSEventModifierFlagOption;
break;
- case 59:
- mask = NSControlKeyMask;
+ case kVK_Control:
+ mask = NSEventModifierFlagControl;
break;
default:
return;
@@ -582,7 +544,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
pboard = [sender draggingPasteboard];
- if ([[pboard types] containsObject:NSURLPboardType])
+ if ([[pboard types] containsObject:NSPasteboardTypeURL])
{
if (sourceDragMask & NSDragOperationLink) {
NSURL *fileUrl = [[pboard readObjectsForClasses:[NSArray arrayWithObject:[NSURL class]] options:[NSDictionary dictionary]] objectAtIndex:0];
@@ -695,6 +657,12 @@ attributedStringInfo getSegments(NSAttributedString *str)
}
}
+#if LL_DARWIN
+// For commitEditing deprecation
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
- (void)commitCurrentPreedit
{
if (mHasMarkedText)
@@ -706,6 +674,10 @@ attributedStringInfo getSegments(NSAttributedString *str)
}
}
+#if LL_DARWIN
+#pragma clang diagnostic pop
+#endif
+
- (void)unmarkText
{
[[self inputContext] discardMarkedText];
@@ -785,9 +757,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) insertNewline:(id)sender
{
- if (!(mModifiers & NSCommandKeyMask) &&
- !(mModifiers & NSShiftKeyMask) &&
- !(mModifiers & NSAlternateKeyMask))
+ if (!(mModifiers & NSEventModifierFlagCommand) &&
+ !(mModifiers & NSEventModifierFlagShift) &&
+ !(mModifiers & NSEventModifierFlagOption))
{
callUnicodeCallback(13, 0);
} else {
@@ -906,27 +878,6 @@ attributedStringInfo getSegments(NSAttributedString *str)
return self;
}
-- (NSPoint)convertToScreenFromLocalPoint:(NSPoint)point relativeToView:(NSView *)view
-{
- NSScreen *currentScreen = [NSScreen currentScreenForMouseLocation];
- if(currentScreen)
- {
- NSPoint windowPoint = [view convertPoint:point toView:nil];
- NSPoint screenPoint = [[view window] convertBaseToScreen:windowPoint];
- NSPoint flippedScreenPoint = [currentScreen flipPoint:screenPoint];
- flippedScreenPoint.y += [currentScreen frame].origin.y;
-
- return flippedScreenPoint;
- }
-
- return NSZeroPoint;
-}
-
-- (NSPoint)flipPoint:(NSPoint)aPoint
-{
- return NSMakePoint(aPoint.x, self.frame.size.height - aPoint.y);
-}
-
- (BOOL) becomeFirstResponder
{
callFocus();