From 290afc142d2edcc105edb065dd98d29e53f1b642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Mon, 17 May 2021 13:24:25 -0400 Subject: [PATCH] Set High DPI Awareness before calling SDL_Init() --- src/conio/sdl_con.c | 38 -------------------------------------- src/conio/sdlfuncs.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index b7b1e3065c..e39298f28d 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -467,44 +467,6 @@ int sdl_init(int mode) cio_api.mode=fullscreen?CIOLIB_MODE_SDL_FULLSCREEN:CIOLIB_MODE_SDL; #ifdef _WIN32 FreeConsole(); - // code that tells windows we're High DPI aware so it doesn't scale our windows - // taken from Yamagi Quake II - - typedef enum D3_PROCESS_DPI_AWARENESS { - D3_PROCESS_DPI_UNAWARE = 0, - D3_PROCESS_SYSTEM_DPI_AWARE = 1, - D3_PROCESS_PER_MONITOR_DPI_AWARE = 2 - } YQ2_PROCESS_DPI_AWARENESS; - - /* For Vista, Win7 and Win8 */ - BOOL(WINAPI *SetProcessDPIAware)(void) = NULL; - - /* Win8.1 and later */ - HRESULT(WINAPI *SetProcessDpiAwareness)(enum D3_PROCESS_DPI_AWARENESS dpiAwareness) = NULL; - - const char* user32dll[] = {"User32", NULL}; - dll_handle userDLL = xp_dlopen(user32dll, RTLD_LAZY, 0); - - if (userDLL) - { - SetProcessDPIAware = xp_dlsym(userDLL, "SetProcessDPIAware"); - } - - - const char* shcoredll[] = {"SHCore", NULL}; - dll_handle shcoreDLL = xp_dlopen(shcoredll, RTLD_LAZY, 0); - - if (shcoreDLL) - { - SetProcessDpiAwareness = xp_dlsym(shcoreDLL, "SetProcessDpiAwareness"); - } - - if (SetProcessDpiAwareness) { - SetProcessDpiAwareness(D3_PROCESS_PER_MONITOR_DPI_AWARE); - } - else if (SetProcessDPIAware) { - SetProcessDPIAware(); - } #endif cio_api.options |= CONIO_OPT_PALETTE_SETTING | CONIO_OPT_SET_TITLE | CONIO_OPT_SET_NAME | CONIO_OPT_SET_ICON; return(0); diff --git a/src/conio/sdlfuncs.c b/src/conio/sdlfuncs.c index 49ea6aeae9..bc4feb8419 100644 --- a/src/conio/sdlfuncs.c +++ b/src/conio/sdlfuncs.c @@ -231,6 +231,44 @@ int init_sdl_video(void) sdl.SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2" ); sdl.SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1" ); #ifdef _WIN32 + // code that tells windows we're High DPI aware so it doesn't scale our windows + // taken from Yamagi Quake II + + typedef enum D3_PROCESS_DPI_AWARENESS { + D3_PROCESS_DPI_UNAWARE = 0, + D3_PROCESS_SYSTEM_DPI_AWARE = 1, + D3_PROCESS_PER_MONITOR_DPI_AWARE = 2 + } YQ2_PROCESS_DPI_AWARENESS; + + /* For Vista, Win7 and Win8 */ + BOOL(WINAPI *SetProcessDPIAware)(void) = NULL; + + /* Win8.1 and later */ + HRESULT(WINAPI *SetProcessDpiAwareness)(enum D3_PROCESS_DPI_AWARENESS dpiAwareness) = NULL; + + const char* user32dll[] = {"User32", NULL}; + dll_handle userDLL = xp_dlopen(user32dll, RTLD_LAZY, 0); + + if (userDLL) + { + SetProcessDPIAware = xp_dlsym(userDLL, "SetProcessDPIAware"); + } + + + const char* shcoredll[] = {"SHCore", NULL}; + dll_handle shcoreDLL = xp_dlopen(shcoredll, RTLD_LAZY, 0); + + if (shcoreDLL) + { + SetProcessDpiAwareness = xp_dlsym(shcoreDLL, "SetProcessDpiAwareness"); + } + + if (SetProcessDpiAwareness) { + SetProcessDpiAwareness(D3_PROCESS_PER_MONITOR_DPI_AWARE); + } + else if (SetProcessDPIAware) { + SetProcessDPIAware(); + } /* Fail to windib (ie: No mouse attached) */ if(sdl.Init(SDL_INIT_VIDEO) == 0) { sdl_video_initialized=TRUE; -- GitLab