Correctly set "dpi awarness" in win32, making the app automatically

scale properly for high dpi displays.
This commit is contained in:
casey langen 2017-06-11 21:54:23 -07:00
parent 2e2ee29cbb
commit aad227681d
3 changed files with 17 additions and 0 deletions

View File

@ -75,6 +75,7 @@ App::App(const std::string& title) {
#ifdef WIN32
this->iconId = 0;
win32::ConfigureDpiAwareness();
#else
setlocale(LC_ALL, "");
std::signal(SIGWINCH, resizedHandler);

View File

@ -252,6 +252,21 @@ namespace cursespp {
resetMutex();
}
}
void ConfigureDpiAwareness() {
typedef HRESULT(__stdcall *SetProcessDpiAwarenessProc)(int);
static const int ADJUST_DPI_PER_MONITOR = 2;
HMODULE dll = LoadLibrary(L"shcore.dll");
if (dll) {
SetProcessDpiAwarenessProc setDpiAwareness =
(SetProcessDpiAwarenessProc) GetProcAddress(dll, "SetProcessDpiAwareness");
if (setDpiAwareness) {
setDpiAwareness(ADJUST_DPI_PER_MONITOR);
}
}
}
}
}

View File

@ -51,6 +51,7 @@ namespace cursespp {
void EnableSingleInstance(const std::string& uniqueId);
bool AlreadyRunning();
void ShowOtherInstance();
void ConfigureDpiAwareness();
}
}