sdl2-compat: Fix scaling for legacy programs on wayland (#343)

From 80c0eef7ff7a475d5db98e5fa83f0a6284382c8a Mon Sep 17 00:00:00 2001
From: simonioc <[EMAIL REDACTED]>
Date: Tue, 11 Feb 2025 01:05:56 +0100
Subject: [PATCH] Fix scaling for legacy programs on wayland (#343)

---
 src/sdl2_compat.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index c00ec035..ac06a7b6 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -1071,6 +1071,11 @@ SDL2Compat_InitOnStartupInternal(void)
     SDL3_SetHint("SDL_BORDERLESS_WINDOWED_STYLE", "0");
     SDL3_SetHint("SDL_VIDEO_SYNC_WINDOW_OPERATIONS", "1");
 
+    // Pretend Wayland doesn't have fractional scaling
+    // This is more compatible with applications that have only been tested under X11 without high DPI support
+    // Full discussion is here: https://github.com/libsdl-org/SDL/issues/12158
+    SDL3_SetHint(SDL_HINT_VIDEO_WAYLAND_SCALE_TO_DISPLAY, "1");
+
     SDL2Compat_InitLogPrefixes();
 
     return true;