diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index fd4efe5346..6ff41698f6 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -168,7 +168,10 @@ public:
virtual LLSD getNativeKeyData() { return LLSD::emptyMap(); }
// Get system UI size based on DPI (for 96 DPI UI size should be 1.0)
- virtual F32 getSystemUISize() { return 1.0f; }
+ // Determine scaling of the display we show the viewer
+ //virtual F32 getSystemUISize() { return 1.0f; }
+ virtual F32 getSystemUISize(S32 x, S32 y) { return 1.0f; }
+ //
// Window Title Access
//this needs to be overridden for all platforms
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index 1144b75257..65605a1c22 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -3966,7 +3966,10 @@ BOOL LLWindowWin32::handleImeRequests(WPARAM request, LPARAM param, LRESULT *res
return FALSE;
}
-F32 LLWindowWin32::getSystemUISize()
+// Determine scaling of the display we show the viewer
+//F32 LLWindowWin32::getSystemUISize()
+F32 LLWindowWin32::getSystemUISize(S32 x, S32 y)
+//
{
// Type fix
//float scale_value = 0;
@@ -3993,15 +3996,30 @@ F32 LLWindowWin32::getSystemUISize()
HRESULT hr = E_FAIL;
// Get the DPI for the main monitor, and set the scaling factor
- pt.x = 1;
- pt.y = 1;
- // Get scaling for primary display, assuming that's where we open the viewer
- //hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
- hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
+ // Determine scaling of the display we show the viewer
+ //pt.x = 1;
+ //pt.y = 1;
+ pt.x = x;
+ pt.y = y;
//
+ hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
hr = pGDFM(hMonitor, MDT_EFFECTIVE_DPI, &dpix, &dpiy);
- scale_value = dpix / 96.0f;
+ // Check result before using it
+ //scale_value = dpix / 96.0f;
+ if (hr == S_OK)
+ {
+ scale_value = dpix / 96.0f;
+ }
+ else
+ {
+ LL_WARNS() << "Could not determine DPI for monitor. Defaulting to 100 %" << LL_ENDL;
+ scale_value = 1.0f;
+ }
+ //
}
+
+ // Free library early - not needed anymore
+ FreeLibrary(hShcore);
}
else
{
diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h
index 15c968e82f..5d106ea79c 100644
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -111,7 +111,10 @@ public:
/*virtual*/ void spawnWebBrowser(const std::string& escaped_url, bool async);
void openFile(const std::string& file_name);
- /*virtual*/ F32 getSystemUISize();
+ // Determine scaling of the display we show the viewer
+ /*virtual*/ //F32 getSystemUISize();
+ /*virtual*/ F32 getSystemUISize(S32 x, S32 y);
+ //
// Window Title Access
/*virtual*/ void setTitle(const std::string& win_title);
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 2eae87250a..f19bde8216 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1821,7 +1821,10 @@ LLViewerWindow::LLViewerWindow(const Params& p)
}
- F32 system_scale_factor = mWindow->getSystemUISize();
+ // Determine scaling of the display we show the viewer
+ //F32 system_scale_factor = mWindow->getSystemUISize();
+ F32 system_scale_factor = mWindow->getSystemUISize(p.x, p.y);
+ //
if (p.first_run || gSavedSettings.getF32("LastSystemUIScaleFactor") != system_scale_factor)
{
mSystemUIScaleFactorChanged = true;