Windows: Start at a sensible window size if high-DPI. Avoids the worst of #9437 but does not fix it.

This commit is contained in:
Henrik Rydgård committed 2017-03-17 13:22:00 +01:00
1 parent 6dcbed6659
commit aefad893f8
4 files changed
+25 -20

No files matched your search

+1 -19
View File
@@ -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;
+6 -1
View File
@@ -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;
+17
View File
@@ -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;
}
+1
View File
@@ -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,