From 724d92fd65862777c401a0a5b398a38a082d0618 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Wed, 25 Jan 2023 08:32:16 +0100
Subject: [PATCH] Rename SDL_GetDisplayDPI to SDL_GetDisplayPhysicalDPI to
avoid confusion with logical DPI
---
build-scripts/SDL_migration.cocci | 5 +++++
docs/README-migration.md | 1 +
include/SDL3/SDL_oldnames.h | 2 ++
include/SDL3/SDL_video.h | 2 +-
src/dynapi/SDL_dynapi.sym | 2 +-
src/dynapi/SDL_dynapi_overrides.h | 2 +-
src/dynapi/SDL_dynapi_procs.h | 2 +-
src/test/SDL_test_common.c | 6 +++---
src/video/SDL_video.c | 2 +-
src/video/windows/SDL_windowsmodes.c | 4 ++--
test/testdisplayinfo.c | 2 +-
11 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci
index 326dd2144f83..b5d19dbdceb5 100644
--- a/build-scripts/SDL_migration.cocci
+++ b/build-scripts/SDL_migration.cocci
@@ -2321,3 +2321,8 @@ expression e;
@@
- SDL_LASTEVENT
+ SDL_EVENT_LAST
+@@
+@@
+- SDL_GetDisplayDPI
++ SDL_GetDisplayPhysicalDPI
+ (...)
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 9ea52ee47766..755d7016d5c8 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -967,6 +967,7 @@ SDL_GL_SwapWindow() returns 0 if the function succeeds or a negative error code
SDL_GL_GetSwapInterval() takes the interval as an output parameter and returns 0 if the function succeeds or a negative error code if there was an error.
The following functions have been renamed:
+* SDL_GetDisplayDPI() => SDL_GetDisplayPhysicalDPI()
* SDL_GetPointDisplayIndex() => SDL_GetDisplayIndexForPoint()
* SDL_GetRectDisplayIndex() => SDL_GetDisplayIndexForRect()
diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
index c29be7bd17db..e1efb021126f 100644
--- a/include/SDL3/SDL_oldnames.h
+++ b/include/SDL3/SDL_oldnames.h
@@ -412,6 +412,7 @@
#define SDL_GetTicks64 SDL_GetTicks
/* ##SDL_video.h */
+#define SDL_GetDisplayDPI SDL_GetDisplayPhysicalDPI
#define SDL_GetPointDisplayIndex SDL_GetDisplayIndexForPoint
#define SDL_GetRectDisplayIndex SDL_GetDisplayIndexForRect
@@ -791,6 +792,7 @@
#define SDL_GetTicks64 SDL_GetTicks64_renamed_SDL_GetTicks
/* ##SDL_video.h */
+#define SDL_GetDisplayDPI SDL_GetDisplayDPI_renamed_SDL_GetDisplayPhysicalDPI
#define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_renamed_SDL_GetDisplayIndexForPoint
#define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_renamed_SDL_GetDisplayIndexForRect
diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h
index f9f6ef1a1fb4..23a9f246f525 100644
--- a/include/SDL3/SDL_video.h
+++ b/include/SDL3/SDL_video.h
@@ -403,7 +403,7 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rec
*
* \sa SDL_GetNumVideoDisplays
*/
-extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi);
+extern DECLSPEC int SDLCALL SDL_GetDisplayPhysicalDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi);
/**
* Get the orientation of a display.
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index ab6566fb911e..295b5810d928 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -164,7 +164,7 @@ SDL3_0.0.0 {
SDL_GetDefaultCursor;
SDL_GetDesktopDisplayMode;
SDL_GetDisplayBounds;
- SDL_GetDisplayDPI;
+ SDL_GetDisplayPhysicalDPI;
SDL_GetDisplayIndexForPoint;
SDL_GetDisplayIndexForRect;
SDL_GetDisplayMode;
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 2c2c368b9261..b7e92e9c4f94 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -189,7 +189,7 @@
#define SDL_GetDefaultCursor SDL_GetDefaultCursor_REAL
#define SDL_GetDesktopDisplayMode SDL_GetDesktopDisplayMode_REAL
#define SDL_GetDisplayBounds SDL_GetDisplayBounds_REAL
-#define SDL_GetDisplayDPI SDL_GetDisplayDPI_REAL
+#define SDL_GetDisplayPhysicalDPI SDL_GetDisplayPhysicalDPI_REAL
#define SDL_GetDisplayIndexForPoint SDL_GetDisplayIndexForPoint_REAL
#define SDL_GetDisplayIndexForRect SDL_GetDisplayIndexForRect_REAL
#define SDL_GetDisplayMode SDL_GetDisplayMode_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index be71c09f39f2..0dde18dfdaac 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -263,7 +263,7 @@ SDL_DYNAPI_PROC(int,SDL_GetDefaultAudioInfo,(char **a, SDL_AudioSpec *b, int c),
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetDefaultCursor,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_GetDesktopDisplayMode,(int a, SDL_DisplayMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayBounds,(int a, SDL_Rect *b),(a,b),return)
-SDL_DYNAPI_PROC(int,SDL_GetDisplayDPI,(int a, float *b, float *c, float *d),(a,b,c,d),return)
+SDL_DYNAPI_PROC(int,SDL_GetDisplayPhysicalDPI,(int a, float *b, float *c, float *d),(a,b,c,d),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(int,SDL_GetDisplayMode,(int a, int b, SDL_DisplayMode *c),(a,b,c),return)
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index f4aa828f2267..322355a5cae3 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1128,7 +1128,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_zero(usablebounds);
SDL_GetDisplayUsableBounds(i, &usablebounds);
- SDL_GetDisplayDPI(i, NULL, &hdpi, &vdpi);
+ SDL_GetDisplayPhysicalDPI(i, NULL, &hdpi, &vdpi);
SDL_Log("Bounds: %dx%d at %d,%d\n", bounds.w, bounds.h, bounds.x, bounds.y);
SDL_Log("Usable bounds: %dx%d at %d,%d\n", usablebounds.w, usablebounds.h, usablebounds.x, usablebounds.y);
@@ -2296,8 +2296,8 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
textY += lineHeight;
}
- if (0 == SDL_GetDisplayDPI(windowDisplayIndex, &ddpi, &hdpi, &vdpi)) {
- (void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayDPI: ddpi: %f, hdpi: %f, vdpi: %f",
+ if (0 == SDL_GetDisplayPhysicalDPI(windowDisplayIndex, &ddpi, &hdpi, &vdpi)) {
+ (void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayPhysicalDPI: ddpi: %f, hdpi: %f, vdpi: %f",
ddpi, hdpi, vdpi);
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 9c48f5891d6f..7916b90ddbc5 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -746,7 +746,7 @@ int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect *rect)
return SDL_GetDisplayBounds(displayIndex, rect);
}
-int SDL_GetDisplayDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi)
+int SDL_GetDisplayPhysicalDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi)
{
SDL_VideoDisplay *display;
diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c
index fd83b495a9b8..3d1fcc79accb 100644
--- a/src/video/windows/SDL_windowsmodes.c
+++ b/src/video/windows/SDL_windowsmodes.c
@@ -637,7 +637,7 @@ void WIN_ScreenPointFromSDLFloat(float x, float y, LONG *xOut, LONG *yOut, int *
goto passthrough;
}
- if (SDL_GetDisplayBounds(displayIndex, &bounds) < 0 || SDL_GetDisplayDPI(displayIndex, &ddpi, &hdpi, &vdpi) < 0) {
+ if (SDL_GetDisplayBounds(displayIndex, &bounds) < 0 || SDL_GetDisplayPhysicalDPI(displayIndex, &ddpi, &hdpi, &vdpi) < 0) {
goto passthrough;
}
@@ -712,7 +712,7 @@ void WIN_ScreenPointToSDLFloat(LONG x, LONG y, float *xOut, float *yOut)
}
/* Get SDL display properties */
- if (SDL_GetDisplayBounds(displayIndex, &bounds) < 0 || SDL_GetDisplayDPI(displayIndex, &ddpi, &hdpi, &vdpi) < 0) {
+ if (SDL_GetDisplayBounds(displayIndex, &bounds) < 0 || SDL_GetDisplayPhysicalDPI(displayIndex, &ddpi, &hdpi, &vdpi) < 0) {
return;
}
diff --git a/test/testdisplayinfo.c b/test/testdisplayinfo.c
index d0798fc661fe..7cfa8cc2b03d 100644
--- a/test/testdisplayinfo.c
+++ b/test/testdisplayinfo.c
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
SDL_GetDisplayBounds(dpy, &rect);
SDL_Log("%d: \"%s\" (%dx%d, (%d, %d)), %d modes.\n", dpy, SDL_GetDisplayName(dpy), rect.w, rect.h, rect.x, rect.y, num_modes);
- if (SDL_GetDisplayDPI(dpy, &ddpi, &hdpi, &vdpi) == -1) {
+ if (SDL_GetDisplayPhysicalDPI(dpy, &ddpi, &hdpi, &vdpi) == -1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " DPI: failed to query (%s)\n", SDL_GetError());
} else {
SDL_Log(" DPI: ddpi=%f; hdpi=%f; vdpi=%f\n", ddpi, hdpi, vdpi);