From f2ebdcbbec54b7bb28040212d313409376056d51 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Mon, 2 Aug 2021 17:47:47 -0400
Subject: [PATCH] Fix hidpi checkbox in graphics prefs being non-functional

---
 indra/llwindow/llopenglview-objc.mm |  5 ++++-
 indra/llwindow/llwindowmacosx.cpp   |  1 +
 indra/newview/llappviewer.cpp       | 10 +++++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 1459acd4966..4b22489b29f 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)
@@ -247,7 +249,8 @@ attributedStringInfo getSegments(NSAttributedString *str)
         }
         
         //for retina support
-        //[self setWantsBestResolutionOpenGLSurface:YES];
+        BOOL requestHiDPI = gHiDPISupport ? YES : NO;
+        [self setWantsBestResolutionOpenGLSurface:requestHiDPI];
         
         [self setPixelFormat:pixelFormat];
         
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index 217b1375c0e..292d021c785 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -43,6 +43,7 @@
 #include <CoreGraphics/CGDisplayConfiguration.h>
 
 extern BOOL gDebugWindowProc;
+BOOL gHiDPISupport = TRUE;
 
 const S32	BITS_PER_PIXEL = 32;
 const S32	MAX_NUM_RESOLUTIONS = 32;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 60ce92d81ae..54b4ee08215 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -290,6 +290,10 @@ extern BOOL gRandomizeFramerate;
 extern BOOL gPeriodicSlowFrame;
 extern BOOL gDebugGL;
 
+#if LL_DARWIN
+extern BOOL gHiDPISupport;
+#endif
+
 ////////////////////////////////////////////////////////////
 // All from the last globals push...
 
@@ -604,6 +608,10 @@ static void settings_to_globals()
 	gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc");
 	gShowObjectUpdates = gSavedSettings.getBOOL("ShowObjectUpdates");
 	LLWorldMapView::sMapScale = gSavedSettings.getF32("MapScale");
+	
+#if LL_DARWIN
+	gHiDPISupport = gSavedSettings.getBOOL("RenderHiDPI");
+#endif
 }
 
 static void settings_modify()
@@ -3204,7 +3212,7 @@ LLSD LLAppViewer::getViewerInfo() const
     info["TEXTURE_MEMORY"] = gSavedSettings.getS32("TextureMemory");
 
 #if LL_DARWIN
-    info["HIDPI"] = TRUE;
+    info["HIDPI"] = gHiDPISupport;
 #endif
 
 	// Libraries
-- 
GitLab