From 136edd109787b2ecfa8b77fc6df5558bfe9f7c8f Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Wed, 3 Apr 2024 21:33:46 -0400 Subject: [PATCH] Fix incorrect SDL window pos on high DPI --- src/pc/gfx/gfx_sdl1.c | 8 ++++---- src/pc/gfx/gfx_sdl2.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pc/gfx/gfx_sdl1.c b/src/pc/gfx/gfx_sdl1.c index cd045e55c..7659a58d9 100644 --- a/src/pc/gfx/gfx_sdl1.c +++ b/src/pc/gfx/gfx_sdl1.c @@ -95,6 +95,10 @@ static void gfx_sdl_set_mode(void) { } static void gfx_sdl_init(const char *window_title) { +#if defined(_WIN32) || defined(_WIN64) + SetProcessDPIAware(); +#endif + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) sys_fatal("Could not init SDL1 video: %s\n", SDL_GetError()); @@ -114,10 +118,6 @@ static void gfx_sdl_init(const char *window_title) { } controller_bind_init(); - -#if defined(_WIN32) || defined(_WIN64) - SetProcessDPIAware(); -#endif } static void gfx_sdl_main_loop(void (*run_one_game_iter)(void)) { diff --git a/src/pc/gfx/gfx_sdl2.c b/src/pc/gfx/gfx_sdl2.c index e0b678a88..dab9e0e3b 100644 --- a/src/pc/gfx/gfx_sdl2.c +++ b/src/pc/gfx/gfx_sdl2.c @@ -112,6 +112,10 @@ static void gfx_sdl_reset_dimension_and_pos(void) { } static void gfx_sdl_init(const char *window_title) { +#if defined(_WIN32) || defined(_WIN64) + SetProcessDPIAware(); +#endif + SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); SDL_Init(SDL_INIT_VIDEO); SDL_StartTextInput(); @@ -143,10 +147,6 @@ static void gfx_sdl_init(const char *window_title) { } controller_bind_init(); - -#if defined(_WIN32) || defined(_WIN64) - SetProcessDPIAware(); -#endif } static void gfx_sdl_main_loop(void (*run_one_game_iter)(void)) {