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.mm54
1 files changed, 40 insertions, 14 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index c8c086d705..54a4793b2d 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"
+extern BOOL gHiDPISupport;
+
#pragma mark local functions
NativeKeyEventData extractKeyDataFromKeyEvent(NSEvent* theEvent)
@@ -154,8 +156,8 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowResized:) name:NSWindowDidResizeNotification
- object:[self window]];
-
+ object:[self window]];
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowWillMiniaturize:) name:NSWindowWillMiniaturizeNotification
object:[self window]];
@@ -167,6 +169,17 @@ attributedStringInfo getSegments(NSAttributedString *str)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification
object:[self window]];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(windowDidChangeScreen:) name:NSWindowDidChangeScreenNotification
+ object:[self window]];
+
+
+ NSRect wnd_rect = [[self window] frame];
+ NSRect dev_rect = [self convertRectToBacking:wnd_rect];
+ if (!NSEqualSizes(wnd_rect.size,dev_rect.size))
+ {
+ callResize(dev_rect.size.width, dev_rect.size.height);
+ }
}
- (void)setOldResize:(bool)oldresize
@@ -178,8 +191,8 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
if (!mOldResize) //Maint-3288
{
- NSSize size = [self frame].size;
- callResize(size.width, size.height);
+ NSSize dev_sz = gHiDPISupport ? [self convertSizeToBacking:[self frame].size] : [self frame].size;
+ callResize(dev_sz.width, dev_sz.height);
}
}
@@ -198,6 +211,11 @@ attributedStringInfo getSegments(NSAttributedString *str)
mModifiers = [NSEvent modifierFlags];
}
+-(void)windowDidChangeScreen:(NSNotification *)notification;
+{
+ callWindowDidChangeScreen();
+}
+
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -258,7 +276,10 @@ attributedStringInfo getSegments(NSAttributedString *str)
}
[self setPixelFormat:pixelFormat];
-
+
+ //for retina support
+ [self setWantsBestResolutionOpenGLSurface:gHiDPISupport];
+
[self setOpenGLContext:glContext];
[glContext setView:self];
@@ -350,7 +371,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
callRightMouseUp(mMousePos, [theEvent modifierFlags]);
mSimulatedRightClick = false;
} else {
- NSPoint mPoint = [theEvent locationInWindow];
+ NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
callLeftMouseUp(mMousePos, [theEvent modifierFlags]);
@@ -369,14 +390,16 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void)mouseMoved:(NSEvent *)theEvent
{
- float mouseDeltas[2] = {
- float([theEvent deltaX]),
- float([theEvent deltaY])
+ NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]);
+
+ float mouseDeltas[] = {
+ float(dev_delta.x),
+ float(dev_delta.y)
};
callDeltaUpdate(mouseDeltas, 0);
- NSPoint mPoint = [theEvent locationInWindow];
+ NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
callMouseMoved(mMousePos, 0);
@@ -390,14 +413,17 @@ attributedStringInfo getSegments(NSAttributedString *str)
// 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] = {
- float([theEvent deltaX]),
- float([theEvent deltaY])
+
+ NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]);
+
+ float mouseDeltas[] = {
+ float(dev_delta.x),
+ float(dev_delta.y)
};
callDeltaUpdate(mouseDeltas, 0);
- NSPoint mPoint = [theEvent locationInWindow];
+ NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
callMouseDragged(mMousePos, 0);