From c699f3d1d806def7b80ca2280258e8d16f44675d Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 16 May 2023 16:29:52 -0700
Subject: [PATCH] Updated SDL high DPI support
We have gotten feedback that abstracting the coordinate system based on the display scale is unexpected and it is difficult to adapt existing applications to the proposed API.
The new approach is to provide the coordinate systems that people expect, but provide additional information that will help applications properly handle high DPI situations.
The concepts needed for high DPI support are documented in README-highdpi.md. An example of automatically adapting the content to display scale changes can be found in SDL_test_common.c, where auto_scale_content is checked.
Also, the SDL_WINDOW_ALLOW_HIGHDPI window flag has been replaced by the SDL_HINT_VIDEO_ENABLE_HIGH_PIXEL_DENSITY hint.
Fixes https://github.com/libsdl-org/SDL/issues/7709
---
build-scripts/SDL_migration.cocci | 20 --
docs/README-highdpi.md | 18 ++
docs/README-migration.md | 8 +-
include/SDL3/SDL_events.h | 5 +-
include/SDL3/SDL_hints.h | 11 +
include/SDL3/SDL_render.h | 36 +--
include/SDL3/SDL_test_common.h | 1 +
include/SDL3/SDL_video.h | 103 +++++----
src/dynapi/SDL_dynapi.sym | 3 +-
src/dynapi/SDL_dynapi_overrides.h | 3 +-
src/dynapi/SDL_dynapi_procs.h | 3 +-
src/events/SDL_events.c | 6 +-
src/render/SDL_render.c | 74 ++-----
src/test/SDL_test_common.c | 90 +++++---
src/video/SDL_sysvideo.h | 3 +
src/video/SDL_video.c | 160 ++++++++------
src/video/android/SDL_androidmouse.c | 3 -
src/video/android/SDL_androidvideo.c | 15 +-
src/video/android/SDL_androidwindow.c | 8 +-
src/video/cocoa/SDL_cocoamodes.m | 14 +-
src/video/dummy/SDL_nullvideo.c | 4 +-
src/video/emscripten/SDL_emscriptenvideo.c | 4 +-
src/video/haiku/SDL_bmodes.cc | 4 +-
src/video/kmsdrm/SDL_kmsdrmvideo.c | 12 +-
src/video/n3ds/SDL_n3dsvideo.c | 8 +-
src/video/ngage/SDL_ngagevideo.cpp | 4 +-
src/video/offscreen/SDL_offscreenvideo.c | 4 +-
src/video/ps2/SDL_ps2video.c | 4 +-
src/video/psp/SDL_pspvideo.c | 8 +-
src/video/raspberry/SDL_rpivideo.c | 8 +-
src/video/riscos/SDL_riscosmodes.c | 4 +-
src/video/uikit/SDL_uikitmodes.m | 38 ++--
src/video/vita/SDL_vitavideo.c | 12 +-
src/video/vivante/SDL_vivantevideo.c | 6 +-
src/video/wayland/SDL_waylandvideo.c | 60 +++--
src/video/wayland/SDL_waylandwindow.c | 22 +-
src/video/windows/SDL_windowsevents.c | 89 ++------
src/video/windows/SDL_windowsmodes.c | 244 +++------------------
src/video/windows/SDL_windowsmodes.h | 4 -
src/video/windows/SDL_windowsmouse.c | 9 +-
src/video/windows/SDL_windowsvideo.c | 14 +-
src/video/windows/SDL_windowsvideo.h | 1 -
src/video/windows/SDL_windowswindow.c | 136 +-----------
src/video/windows/SDL_windowswindow.h | 9 -
src/video/winrt/SDL_winrtvideo.cpp | 27 +--
src/video/x11/SDL_x11messagebox.c | 4 +-
src/video/x11/SDL_x11modes.c | 27 +--
test/testautomation_video.c | 21 +-
test/testdisplayinfo.c | 11 +-
test/testshape.c | 4 +-
test/testwm.c | 2 +-
51 files changed, 506 insertions(+), 882 deletions(-)
create mode 100644 docs/README-highdpi.md
diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci
index 22d9892f7854..86acf1ff3328 100644
--- a/build-scripts/SDL_migration.cocci
+++ b/build-scripts/SDL_migration.cocci
@@ -2284,26 +2284,6 @@ expression e;
- SDL_WINDOW_INPUT_GRABBED
+ SDL_WINDOW_MOUSE_GRABBED
@@
-SDL_DisplayMode *e;
-@@
-(
-- e->w
-+ e->screen_w
-|
-- e->h
-+ e->screen_h
-)
-@@
-SDL_DisplayMode e;
-@@
-(
-- e.w
-+ e.screen_w
-|
-- e.h
-+ e.screen_h
-)
-@@
@@
- SDL_GetWindowDisplayIndex
+ SDL_GetDisplayForWindow
diff --git a/docs/README-highdpi.md b/docs/README-highdpi.md
new file mode 100644
index 000000000000..a63cbbcb6752
--- /dev/null
+++ b/docs/README-highdpi.md
@@ -0,0 +1,18 @@
+
+SDL 3.0 has new support for high DPI displays
+
+Displays now have a content display scale.
+
+The display scale is the expected scale for content based on the DPI settings of the display. For example, a 4K display might have a 2.0 (200%) display scale, which means that the user expects UI elements to be twice as big on this display, to aid in readability.
+
+The window size is now distinct from the window pixel size.
+
+The window also has a display scale, which is the content display scale relative to the window pixel size.
+
+For example, a 3840x2160 window displayed at 200% on Windows, and a 1920x1080 window on a 2x display on macOS will both have a pixel size of 3840x2160 and a display scale of 2.0.
+
+You can query the window size using SDL_GetWindowSize(), and when this changes you get an SDL_EVENT_WINDOW_RESIZED event.
+
+You can query the window pixel size using SDL_GetWindowSizeInPixels(), and when this changes you get an SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event. You are guaranteed to get a SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event when a window is created and resized, and you can use this event to create and resize your graphics context for the window.
+
+You can query the window display scale using SDL_GetWindowDisplayScale(), and when this changes you get an SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED event.
diff --git a/docs/README-migration.md b/docs/README-migration.md
index 2e0b3a27dfd1..41287edfad42 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -1085,9 +1085,9 @@ The SDL_WINDOWPOS_UNDEFINED_DISPLAY() and SDL_WINDOWPOS_CENTERED_DISPLAY() macro
The SDL_WINDOW_SHOWN flag has been removed. Windows are shown by default and can be created hidden by using the SDL_WINDOW_HIDDEN flag.
-The SDL_WINDOW_ALLOW_HIGHDPI flag has been removed. Windows are automatically high DPI aware and their coordinates are in screen space, which may differ from physical pixels on displays using display scaling.
+The SDL_WINDOW_ALLOW_HIGHDPI flag has been replaced by the SDL_HINT_VIDEO_ENABLE_HIGH_PIXEL_DENSITY hint, which is enabled by default.
-SDL_DisplayMode now includes the pixel size, the screen size and the relationship between the two. For example, a 4K display at 200% scale could have a pixel size of 3840x2160, a screen size of 1920x1080, and a display scale of 2.0.
+SDL_DisplayMode now includes the pixel density which can be greater than 1.0 for display modes that have a higher pixel size than the mode size. You should use SDL_GetWindowSizeInPixels() to get the actual pixel size of the window back buffer.
The refresh rate in SDL_DisplayMode is now a float.
@@ -1100,8 +1100,8 @@ Rather than iterating over display modes using an index, there is a new function
if (modes) {
for (i = 0; i < num_modes; ++i) {
SDL_DisplayMode *mode = modes[i];
- SDL_Log("Display %" SDL_PRIu32 " mode %d: %dx%d@%gHz, %d%% scale\n",
- display, i, mode->pixel_w, mode->pixel_h, mode->refresh_rate, (int)(mode->display_scale * 100.0f));
+ SDL_Log("Display %" SDL_PRIu32 " mode %d: %dx%d@%gx %gHz\n",
+ display, i, mode->w, mode->h, mode->pixel_density, mode->refresh_rate);
}
SDL_free(modes);
}
diff --git a/include/SDL3/SDL_events.h b/include/SDL3/SDL_events.h
index a92a2fe4b831..de0815913a41 100644
--- a/include/SDL3/SDL_events.h
+++ b/include/SDL3/SDL_events.h
@@ -95,9 +95,9 @@ typedef enum
SDL_EVENT_DISPLAY_CONNECTED, /**< Display has been added to the system */
SDL_EVENT_DISPLAY_DISCONNECTED, /**< Display has been removed from the system */
SDL_EVENT_DISPLAY_MOVED, /**< Display has changed position */
- SDL_EVENT_DISPLAY_SCALE_CHANGED, /**< Display has changed desktop display scale */
+ SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */
SDL_EVENT_DISPLAY_FIRST = SDL_EVENT_DISPLAY_ORIENTATION,
- SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_SCALE_CHANGED,
+ SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED,
/* Window events */
/* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */
@@ -120,6 +120,7 @@ typedef enum
SDL_EVENT_WINDOW_HIT_TEST, /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL */
SDL_EVENT_WINDOW_ICCPROF_CHANGED, /**< The ICC profile of the window's display has changed */
SDL_EVENT_WINDOW_DISPLAY_CHANGED, /**< Window has been moved to display data1 */
+ SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED, /**< Window display scale has been changed */
SDL_EVENT_WINDOW_DESTROYED, /**< The window with the associated ID is being or has been destroyed. If this message is being handled
in an event watcher, the window handle is still valid and can still be used to retrieve any userdata
associated with the window. Otherwise, the handle has already been destroyed and all resources
diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h
index 09830b563c86..8a2e23981dc6 100644
--- a/include/SDL3/SDL_hints.h
+++ b/include/SDL3/SDL_hints.h
@@ -1638,6 +1638,17 @@ extern "C" {
*/
#define SDL_HINT_VIDEO_EXTERNAL_CONTEXT "SDL_VIDEO_EXTERNAL_CONTEXT"
+/**
+ * \brief A variable controlling whether to use high pixel density display modes
+ *
+ * The variable can be set to the following values:
+ * "0" - Disable high pixel density display modes
+ * "1" - Enable high pixel density display modes
+ *
+ * The default value is "1". This hint must be set before display modes are queried and windows are created.
+ */
+#define SDL_HINT_VIDEO_ENABLE_HIGH_PIXEL_DENSITY "SDL_VIDEO_ENABLE_HIGH_PIXEL_DENSITY"
+
/**
* \brief A variable that dictates policy for fullscreen Spaces on macOS.
*
diff --git a/include/SDL3/SDL_render.h b/include/SDL3/SDL_render.h
index 0ea0792cb0bd..7ea1a312448f 100644
--- a/include/SDL3/SDL_render.h
+++ b/include/SDL3/SDL_render.h
@@ -140,7 +140,6 @@ typedef enum
typedef enum
{
SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */
- SDL_LOGICAL_PRESENTATION_MATCH, /**< The rendered content matches the window size in points */
SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */
SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */
SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */
@@ -235,9 +234,8 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(int width, int height, U
* need a specific renderer, specify NULL and SDL will attempt to chooes the
* best option for you, based on what is available on the user's system.
*
- * By default the rendering size matches the window size in points, but you
- * can call SDL_SetRenderLogicalPresentation() to enable high DPI rendering or
- * change the content size and scaling options.
+ * By default the rendering size matches the window size in pixels, but you
+ * can call SDL_SetRenderLogicalPresentation() to change the content size and scaling options.
*
* \param window the window where rendering is displayed
* \param name the name of the rendering driver to initialize, or NULL to
@@ -316,24 +314,6 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer);
*/
extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_RendererInfo *info);
-/**
- * Get the output size in points of a rendering context.
- *
- * This returns the true output size in points, ignoring any render targets or
- * logical size and presentation.
- *
- * \param renderer the rendering context
- * \param w a pointer filled in with the width in points
- * \param h a pointer filled in with the height in points
- * \returns 0 on success or a negative error code on failure; call
- * SDL_GetError() for more information.
- *
- * \since This function is available since SDL 3.0.0.
- *
- * \sa SDL_GetRenderer
- */
-extern DECLSPEC int SDLCALL SDL_GetRenderWindowSize(SDL_Renderer *renderer, int *w, int *h);
-
/**
* Get the output size in pixels of a rendering context.
*
@@ -840,13 +820,9 @@ extern DECLSPEC SDL_Texture *SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer)
* render target is created at the specified size and used for rendering and
* then copied to the output during presentation.
*
- * When a renderer is created, the logical size is set to match the window
- * size in points. The actual output size may be higher pixel density, and can
- * be queried with SDL_GetRenderOutputSize().
- *
* You can disable logical coordinates by setting the mode to
* SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full
- * resolution of the output window.
+ * pixel resolution of the output window.
*
* You can convert coordinates in an event into rendering coordinates using
* SDL_ConvertEventToRenderCoordinates().
@@ -887,8 +863,7 @@ extern DECLSPEC int SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *rende
extern DECLSPEC int SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode, SDL_ScaleMode *scale_mode);
/**
- * Get a point in render coordinates when given a point in window coordinates
- * (points).
+ * Get a point in render coordinates when given a point in window coordinates.
*
* \param renderer the rendering context
* \param window_x the x coordinate in window coordinates
@@ -906,8 +881,7 @@ extern DECLSPEC int SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *rende
extern DECLSPEC int SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
/**
- * Get a point in window coordinates (points) when given a point in render
- * coordinates.
+ * Get a point in window coordinates when given a point in render coordinates.
*
* \param renderer the rendering context
* \param x the x coordinate in render coordinates
diff --git a/include/SDL3/SDL_test_common.h b/include/SDL3/SDL_test_common.h
index c326732b9e60..4c151471c810 100644
--- a/include/SDL3/SDL_test_common.h
+++ b/include/SDL3/SDL_test_common.h
@@ -77,6 +77,7 @@ typedef struct
int window_maxH;
int logical_w;
int logical_h;
+ SDL_bool auto_scale_content;
SDL_RendererLogicalPresentation logical_presentation;
SDL_ScaleMode logical_scale_mode;
float scale;
diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h
index 98dc9663876b..fe41eb27165a 100644
--- a/include/SDL3/SDL_video.h
+++ b/include/SDL3/SDL_video.h
@@ -66,11 +66,9 @@ typedef struct
{
SDL_DisplayID displayID; /**< the display this mode is associated with */
Uint32 format; /**< pixel format */
- int pixel_w; /**< width in pixels (used for creating back buffers) */
- int pixel_h; /**< height in pixels (used for creating back buffers) */
- int screen_w; /**< width in screen coordinates (used for creating windows) */
- int screen_h; /**< height in screen coordinates (used for creating windows) */
- float display_scale; /**< scale converting screen coordinates to pixels (e.g. a 2560x1440 screen size mode with 1.5 scale would have 3840x2160 pixels) */
+ int w; /**< width */
+ int h; /**< height */
+ float pixel_density; /**< scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels) */
float refresh_rate; /**< refresh rate (or zero for unspecified) */
void *driverdata; /**< driver-specific data, initialize to 0 */
} SDL_DisplayMode;
@@ -356,7 +354,7 @@ extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
extern DECLSPEC const char *SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID);
/**
- * Get the desktop area represented by a display, in screen coordinates.
+ * Get the desktop area represented by a display.
*
* The primary display is always located at (0,0).
*
@@ -409,18 +407,31 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID,
*/
extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(SDL_DisplayID displayID);
+/**
+ * Get the content scale of a display.
+ *
+ * The content scale is the expected scale for content based on the DPI settings of the display. For example, a 4K display might have a 2.0 (200%) display scale, which means that the user expects UI elements to be twice as big on this display, to aid in readability.
+ *
+ * \param displayID the instance ID of the display to query
+ * \returns The content scale of the display, or 0.0f on error; call SDL_GetError() for more details.
+ *
+ * \since This function is available since SDL 3.0.0.
+ *
+ * \sa SDL_GetDisplays
+ */
+extern DECLSPEC float SDLCALL SDL_GetDisplayContentScale(SDL_DisplayID displayID);
+
/**
* Get a list of fullscreen display modes available on a display.
*
* The display modes are sorted in this priority:
*
- * - screen_w -> largest to smallest
- * - screen_h -> largest to smallest
- * - pixel_w -> largest to smallest
- * - pixel_h -> largest to smallest
+ * - w -> largest to smallest
+ * - h -> largest to smallest
* - bits per pixel -> more colors to fewer colors
* - packed pixel layout -> largest to smallest
* - refresh rate -> highest to lowest
+ * - pixel density -> lowest to highest
*
* \param displayID the instance ID of the display to query
* \param count a pointer filled in with the number of displays returned
@@ -499,7 +510,7 @@ extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetDesktopDisplayMode(SDL_Dis
extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID);
/**
- * Get the display containing a point, in screen coordinates.
+ * Get the display containing a point.
*
* \param point the point to query
* \returns the instance ID of the display containing the point or 0 on
@@ -513,7 +524,7 @@ extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetCurrentDisplayMode(SDL_Dis
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
/**
- * Get the display primarily containing a rect, in screen coordinates.
+ * Get the display primarily containing a rect.
*
* \param rect the rect to query
* \returns the instance ID of the display entirely containing the rect or
@@ -542,6 +553,20 @@ extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect
*/
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window);
+/**
+ * Get the content display scale relative to a window's pixel size.
+ *
+ * This is a combination of the window pixel density and the display content scale, and is the expected scale for displaying content in this window. For example, if a 3840x2160 window had a display scale of 2.0, the user expects the content to take twice as many pixels and be the same physical size as if it were being displayed in a 1920x1080 window with a display scale of 1.0.
+ *
+ * Conceptually this value corresponds to the scale display setting, and is updated when that setting is changed, or the window moves to a display with a different scale setting.
+ *
+ * \param window the window to query
+ * \returns the display scale, or 0.0f on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ */
+extern DECLSPEC float SDLCALL SDL_GetWindowDisplayScale(SDL_Window *window);
+
/**
* Set the display mode to use when a window is visible and fullscreen.
*
@@ -623,9 +648,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window);
* On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
* property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
*
- * The window size in pixels may differ from its size in screen coordinates if
- * the window is on a high density display (one with an OS scaling factor).
- * Use SDL_GetWindowSize() to query the client area's size in screen
+ * The window pixel size may differ from its window coordinate size if the window is on a high pixel density display.
+ * Use SDL_GetWindowSize() to query the client area's size in window
* coordinates, and SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize()
* to query the drawable size in pixels. Note that the drawable size can vary
* after the window is created and should be queried again if you get an
@@ -652,8 +676,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window);
* in a future version of SDL.
*
* \param title the title of the window, in UTF-8 encoding
- * \param w the width of the window, in screen coordinates
- * \param h the height of the window, in screen coordinates
+ * \param w the width of the window
+ * \param h the height of the window
* \param flags 0, or one or more SDL_WindowFlags OR'd together
* \returns the window that was created or NULL on failure; call
* SDL_GetError() for more information.
@@ -688,9 +712,8 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindow(const char *title, int w, i
* On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
* property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
*
- * The window size in pixels may differ from its size in screen coordinates if
- * the window is on a high density display (one with an OS scaling factor).
- * Use SDL_GetWindowSize() to query the client area's size in screen
+ * The window pixel size may differ from its window coordinate size if the window is on a high pixel density display.
+ * Use SDL_GetWindowSize() to query the client area's size in window
* coordinates, and SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize()
* to query the drawable size in pixels. Note that the drawable size can vary
* after the window is created and should be queried again if you get an
@@ -719,8 +742,8 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindow(const char *title, int w, i
* \param title the title of the window, in UTF-8 encoding
* \param x the x position of the window, or `SDL_WINDOWPOS_CENTERED`
* \param y the y position of the window, or `SDL_WINDOWPOS_CENTERED`
- * \param w the width of the window, in screen coordinates
- * \param h the height of the window, in screen coordinates
+ * \param w the width of the window
+ * \param h the height of the window
* \param flags 0, or one or more SDL_WindowFlags OR'd together
* \returns the window that was created or NULL on failure; call
* SDL_GetError() for more information.
@@ -767,11 +790,11 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindowWithPosition(const char *tit
*
* \param parent the parent of the window, must not be NULL
* \param offset_x the x position of the popup window relative to the origin
- * of the parent, in screen coordinates
+ * of the parent
* \param offset_y the y position of the popup window relative to the origin
- * of the parent window, in screen coordinates
- * \param w the width of the window, in screen coordinates
- * \param h the height of the window, in screen coordinates
+ * of the parent window
+ * \param w the width of the window
+ * \param h the height of the window
* \param flags SDL_WINDOW_TOOLTIP or SDL_WINDOW_POPUP MENU, and zero or more
* additional SDL_WindowFlags OR'd together.
* \returns the window that was created or NULL on failure; call
@@ -938,7 +961,7 @@ extern DECLSPEC void *SDLCALL SDL_SetWindowData(SDL_Window *window, const char *
extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window *window, const char *name);
/**
- * Set the position of a window, in screen coordinates.
+ * Set the position of a window.
*
* \param window the window to reposition
* \param x the x coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or
@@ -955,7 +978,7 @@ extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window *window, const char *
extern DECLSPEC int SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
/**
- * Get the position of a window, in screen coordinates.
+ * Get the position of a window.
*
* If you do not need the value for one of the positions a NULL may be passed
* in the `x` or `y` parameter.
@@ -973,10 +996,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int
extern DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
/**
- * Set the size of a window's client area, in screen coordinates.
- *
- * The window size in screen coordinates may differ from the size in pixels if
- * the window is on a high density display (one with an OS scaling factor).
+ * Set the size of a window's client area.
*
* This only affects the size of the window when not in fullscreen mode. To
* change the fullscreen mode of a window, use SDL_SetWindowFullscreenMode()
@@ -995,13 +1015,12 @@ extern DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, in
extern DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
/**
- * Get the size of a window's client area, in screen coordinates.
+ * Get the size of a window's client area.
*
* NULL can safely be passed as the `w` or `h` parameter if the width or
* height value is not desired.
*
- * The window size in screen coordinates may differ from the size in pixels if
- * the window is on a high density display (one with an OS scaling factor).
+ * The window pixel size may differ from its window coordinate size if the window is on a high pixel density display.
* Use SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize() to get the
* real client area size in pixels.
*
@@ -1020,8 +1039,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
extern DECLSPEC int SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
/**
- * Get the size of a window's borders (decorations) around the client area, in
- * screen coordinates.
+ * Get the size of a window's borders (decorations) around the client area.
*
* Note: If this function fails (returns -1), the size values will be
* initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the
@@ -1057,9 +1075,6 @@ extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *to
/**
* Get the size of a window's client area, in pixels.
*
- * The window size in pixels may differ from the size in screen coordinates if
- * the window is on a high density display (one with an OS scaling factor).
- *
* \param window the window from which the drawable size should be queried
* \param w a pointer to variable for storing the width in pixels, may be NULL
* \param h a pointer to variable for storing the height in pixels, may be
@@ -1075,7 +1090,7 @@ extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *to
extern DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
/**
- * Set the minimum size of a window's client area, in screen coordinates.
+ * Set the minimum size of a window's client area.
*
* \param window the window to change
* \param min_w the minimum width of the window, or 0 for no limit
@@ -1091,7 +1106,7 @@ extern DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w
extern DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h);
/**
- * Get the minimum size of a window's client area, in screen coordinates.
+ * Get the minimum size of a window's client area.
*
* \param window the window to query
* \param w a pointer filled in with the minimum width of the window, may be
@@ -1109,7 +1124,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min
extern DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
/**
- * Set the maximum size of a window's client area, in screen coordinates.
+ * Set the maximum size of a window's client area.
*
* \param window the window to change
* \param max_w the maximum width of the window, or 0 for no limit
@@ -1125,7 +1140,7 @@ extern DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w,
extern DECLSPEC int SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h);
/**
- * Get the maximum size of a window's client area, in screen coordinates.
+ * Get the maximum size of a window's client area.
*
* \param window the window to query
* \param w a pointer filled in with the maximum width of the window, may be
diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index 78075cd635eb..01b62251890c 100644
--- a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -837,7 +837,6 @@ SDL3_0.0.0 {
SDL_ConvertEventToRenderCoordinates;
SDL_SetRenderScale;
SDL_GetRenderScale;
- SDL_GetRenderWindowSize;
SDL_GetSystemTheme;
SDL_CreatePopupWindow;
SDL_GetWindowParent;
@@ -856,6 +855,8 @@ SDL3_0.0.0 {
SDL_UnlockRWLock;
SDL_DestroyRWLock;
SDL_GetPath;
+ SDL_GetDisplayContentScale;
+ SDL_GetWindowDisplayScale;
# extra symbols go here (don't modify this line)
local: *;
};
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index c5f65c31f93a..56cf1f7cdc38 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -863,7 +863,6 @@
#define SDL_ConvertEventToRenderCoordinates SDL_ConvertEventToRenderCoordinates_REAL
#define SDL_SetRenderScale SDL_SetRenderScale_REAL
#define SDL_GetRenderScale SDL_GetRenderScale_REAL
-#define SDL_GetRenderWindowSize SDL_GetRenderWindowSize_REAL
#define SDL_GetSystemTheme SDL_GetSystemTheme_REAL
#define SDL_CreatePopupWindow SDL_CreatePopupWindow_REAL
#define SDL_GetWindowParent SDL_GetWindowParent_REAL
@@ -882,3 +881,5 @@
#define SDL_UnlockRWLock SDL_UnlockRWLock_REAL
#define SDL_DestroyRWLock SDL_DestroyRWLock_REAL
#define SDL_GetPath SDL_GetPath_REAL
+#define SDL_GetDisplayContentScale SDL_GetDisplayContentScale_REAL
+#define SDL_GetWindowDisplayScale SDL_GetWindowDisplayScale_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 5bfb06aadd55..f6e54223ecb7 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -908,7 +908,6 @@ SDL_DYNAPI_PROC(int,SDL_GetRenderOutputSize,(SDL_Renderer *a, int *b, int *c),(a
SDL_DYNAPI_PROC(int,SDL_ConvertEventToRenderCoordinates,(SDL_Renderer *a, SDL_Event *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderScale,(SDL_Renderer *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderScale,(SDL_Renderer *a, float *b, float *c),(a
(Patch may be truncated, please check the link at the top of this post.)