From c6969df4d79b9da1115df5cacae398ba70685d30 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 27 Dec 2022 06:38:34 -0800
Subject: [PATCH] SDL API renaming: SDL_video.h
Fixes https://github.com/libsdl-org/SDL/issues/6880
---
WhatsNew.txt | 2 ++
docs/README-migration.md | 4 ++++
include/SDL3/SDL_oldnames.h | 8 ++++++++
include/SDL3/SDL_video.h | 4 ++--
src/dynapi/SDL_dynapi.sym | 4 ++--
src/dynapi/SDL_dynapi_overrides.h | 4 ++--
src/dynapi/SDL_dynapi_procs.h | 4 ++--
src/video/SDL_sysvideo.h | 2 +-
src/video/SDL_video.c | 4 ++--
src/video/windows/SDL_windowsmodes.c | 2 +-
10 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/WhatsNew.txt b/WhatsNew.txt
index c4930b5ad8e6..8d31fd368364 100644
--- a/WhatsNew.txt
+++ b/WhatsNew.txt
@@ -32,6 +32,8 @@ General:
* SDL_FreeSurface => SDL_DestroySurface
* SDL_GetClipRect => SDL_GetSurfaceClipRect
* SDL_GetColorKey => SDL_GetSurfaceColorKey
+ * SDL_GetPointDisplayIndex => SDL_GetDisplayIndexForPoint
+ * SDL_GetRectDisplayIndex => SDL_GetDisplayIndexForRect
* SDL_HasColorKey => SDL_SurfaceHasColorKey
* SDL_HasSurfaceRLE => SDL_SurfaceHasRLE
* SDL_JoystickAttachVirtual => SDL_AttachVirtualJoystick
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 94687a15f6b2..a3bdf7efc406 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -592,3 +592,7 @@ SDL_VideoInit() and SDL_VideoQuit() have been removed. Instead you can call SDL_
+The following functions have been renamed:
+* SDL_GetPointDisplayIndex => SDL_GetDisplayIndexForPoint
+* SDL_GetRectDisplayIndex => SDL_GetDisplayIndexForRect
+
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index 20a7d0dca6af..13fb0a18a06a 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -207,6 +207,10 @@
#define SDL_UpperBlit SDL_BlitSurface
#define SDL_UpperBlitScaled SDL_BlitSurfaceScaled
+/* ##SDL_video.h */
+#define SDL_GetPointDisplayIndex SDL_GetDisplayIndexForPoint
+#define SDL_GetRectDisplayIndex SDL_GetDisplayIndexForRect
+
#else /* !SDL_ENABLE_OLD_NAMES */
/* ##SDL_audio.h */
@@ -377,6 +381,10 @@
#define SDL_UpperBlit SDL_UpperBlit_renamed_SDL_BlitSurface
#define SDL_UpperBlitScaled SDL_UpperBlitScaled_renamed_SDL_BlitSurfaceScaled
+/* ##SDL_video.h */
+#define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_renamed_SDL_GetDisplayIndexForPoint
+#define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_renamed_SDL_GetDisplayIndexForRect
+
#endif /* SDL_ENABLE_OLD_NAMES */
#endif /* SDL_oldnames_h_ */
diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h
index 06ff3dcb09d8..387ca7db21be 100644
--- a/include/SDL3/SDL_video.h
+++ b/include/SDL3/SDL_video.h
@@ -540,7 +540,7 @@ extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayI
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
*/
-extern DECLSPEC int SDLCALL SDL_GetPointDisplayIndex(const SDL_Point * point);
+extern DECLSPEC int SDLCALL SDL_GetDisplayIndexForPoint(const SDL_Point * point);
/**
* Get the index of the display primarily containing a rect
@@ -555,7 +555,7 @@ extern DECLSPEC int SDLCALL SDL_GetPointDisplayIndex(const SDL_Point * point);
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
*/
-extern DECLSPEC int SDLCALL SDL_GetRectDisplayIndex(const SDL_Rect * rect);
+extern DECLSPEC int SDLCALL SDL_GetDisplayIndexForRect(const SDL_Rect * rect);
/**
* Get the index of the display associated with a window.
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index ceb625bbcc16..e389802ed66e 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -536,8 +536,8 @@ SDL3_0.0.0 {
SDL_GetDesktopDisplayMode;
SDL_GetCurrentDisplayMode;
SDL_GetClosestDisplayMode;
- SDL_GetPointDisplayIndex;
- SDL_GetRectDisplayIndex;
+ SDL_GetDisplayIndexForPoint;
+ SDL_GetDisplayIndexForRect;
SDL_GetWindowDisplayIndex;
SDL_SetWindowDisplayMode;
SDL_GetWindowDisplayMode;
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 0d84394d0285..e7289c61f0a2 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -852,8 +852,8 @@
#define SDL_GetOriginalMemoryFunctions SDL_GetOriginalMemoryFunctions_REAL
#define SDL_ResetKeyboard SDL_ResetKeyboard_REAL
#define SDL_GetDefaultAudioInfo SDL_GetDefaultAudioInfo_REAL
-#define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_REAL
-#define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_REAL
+#define SDL_GetDisplayIndexForPoint SDL_GetDisplayIndexForPoint_REAL
+#define SDL_GetDisplayIndexForRect SDL_GetDisplayIndexForRect_REAL
#define SDL_ResetHint SDL_ResetHint_REAL
#define SDL_crc16 SDL_crc16_REAL
#define SDL_GetWindowSizeInPixels SDL_GetWindowSizeInPixels_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 4a2bf2f34541..261a81b65c0b 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -924,8 +924,8 @@ SDL_DYNAPI_PROC(int,SDL_GDKGetTaskQueue,(XTaskQueueHandle *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GetOriginalMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_ResetKeyboard,(void),(),)
SDL_DYNAPI_PROC(int,SDL_GetDefaultAudioInfo,(char **a, SDL_AudioSpec *b, int c),(a,b,c),return)
-SDL_DYNAPI_PROC(int,SDL_GetPointDisplayIndex,(const SDL_Point *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_GetRectDisplayIndex,(const SDL_Rect *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_GetDisplayIndexForPoint,(const SDL_Point *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_GetDisplayIndexForRect,(const SDL_Rect *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ResetHint,(const char *a),(a),return)
SDL_DYNAPI_PROC(Uint16,SDL_crc16,(Uint16 a, const void *b, size_t c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_GetWindowSizeInPixels,(SDL_Window *a, int *b, int *c),(a,b,c),)
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index 084111969473..469cddaa2e23 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -513,7 +513,7 @@ extern float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vin
extern void SDL_ToggleDragAndDropSupport(void);
-extern int SDL_GetPointDisplayIndex(const SDL_Point *point);
+extern int SDL_GetDisplayIndexForPoint(const SDL_Point *point);
extern int SDL_GL_SwapWindowWithResult(SDL_Window *window);
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 149bc59d9e8d..c8cd2175dd15 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -1133,12 +1133,12 @@ static int GetRectDisplayIndex(int x, int y, int w, int h)
return closest;
}
-int SDL_GetPointDisplayIndex(const SDL_Point *point)
+int SDL_GetDisplayIndexForPoint(const SDL_Point *point)
{
return GetRectDisplayIndex(point->x, point->y, 1, 1);
}
-int SDL_GetRectDisplayIndex(const SDL_Rect *rect)
+int SDL_GetDisplayIndexForRect(const SDL_Rect *rect)
{
return GetRectDisplayIndex(rect->x, rect->y, rect->w, rect->h);
}
diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c
index 310f20e78da5..3155f8da2410 100644
--- a/src/video/windows/SDL_windowsmodes.c
+++ b/src/video/windows/SDL_windowsmodes.c
@@ -610,7 +610,7 @@ void WIN_ScreenPointFromSDL(int *x, int *y, int *dpiOut)
}
/* Can't use MonitorFromPoint for this because we currently have SDL coordinates, not pixels */
- displayIndex = SDL_GetPointDisplayIndex(&point);
+ displayIndex = SDL_GetDisplayIndexForPoint(&point);
if (displayIndex < 0) {
return;