From 20a2019e4b5a3456d9d5b1ce647b5f459e6e29b1 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Mon, 3 Sep 2018 17:22:15 +0300 Subject: MAINT-9076 Improved support for Retina Displays --- indra/llwindow/llopenglview-objc.mm | 44 ++++++++++++++++++++++++----------- indra/llwindow/llwindow.h | 3 +++ indra/llwindow/llwindowmacosx-objc.h | 6 +++++ indra/llwindow/llwindowmacosx-objc.mm | 10 ++++++++ indra/llwindow/llwindowmacosx.cpp | 35 +++++++++++++++++----------- indra/llwindow/llwindowmacosx.h | 3 ++- 6 files changed, 72 insertions(+), 29 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index c8c086d705..de123d80d5 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -154,8 +154,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 +167,14 @@ attributedStringInfo getSegments(NSAttributedString *str) [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification 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 +186,8 @@ attributedStringInfo getSegments(NSAttributedString *str) { if (!mOldResize) //Maint-3288 { - NSSize size = [self frame].size; - callResize(size.width, size.height); + NSSize dev_sz = [self convertSizeToBacking:[self frame].size]; + callResize(dev_sz.width, dev_sz.height); } } @@ -258,7 +266,10 @@ attributedStringInfo getSegments(NSAttributedString *str) } [self setPixelFormat:pixelFormat]; - + + //for retina support + [self setWantsBestResolutionOpenGLSurface:YES]; + [self setOpenGLContext:glContext]; [glContext setView:self]; @@ -350,7 +361,7 @@ attributedStringInfo getSegments(NSAttributedString *str) callRightMouseUp(mMousePos, [theEvent modifierFlags]); mSimulatedRightClick = false; } else { - NSPoint mPoint = [theEvent locationInWindow]; + NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]]; mMousePos[0] = mPoint.x; mMousePos[1] = mPoint.y; callLeftMouseUp(mMousePos, [theEvent modifierFlags]); @@ -369,14 +380,16 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void)mouseMoved:(NSEvent *)theEvent { - float mouseDeltas[2] = { - float([theEvent deltaX]), - float([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 = [theEvent locationInWindow]; + NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]]; mMousePos[0] = mPoint.x; mMousePos[1] = mPoint.y; callMouseMoved(mMousePos, 0); @@ -390,14 +403,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 = [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])]; + + float mouseDeltas[] = { + float(dev_delta.x), + float(dev_delta.y) }; callDeltaUpdate(mouseDeltas, 0); - NSPoint mPoint = [theEvent locationInWindow]; + NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]]; mMousePos[0] = mPoint.x; mMousePos[1] = mPoint.y; callMouseDragged(mMousePos, 0); diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index a05ba8cbba..cb0daea2cd 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -166,6 +166,9 @@ public: // Provide native key event data virtual LLSD getNativeKeyData() { return LLSD::emptyMap(); } + // Default scale + virtual float getDeviceScaleFactor() { return 1.0f; } + // Get system UI size based on DPI (for 96 DPI UI size should be 1.0) virtual F32 getSystemUISize() { return 1.0; } protected: diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index b06cd2c184..ef5f803718 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -31,6 +31,9 @@ #include #include +//fir CGSize +#include + typedef std::vector > segment_t; typedef std::vector segment_lengths; @@ -101,11 +104,14 @@ void setResizeMode(bool oldresize, void* glview); NSWindowRef createNSWindow(int x, int y, int width, int height); #include + GLViewRef createOpenGLView(NSWindowRef window, unsigned int samples, bool vsync); void glSwapBuffers(void* context); CGLContextObj getCGLContextObj(GLViewRef view); unsigned long getVramSize(GLViewRef view); +float getDeviceUnitSize(GLViewRef view); void getContentViewBounds(NSWindowRef window, float* bounds); +const CGSize & getDeviceContentViewSize(NSWindowRef window, GLViewRef view); void getWindowSize(NSWindowRef window, float* size); void setWindowSize(NSWindowRef window, int width, int height); void getCursorPos(NSWindowRef window, float* pos); diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 43ce9a2255..489f92fa14 100644 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -253,6 +253,11 @@ unsigned long getVramSize(GLViewRef view) return [(LLOpenGLView *)view getVramSize]; } +float getDeviceUnitSize(GLViewRef view) +{ + return [(LLOpenGLView*)view convertSizeToBacking:NSMakeSize(1, 1)].width; +} + void getContentViewBounds(NSWindowRef window, float* bounds) { bounds[0] = [[(LLNSWindow*)window contentView] bounds].origin.x; @@ -261,6 +266,11 @@ void getContentViewBounds(NSWindowRef window, float* bounds) bounds[3] = [[(LLNSWindow*)window contentView] bounds].size.height; } +const CGSize & getDeviceContentViewSize(NSWindowRef window, GLViewRef view) +{ + return [(NSOpenGLView*)view convertRectToBacking:[[(LLNSWindow*)window contentView] bounds]].size; +} + void getWindowSize(NSWindowRef window, float* size) { NSRect frame = [(LLNSWindow*)window frame]; diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 843294c239..7f6b30bd37 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -845,7 +845,6 @@ BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position) BOOL LLWindowMacOSX::getSize(LLCoordScreen *size) { - float rect[4]; S32 err = -1; if(mFullscreen) @@ -856,10 +855,10 @@ BOOL LLWindowMacOSX::getSize(LLCoordScreen *size) } else if(mWindow) { - getContentViewBounds(mWindow, rect); + const CGSize & sz = getDeviceContentViewSize(mWindow, mGLView); - size->mX = rect[2]; - size->mY = rect[3]; + size->mX = sz.width; + size->mY = sz.height; } else { @@ -871,7 +870,6 @@ BOOL LLWindowMacOSX::getSize(LLCoordScreen *size) BOOL LLWindowMacOSX::getSize(LLCoordWindow *size) { - float rect[4]; S32 err = -1; if(mFullscreen) @@ -882,10 +880,10 @@ BOOL LLWindowMacOSX::getSize(LLCoordWindow *size) } else if(mWindow) { - getContentViewBounds(mWindow, rect); + const CGSize & sz = getDeviceContentViewSize(mWindow, mGLView); - size->mX = rect[2]; - size->mY = rect[3]; + size->mX = sz.width; + size->mY = sz.height; } else { @@ -1124,8 +1122,9 @@ BOOL LLWindowMacOSX::getCursorPosition(LLCoordWindow *position) cursor_point[1] += mCursorLastEventDeltaY; } - position->mX = cursor_point[0]; - position->mY = cursor_point[1]; + float scale = getDeviceScaleFactor(); + position->mX = cursor_point[0] * scale; + position->mY = cursor_point[1] * scale; return TRUE; } @@ -1318,8 +1317,9 @@ BOOL LLWindowMacOSX::convertCoords(LLCoordScreen from, LLCoordWindow* to) convertScreenToWindow(mWindow, mouse_point); - to->mX = mouse_point[0]; - to->mY = mouse_point[1]; + float scale_factor = getDeviceScaleFactor(); + to->mX = mouse_point[0] * scale_factor; + to->mY = mouse_point[1] * scale_factor; return TRUE; } @@ -1334,10 +1334,12 @@ BOOL LLWindowMacOSX::convertCoords(LLCoordWindow from, LLCoordScreen *to) mouse_point[0] = from.mX; mouse_point[1] = from.mY; + convertWindowToScreen(mWindow, mouse_point); - to->mX = mouse_point[0]; - to->mY = mouse_point[1]; + float scale_factor = getDeviceScaleFactor(); + to->mX = mouse_point[0] / scale_factor; + to->mY = mouse_point[1] / scale_factor; return TRUE; } @@ -1891,6 +1893,11 @@ MASK LLWindowMacOSX::modifiersToMask(S16 modifiers) return mask; } +F32 LLWindowMacOSX::getDeviceScaleFactor() +{ + return ::getDeviceUnitSize(mGLView); +} + #if LL_OS_DRAGDROP_ENABLED /* S16 LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow, diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 9e9bd8ae39..fc5c9a0054 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -112,6 +112,7 @@ public: /*virtual*/ void allowLanguageTextInput(LLPreeditor *preeditor, BOOL b); /*virtual*/ void interruptLanguageTextInput(); /*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async); + /*virtual*/ F32 getDeviceScaleFactor(); static std::vector getDynamicFallbackFontList(); @@ -135,7 +136,7 @@ protected: BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth, U32 fsaa_samples); - ~LLWindowMacOSX(); + ~LLWindowMacOSX(); void initCursors(); BOOL isValid(); -- cgit v1.2.3 From 6ce18422de822a195813e5daa890000e1556ac03 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Fri, 19 Oct 2018 19:12:08 +0300 Subject: SL-9766 [Render] [Mac] Alt + left mouse click has severely impaired functions --- indra/llwindow/llwindowmacosx.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 7f6b30bd37..b02b77ffbd 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -1317,9 +1317,8 @@ BOOL LLWindowMacOSX::convertCoords(LLCoordScreen from, LLCoordWindow* to) convertScreenToWindow(mWindow, mouse_point); - float scale_factor = getDeviceScaleFactor(); - to->mX = mouse_point[0] * scale_factor; - to->mY = mouse_point[1] * scale_factor; + to->mX = mouse_point[0]; + to->mY = mouse_point[1]; return TRUE; } @@ -1337,9 +1336,8 @@ BOOL LLWindowMacOSX::convertCoords(LLCoordWindow from, LLCoordScreen *to) convertWindowToScreen(mWindow, mouse_point); - float scale_factor = getDeviceScaleFactor(); - to->mX = mouse_point[0] / scale_factor; - to->mY = mouse_point[1] / scale_factor; + to->mX = mouse_point[0]; + to->mY = mouse_point[1]; return TRUE; } -- cgit v1.2.3 From eaeb8605d078846576304028cb46a57081abe113 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Tue, 23 Oct 2018 19:24:03 +0300 Subject: SL-9774 [Render] dragging active Second Life session to second monitor zooms in making viewer unusable --- indra/llwindow/llopenglview-objc.mm | 8 ++++++++ indra/llwindow/llwindowcallbacks.cpp | 5 +++++ indra/llwindow/llwindowcallbacks.h | 1 + indra/llwindow/llwindowmacosx-objc.h | 1 + indra/llwindow/llwindowmacosx.cpp | 8 ++++++++ 5 files changed, 23 insertions(+) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index de123d80d5..ee05fd5cc9 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -167,6 +167,9 @@ 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]; @@ -206,6 +209,11 @@ attributedStringInfo getSegments(NSAttributedString *str) mModifiers = [NSEvent modifierFlags]; } +-(void)windowDidChangeScreen:(NSNotification *)notification; +{ + callWindowDidChangeScreen(); +} + - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; diff --git a/indra/llwindow/llwindowcallbacks.cpp b/indra/llwindow/llwindowcallbacks.cpp index 7e90ade423..94c725fc7e 100644 --- a/indra/llwindow/llwindowcallbacks.cpp +++ b/indra/llwindow/llwindowcallbacks.cpp @@ -180,6 +180,11 @@ BOOL LLWindowCallbacks::handleDPIChanged(LLWindow *window, F32 ui_scale_factor, return FALSE; } +BOOL LLWindowCallbacks::handleWindowDidChangeScreen(LLWindow *window) +{ + return FALSE; +} + void LLWindowCallbacks::handlePingWatchdog(LLWindow *window, const char * msg) { diff --git a/indra/llwindow/llwindowcallbacks.h b/indra/llwindow/llwindowcallbacks.h index 47d5a18858..4d753024fe 100644 --- a/indra/llwindow/llwindowcallbacks.h +++ b/indra/llwindow/llwindowcallbacks.h @@ -66,6 +66,7 @@ public: virtual BOOL handleTimerEvent(LLWindow *window); virtual BOOL handleDeviceChange(LLWindow *window); virtual BOOL handleDPIChanged(LLWindow *window, F32 ui_scale_factor, S32 window_width, S32 window_height); + virtual BOOL handleWindowDidChangeScreen(LLWindow *window); enum DragNDropAction { DNDA_START_TRACKING = 0,// Start tracking an incoming drag diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index ef5f803718..743089be6b 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -147,6 +147,7 @@ void callWindowFocus(); void callWindowUnfocus(); void callWindowHide(); void callWindowUnhide(); +void callWindowDidChangeScreen(); void callDeltaUpdate(float *delta, unsigned int mask); void callMiddleMouseDown(float *pos, unsigned int mask); void callMiddleMouseUp(float *pos, unsigned int mask); diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index b02b77ffbd..376b8610b5 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -400,6 +400,14 @@ void callWindowUnhide() } } +void callWindowDidChangeScreen() +{ + if ( gWindowImplementation && gWindowImplementation->getCallbacks() ) + { + gWindowImplementation->getCallbacks()->handleWindowDidChangeScreen(gWindowImplementation); + } +} + void callDeltaUpdate(float *delta, MASK mask) { gWindowImplementation->updateMouseDeltas(delta); -- cgit v1.2.3 From acc86a9139872e182fbeb5b9fc7daa12c5d2c029 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Mon, 26 Nov 2018 18:02:44 +0200 Subject: =?UTF-8?q?SL-9766=20[Render]=20[Mac]=20Alt=20+=20left=20mouse=20c?= =?UTF-8?q?lick=20has=20severely=20impaired=20functions=20SL-10019=20-=20[?= =?UTF-8?q?Mac]=20[Render]=20Right-click=20context=20menu=20immediately=20?= =?UTF-8?q?disappears=20when=20clicking=20any=20place=20in=20the=20?= =?UTF-8?q?=E2=80=98Inventory=E2=80=99=20floater=20SL-9984=20-=20[Retina]?= =?UTF-8?q?=20Camera=20frustum,=20do=20not=20display=20correctly=20on=20"W?= =?UTF-8?q?ORLD=20MAP"=20window.=20SL-10027=20-=20[Mac]=20[Render]=20Add?= =?UTF-8?q?=20toggle=20for=20Retina=20support=20to=20mitigate=20FPS=20loss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-FIX for Retina support. --- indra/llwindow/llopenglview-objc.mm | 16 +++++++++------- indra/llwindow/llwindowmacosx-objc.h | 3 ++- indra/llwindow/llwindowmacosx-objc.mm | 12 +++++++----- indra/llwindow/llwindowmacosx.cpp | 19 ++++++++++++------- 4 files changed, 30 insertions(+), 20 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index ee05fd5cc9..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) @@ -189,7 +191,7 @@ attributedStringInfo getSegments(NSAttributedString *str) { if (!mOldResize) //Maint-3288 { - NSSize dev_sz = [self convertSizeToBacking:[self frame].size]; + NSSize dev_sz = gHiDPISupport ? [self convertSizeToBacking:[self frame].size] : [self frame].size; callResize(dev_sz.width, dev_sz.height); } } @@ -276,7 +278,7 @@ attributedStringInfo getSegments(NSAttributedString *str) [self setPixelFormat:pixelFormat]; //for retina support - [self setWantsBestResolutionOpenGLSurface:YES]; + [self setWantsBestResolutionOpenGLSurface:gHiDPISupport]; [self setOpenGLContext:glContext]; @@ -369,7 +371,7 @@ attributedStringInfo getSegments(NSAttributedString *str) callRightMouseUp(mMousePos, [theEvent modifierFlags]); mSimulatedRightClick = false; } else { - NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]]; + NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; mMousePos[0] = mPoint.x; mMousePos[1] = mPoint.y; callLeftMouseUp(mMousePos, [theEvent modifierFlags]); @@ -388,7 +390,7 @@ attributedStringInfo getSegments(NSAttributedString *str) - (void)mouseMoved:(NSEvent *)theEvent { - NSPoint dev_delta = [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])]; + NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]); float mouseDeltas[] = { float(dev_delta.x), @@ -397,7 +399,7 @@ attributedStringInfo getSegments(NSAttributedString *str) callDeltaUpdate(mouseDeltas, 0); - NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]]; + NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; mMousePos[0] = mPoint.x; mMousePos[1] = mPoint.y; callMouseMoved(mMousePos, 0); @@ -412,7 +414,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 = [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])]; + NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]); float mouseDeltas[] = { float(dev_delta.x), @@ -421,7 +423,7 @@ attributedStringInfo getSegments(NSAttributedString *str) callDeltaUpdate(mouseDeltas, 0); - NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]]; + NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; mMousePos[0] = mPoint.x; mMousePos[1] = mPoint.y; callMouseDragged(mMousePos, 0); diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index 743089be6b..34da99de19 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -110,7 +110,8 @@ void glSwapBuffers(void* context); CGLContextObj getCGLContextObj(GLViewRef view); unsigned long getVramSize(GLViewRef view); float getDeviceUnitSize(GLViewRef view); -void getContentViewBounds(NSWindowRef window, float* bounds); +const CGPoint & getContentViewBoundsPosition(NSWindowRef window); +const CGSize & getContentViewBoundsSize(NSWindowRef window); const CGSize & getDeviceContentViewSize(NSWindowRef window, GLViewRef view); void getWindowSize(NSWindowRef window, float* size); void setWindowSize(NSWindowRef window, int width, int height); diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 489f92fa14..156d7965cd 100644 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -258,12 +258,14 @@ float getDeviceUnitSize(GLViewRef view) return [(LLOpenGLView*)view convertSizeToBacking:NSMakeSize(1, 1)].width; } -void getContentViewBounds(NSWindowRef window, float* bounds) +const CGPoint & getContentViewBoundsPosition(NSWindowRef window) { - bounds[0] = [[(LLNSWindow*)window contentView] bounds].origin.x; - bounds[1] = [[(LLNSWindow*)window contentView] bounds].origin.y; - bounds[2] = [[(LLNSWindow*)window contentView] bounds].size.width; - bounds[3] = [[(LLNSWindow*)window contentView] bounds].size.height; + return [[(LLNSWindow*)window contentView] bounds].origin; +} + +const CGSize & getContentViewBoundsSize(NSWindowRef window) +{ + return [[(LLNSWindow*)window contentView] bounds].size; } const CGSize & getDeviceContentViewSize(NSWindowRef window, GLViewRef view) diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 376b8610b5..20853eebd9 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -43,6 +43,7 @@ #include extern BOOL gDebugWindowProc; +BOOL gHiDPISupport = TRUE; const S32 BITS_PER_PIXEL = 32; const S32 MAX_NUM_RESOLUTIONS = 32; @@ -827,7 +828,6 @@ void LLWindowMacOSX::gatherInput() BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position) { - float rect[4]; S32 err = -1; if(mFullscreen) @@ -838,10 +838,12 @@ BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position) } else if(mWindow) { - getContentViewBounds(mWindow, rect); + const CGPoint & pos = getContentViewBoundsPosition(mWindow); - position->mX = rect[0]; - position->mY = rect[1]; + position->mX = pos.x; + position->mY = pos.y; + + err = noErr; } else { @@ -863,7 +865,7 @@ BOOL LLWindowMacOSX::getSize(LLCoordScreen *size) } else if(mWindow) { - const CGSize & sz = getDeviceContentViewSize(mWindow, mGLView); + const CGSize & sz = gHiDPISupport ? getDeviceContentViewSize(mWindow, mGLView) : getContentViewBoundsSize(mWindow); size->mX = sz.width; size->mY = sz.height; @@ -888,7 +890,7 @@ BOOL LLWindowMacOSX::getSize(LLCoordWindow *size) } else if(mWindow) { - const CGSize & sz = getDeviceContentViewSize(mWindow, mGLView); + const CGSize & sz = gHiDPISupport ? getDeviceContentViewSize(mWindow, mGLView) : getContentViewBoundsSize(mWindow); size->mX = sz.width; size->mY = sz.height; @@ -1100,6 +1102,9 @@ BOOL LLWindowMacOSX::setCursorPosition(const LLCoordWindow position) // trigger mouse move callback LLCoordGL gl_pos; convertCoords(position, &gl_pos); + float scale = getDeviceScaleFactor(); + gl_pos.mX *= scale; + gl_pos.mY *= scale; mCallbacks->handleMouseMove(this, gl_pos, (MASK)0); return result; @@ -1901,7 +1906,7 @@ MASK LLWindowMacOSX::modifiersToMask(S16 modifiers) F32 LLWindowMacOSX::getDeviceScaleFactor() { - return ::getDeviceUnitSize(mGLView); + return gHiDPISupport ? ::getDeviceUnitSize(mGLView) : LLWindow::getDeviceScaleFactor(); } #if LL_OS_DRAGDROP_ENABLED -- cgit v1.2.3 From 6c8cfff7aba5a757499bde55aef6a70d1443a09f Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Tue, 11 Dec 2018 18:11:58 +0200 Subject: SL-10176 - [Love Me Render] MacOS Quit / Shutdown crash --- indra/llwindow/llwindowmacosx-objc.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 156d7965cd..c3eb9b8c8a 100644 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -380,8 +380,8 @@ void closeWindow(NSWindowRef window) void removeGLView(GLViewRef view) { + [(LLOpenGLView*)view clearGLContext]; [(LLOpenGLView*)view removeFromSuperview]; - [(LLOpenGLView*)view release]; } void setupInputWindow(NSWindowRef window, GLViewRef glview) -- cgit v1.2.3 From f6bccd6f9eb62178f9f3d912114d12a84a9e42d6 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Mon, 14 Jan 2019 19:07:00 +0200 Subject: - remove getDeviceScaleFactor() and replace it to getSystemUISize() according Ansariel note --- indra/llwindow/llwindow.h | 3 --- indra/llwindow/llwindowmacosx.cpp | 8 ++++---- indra/llwindow/llwindowmacosx.h | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index cb0daea2cd..a05ba8cbba 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -166,9 +166,6 @@ public: // Provide native key event data virtual LLSD getNativeKeyData() { return LLSD::emptyMap(); } - // Default scale - virtual float getDeviceScaleFactor() { return 1.0f; } - // Get system UI size based on DPI (for 96 DPI UI size should be 1.0) virtual F32 getSystemUISize() { return 1.0; } protected: diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 20853eebd9..b320b93d43 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -1102,7 +1102,7 @@ BOOL LLWindowMacOSX::setCursorPosition(const LLCoordWindow position) // trigger mouse move callback LLCoordGL gl_pos; convertCoords(position, &gl_pos); - float scale = getDeviceScaleFactor(); + float scale = getSystemUISize(); gl_pos.mX *= scale; gl_pos.mY *= scale; mCallbacks->handleMouseMove(this, gl_pos, (MASK)0); @@ -1135,7 +1135,7 @@ BOOL LLWindowMacOSX::getCursorPosition(LLCoordWindow *position) cursor_point[1] += mCursorLastEventDeltaY; } - float scale = getDeviceScaleFactor(); + float scale = getSystemUISize(); position->mX = cursor_point[0] * scale; position->mY = cursor_point[1] * scale; @@ -1904,9 +1904,9 @@ MASK LLWindowMacOSX::modifiersToMask(S16 modifiers) return mask; } -F32 LLWindowMacOSX::getDeviceScaleFactor() +F32 LLWindowMacOSX::getSystemUISize() { - return gHiDPISupport ? ::getDeviceUnitSize(mGLView) : LLWindow::getDeviceScaleFactor(); + return gHiDPISupport ? ::getDeviceUnitSize(mGLView) : LLWindow::getSystemUISize(); } #if LL_OS_DRAGDROP_ENABLED diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index fc5c9a0054..24651027e8 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -112,7 +112,7 @@ public: /*virtual*/ void allowLanguageTextInput(LLPreeditor *preeditor, BOOL b); /*virtual*/ void interruptLanguageTextInput(); /*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async); - /*virtual*/ F32 getDeviceScaleFactor(); + /*virtual*/ F32 getSystemUISize(); static std::vector getDynamicFallbackFontList(); -- cgit v1.2.3