diff --git a/Core/Core.cpp b/Core/Core.cpp index 764686dc2a..36486d9670 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -130,21 +130,6 @@ bool Core_GetPowerSaving() { return powerSaving; } -#ifdef _WIN32 -#if PPSSPP_PLATFORM(UWP) -static int ScreenDPI() { - return 96; // TODO UWP -} -#else -static int ScreenDPI() { - HDC screenDC = GetDC(nullptr); - int dotsPerInch = GetDeviceCaps(screenDC, LOGPIXELSY); - ReleaseDC(nullptr, screenDC); - return dotsPerInch; -} -#endif -#endif - static bool IsWindowSmall(int pixelWidth, int pixelHeight) { // Can't take this from config as it will not be set if windows is maximized. int w = (int)(pixelWidth * g_dpi_scale); @@ -156,10 +141,7 @@ static bool IsWindowSmall(int pixelWidth, int pixelHeight) { bool UpdateScreenScale(int width, int height) { bool smallWindow; #ifdef _WIN32 - // Use legacy DPI handling, because we still compile as XP compatible we don't get the new SDK, unless - // we do unholy tricks. - - g_dpi = ScreenDPI(); + g_dpi = System_GetPropertyInt(SYSPROP_DISPLAY_DPI); g_dpi_scale = 96.0f / g_dpi; #else g_dpi = 96; diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 698ec084c3..3990a249fd 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -394,7 +394,12 @@ namespace MainWindow if (g_Config.iWindowWidth <= 0 || g_Config.iWindowHeight <= 0) { RECT rcInner = rc, rcOuter; bool portrait = g_Config.IsPortrait(); - GetWindowRectAtResolution(2 * (portrait ? 272 : 480), 2 * (portrait ? 480 : 272), rcInner, rcOuter); + + // We want to adjust for DPI but still get an integer pixel scaling ratio. + double dpi_scale = 96.0 / System_GetPropertyInt(SYSPROP_DISPLAY_DPI); + int scale = (int)ceil(2.0 / dpi_scale); + + GetWindowRectAtResolution(scale * (portrait ? 272 : 480), scale * (portrait ? 480 : 272), rcInner, rcOuter); rc.right = rc.left + (rcOuter.right - rcOuter.left); rc.bottom = rc.top + (rcOuter.bottom - rcOuter.top); g_Config.iWindowWidth = rc.right - rc.left; diff --git a/Windows/main.cpp b/Windows/main.cpp index b0d56c816a..d37b3491e0 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -187,6 +187,21 @@ std::string System_GetProperty(SystemProperty prop) { // Ugly! extern WindowsAudioBackend *winAudioBackend; +#ifdef _WIN32 +#if PPSSPP_PLATFORM(UWP) +static int ScreenDPI() { + return 96; // TODO UWP +} +#else +static int ScreenDPI() { + HDC screenDC = GetDC(nullptr); + int dotsPerInch = GetDeviceCaps(screenDC, LOGPIXELSY); + ReleaseDC(nullptr, screenDC); + return dotsPerInch; +} +#endif +#endif + int System_GetPropertyInt(SystemProperty prop) { switch (prop) { case SYSPROP_AUDIO_SAMPLE_RATE: @@ -195,6 +210,8 @@ int System_GetPropertyInt(SystemProperty prop) { return 60000; case SYSPROP_DEVICE_TYPE: return DEVICE_TYPE_DESKTOP; + case SYSPROP_DISPLAY_DPI: + return ScreenDPI(); default: return -1; } diff --git a/ext/native/base/NativeApp.h b/ext/native/base/NativeApp.h index 722f687421..c52e1347ed 100644 --- a/ext/native/base/NativeApp.h +++ b/ext/native/base/NativeApp.h @@ -157,6 +157,7 @@ enum SystemProperty { SYSPROP_DISPLAY_XRES, SYSPROP_DISPLAY_YRES, SYSPROP_DISPLAY_REFRESH_RATE, // returns 1000*the refresh rate in Hz as it can be non-integer + SYSPROP_DISPLAY_DPI, SYSPROP_MOGA_VERSION, SYSPROP_DEVICE_TYPE,