From 7d775a327971c81d31d9c580da9ae9125a060365 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Fri, 6 Oct 2023 15:19:03 -0400
Subject: [PATCH] Translate the SDL2 display index to an SDL3 display ID when
setting the window position
---
src/sdl2_compat.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 916063f..a79e45b 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -5366,7 +5366,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
}
if (window) {
if (!SDL_WINDOWPOS_ISUNDEFINED(x) || !SDL_WINDOWPOS_ISUNDEFINED(y)) {
- SDL3_SetWindowPosition(window, x, y);
+ SDL_SetWindowPosition(window, x, y);
}
if (!hidden) {
SDL3_ShowWindow(window);
@@ -5554,6 +5554,19 @@ SDL_SetWindowPosition(SDL_Window *window, int x, int y)
parent = (SDL_Window *) SDL3_GetWindowData(parent, POPUP_PARENT_PROP_STR);
}
+ } else {
+ if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) {
+ const int displayIndex = x & 0xFFFF;
+ const SDL_DisplayID displayID = Display_IndexToID(displayIndex);
+
+ x = (x & 0xFFFF0000) | (0xFFFF & displayID);
+ }
+ if (SDL_WINDOWPOS_ISUNDEFINED(y) || SDL_WINDOWPOS_ISCENTERED(y)) {
+ const int displayIndex = y & 0xFFFF;
+ const SDL_DisplayID displayID = Display_IndexToID(displayIndex);
+
+ y = (y & 0xFFFF0000) | (0xFFFF & displayID);
+ }
}
SDL3_SetWindowPosition(window, x, y);