SDL 3.0 is going to be high DPI aware and officially separates screen… (#7145)

* SDL 3.0 is going to be high DPI aware and officially separates screen coordinates from client pixel area

The public APIs to disable high DPI support have been removed

Work in progress on https://github.com/libsdl-org/SDL/issues/7134
This commit is contained in:
Sam Lantinga 2023-01-25 01:23:17 -08:00 committed by GitHub
parent 78cc95e34e
commit 4696c9556b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 158 additions and 289 deletions

View file

@ -1147,10 +1147,10 @@ extern "C" {
* \brief A variable controlling whether relative mouse motion is affected by renderer scaling * \brief A variable controlling whether relative mouse motion is affected by renderer scaling
* *
* This variable can be set to the following values: * This variable can be set to the following values:
* "0" - Relative motion is unaffected by DPI or renderer's logical size * "0" - Relative motion is unaffected by display scale or renderer's logical size
* "1" - Relative motion is scaled according to DPI scaling and logical size * "1" - Relative motion is scaled according to display scale scaling and logical size
* *
* By default relative mouse deltas are affected by DPI and renderer scaling * By default relative mouse deltas are affected by display scale and renderer scaling
*/ */
#define SDL_HINT_MOUSE_RELATIVE_SCALING "SDL_MOUSE_RELATIVE_SCALING" #define SDL_HINT_MOUSE_RELATIVE_SCALING "SDL_MOUSE_RELATIVE_SCALING"
@ -1662,11 +1662,6 @@ extern "C" {
*/ */
#define SDL_HINT_VIDEO_EXTERNAL_CONTEXT "SDL_VIDEO_EXTERNAL_CONTEXT" #define SDL_HINT_VIDEO_EXTERNAL_CONTEXT "SDL_VIDEO_EXTERNAL_CONTEXT"
/**
* \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS)
*/
#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED"
/** /**
* \brief A variable that dictates policy for fullscreen Spaces on macOS. * \brief A variable that dictates policy for fullscreen Spaces on macOS.
* *
@ -2039,57 +2034,6 @@ extern "C" {
*/ */
#define SDL_HINT_WINDOWS_USE_D3D9EX "SDL_WINDOWS_USE_D3D9EX" #define SDL_HINT_WINDOWS_USE_D3D9EX "SDL_WINDOWS_USE_D3D9EX"
/**
* \brief Controls whether SDL will declare the process to be DPI aware.
*
* This hint must be set before initializing the video subsystem.
*
* The main purpose of declaring DPI awareness is to disable OS bitmap scaling of SDL windows on monitors with
* a DPI scale factor.
*
* This hint is equivalent to requesting DPI awareness via external means (e.g. calling SetProcessDpiAwarenessContext)
* and does not cause SDL to use a virtualized coordinate system, so it will generally give you 1 SDL coordinate = 1 pixel
* even on high-DPI displays.
*
* For more information, see:
* https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows
*
* This variable can be set to the following values:
* "" - Do not change the DPI awareness (default).
* "unaware" - Declare the process as DPI unaware. (Windows 8.1 and later).
* "system" - Request system DPI awareness. (Vista and later).
* "permonitor" - Request per-monitor DPI awareness. (Windows 8.1 and later).
* "permonitorv2" - Request per-monitor V2 DPI awareness. (Windows 10, version 1607 and later).
* The most visible difference from "permonitor" is that window title bar will be scaled
* to the visually correct size when dragging between monitors with different scale factors.
* This is the preferred DPI awareness level.
*
* If the requested DPI awareness is not available on the currently running OS, SDL will try to request the best
* available match.
*/
#define SDL_HINT_WINDOWS_DPI_AWARENESS "SDL_WINDOWS_DPI_AWARENESS"
/**
* \brief Uses DPI-scaled points as the SDL coordinate system on Windows.
*
* This changes the SDL coordinate system units to be DPI-scaled points, rather than pixels everywhere.
* This means windows will be appropriately sized, even when created on high-DPI displays with scaling.
*
* e.g. requesting a 640x480 window from SDL, on a display with 125% scaling in Windows display settings,
* will create a window with an 800x600 client area (in pixels).
*
* Setting this to "1" implicitly requests process DPI awareness (setting SDL_WINDOWS_DPI_AWARENESS is unnecessary),
* and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows.
*
* This variable can be set to the following values:
* "0" - SDL coordinates equal Windows coordinates. No automatic window resizing when dragging
* between monitors with different scale factors (unless this is performed by
* Windows itself, which is the case when the process is DPI unaware).
* "1" - SDL coordinates are in DPI-scaled points. Automatically resize windows as needed on
* displays with non-100% scale factors.
*/
#define SDL_HINT_WINDOWS_DPI_SCALING "SDL_WINDOWS_DPI_SCALING"
/** /**
* \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden
* *

View file

@ -106,7 +106,7 @@ typedef enum
{ {
SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */ SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */
SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */
/* 0x4 was SDL_WINDOW_SHOWN in SDL2, please reserve this bit for sdl2-compat. */ /* 0x00000004 was SDL_WINDOW_SHOWN in SDL2, please reserve this bit for sdl2-compat. */
SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */
SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */
SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */
@ -117,9 +117,7 @@ typedef enum
SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */
SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ),
SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */
SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported. /* 0x00002000 was SDL_WINDOW_ALLOW_HIGHDPI in SDL2, please reserve this bit for sdl2-compat. */
On macOS NSHighResolutionCapable must be set true in the
application's Info.plist for this to have any effect. */
SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to MOUSE_GRABBED) */ SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to MOUSE_GRABBED) */
SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */ SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */
SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */ SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */
@ -457,8 +455,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
* *
* \sa SDL_GetNumDisplayModes * \sa SDL_GetNumDisplayModes
*/ */
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, SDL_DisplayMode *mode);
SDL_DisplayMode * mode);
/** /**
* Get information about the desktop's display mode. * Get information about the desktop's display mode.
@ -594,8 +591,7 @@ extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window);
* \sa SDL_GetWindowDisplayMode * \sa SDL_GetWindowDisplayMode
* \sa SDL_SetWindowFullscreen * \sa SDL_SetWindowFullscreen
*/ */
extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window *window, const SDL_DisplayMode *mode);
const SDL_DisplayMode * mode);
/** /**
* Query the display mode to use when a window is visible at fullscreen. * Query the display mode to use when a window is visible at fullscreen.
@ -611,8 +607,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
* \sa SDL_SetWindowDisplayMode * \sa SDL_SetWindowDisplayMode
* \sa SDL_SetWindowFullscreen * \sa SDL_SetWindowFullscreen
*/ */
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode);
SDL_DisplayMode * mode);
/** /**
* Get the raw ICC profile data for the screen the window is currently on. * Get the raw ICC profile data for the screen the window is currently on.
@ -656,22 +651,19 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
* - `SDL_WINDOW_MINIMIZED`: window is minimized * - `SDL_WINDOW_MINIMIZED`: window is minimized
* - `SDL_WINDOW_MAXIMIZED`: window is maximized * - `SDL_WINDOW_MAXIMIZED`: window is maximized
* - `SDL_WINDOW_INPUT_GRABBED`: window has grabbed input focus * - `SDL_WINDOW_INPUT_GRABBED`: window has grabbed input focus
* - `SDL_WINDOW_ALLOW_HIGHDPI`: window should be created in high-DPI mode if
* supported (>= SDL 2.0.1)
* *
* The SDL_Window is implicitly shown if SDL_WINDOW_HIDDEN is not set. * The SDL_Window is implicitly shown if SDL_WINDOW_HIDDEN is not set.
* *
* On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist
* property to YES, otherwise you will not receive a High-DPI OpenGL canvas. * property to YES, otherwise you will not receive a High-DPI OpenGL canvas.
* *
* If the window is created with the `SDL_WINDOW_ALLOW_HIGHDPI` flag, its size * The window size in pixels may differ from its size in screen coordinates if
* in pixels may differ from its size in screen coordinates on platforms with * the window is on a high density display (one with an OS scaling factor).
* high-DPI support (e.g. iOS and macOS). Use SDL_GetWindowSize() to query the * Use SDL_GetWindowSize() to query the client area's size in screen coordinates,
* client area's size in screen coordinates, and SDL_GetWindowSizeInPixels() or * and SDL_GetWindowSizeInPixels() or SDL_GetRendererOutputSize() to query the
* SDL_GetRendererOutputSize() to query the drawable size in pixels. Note that * drawable size in pixels. Note that the drawable size can vary after the window
* when this flag is set, the drawable size can vary after the window is * is created and should be queried again when the window is resized or moved
* created and should be queried after major window events such as when the * between displays.
* window is resized or moved between displays.
* *
* If the window is set fullscreen, the width and height parameters `w` and * If the window is set fullscreen, the width and height parameters `w` and
* `h` will not be used. However, invalid size parameters (e.g. too large) may * `h` will not be used. However, invalid size parameters (e.g. too large) may
@ -709,9 +701,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window);
* \sa SDL_CreateWindowFrom * \sa SDL_CreateWindowFrom
* \sa SDL_DestroyWindow * \sa SDL_DestroyWindow
*/ */
extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags);
int x, int y, int w,
int h, Uint32 flags);
/** /**
* Create an SDL window from an existing native window. * Create an SDL window from an existing native window.
@ -794,8 +784,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window);
* *
* \sa SDL_GetWindowTitle * \sa SDL_GetWindowTitle
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window *window, const char *title);
const char *title);
/** /**
* Get the title of a window. * Get the title of a window.
@ -818,8 +807,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon);
SDL_Surface * icon);
/** /**
* Associate an arbitrary named pointer with a window. * Associate an arbitrary named pointer with a window.
@ -835,9 +823,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
* *
* \sa SDL_GetWindowData * \sa SDL_GetWindowData
*/ */
extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, extern DECLSPEC void *SDLCALL SDL_SetWindowData(SDL_Window *window, const char *name, void *userdata);
const char *name,
void *userdata);
/** /**
* Retrieve the data pointer associated with a window. * Retrieve the data pointer associated with a window.
@ -850,101 +836,86 @@ extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window,
* *
* \sa SDL_SetWindowData * \sa SDL_SetWindowData
*/ */
extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window *window, const char *name);
const char *name);
/** /**
* Set the position of a window. * Set the position of a window, in screen coordinates.
*
* The window coordinate origin is the upper left of the display.
* *
* \param window the window to reposition * \param window the window to reposition
* \param x the x coordinate of the window in screen coordinates, or * \param x the x coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED`
* `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED` * \param y the y coordinate of the window, or `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED`
* \param y the y coordinate of the window in screen coordinates, or
* `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED`
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetWindowPosition * \sa SDL_GetWindowPosition
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window *window, int x, int y);
int x, int y);
/** /**
* Get the position of a window. * Get the position of a window, in screen coordinates.
* *
* If you do not need the value for one of the positions a NULL may be passed * If you do not need the value for one of the positions a NULL may be passed
* in the `x` or `y` parameter. * in the `x` or `y` parameter.
* *
* \param window the window to query * \param window the window to query
* \param x a pointer filled in with the x position of the window, in screen * \param x a pointer filled in with the x position of the window, may be NULL
* coordinates, may be NULL * \param y a pointer filled in with the y position of the window, may be NULL
* \param y a pointer filled in with the y position of the window, in screen
* coordinates, may be NULL
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_SetWindowPosition * \sa SDL_SetWindowPosition
*/ */
extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window *window, int *x, int *y);
int *x, int *y);
/** /**
* Set the size of a window's client area. * 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, * The window size in screen coordinates may differ from the size in pixels if
* if the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a platform * the window is on a high density display (one with an OS scaling factor).
* with high-dpi support (e.g. iOS or macOS). Use SDL_GL_GetDrawableSize() or
* SDL_GetRendererOutputSize() to get the real client area size in pixels.
* *
* Fullscreen windows automatically match the size of the display mode, and * Fullscreen windows automatically match the size of the display mode, and
* you should use SDL_SetWindowDisplayMode() to change their size. * you should use SDL_SetWindowDisplayMode() to change their size.
* *
* \param window the window to change * \param window the window to change
* \param w the width of the window in pixels, in screen coordinates, must be * \param w the width of the window, must be > 0
* > 0 * \param h the height of the window, must be > 0
* \param h the height of the window in pixels, in screen coordinates, must be
* > 0
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetWindowSize * \sa SDL_GetWindowSize
* \sa SDL_SetWindowDisplayMode * \sa SDL_SetWindowDisplayMode
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h);
int h);
/** /**
* Get the size of a window's client area. * Get the size of a window's client area, in screen coordinates.
* *
* NULL can safely be passed as the `w` or `h` parameter if the width or * NULL can safely be passed as the `w` or `h` parameter if the width or
* height value is not desired. * height value is not desired.
* *
* The window size in screen coordinates may differ from the size in pixels, * The window size in screen coordinates may differ from the size in pixels if
* if the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a platform * the window is on a high density display (one with an OS scaling factor).
* with high-dpi support (e.g. iOS or macOS). Use SDL_GetWindowSizeInPixels(), * Use SDL_GetWindowSizeInPixels(), SDL_GL_GetDrawableSize(),
* SDL_GL_GetDrawableSize(), SDL_Vulkan_GetDrawableSize(), or * SDL_Vulkan_GetDrawableSize(), or SDL_GetRendererOutputSize() to get the
* SDL_GetRendererOutputSize() to get the real client area size in pixels. * real client area size in pixels.
* *
* \param window the window to query the width and height from * \param window the window to query the width and height from
* \param w a pointer filled in with the width of the window, in screen * \param w a pointer filled in with the width of the window, may be NULL
* coordinates, may be NULL * \param h a pointer filled in with the height of the window, may be NULL
* \param h a pointer filled in with the height of the window, in screen
* coordinates, may be NULL
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetWindowSizeInPixels
* \sa SDL_GL_GetDrawableSize * \sa SDL_GL_GetDrawableSize
* \sa SDL_Vulkan_GetDrawableSize * \sa SDL_Vulkan_GetDrawableSize
* \sa SDL_GetWindowSizeInPixels * \sa SDL_GetRendererOutputSize
* \sa SDL_SetWindowSize * \sa SDL_SetWindowSize
*/ */
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
int *h);
/** /**
* Get the size of a window's borders (decorations) around the client area. * Get the size of a window's borders (decorations) around the client area,
* in screen coordinates.
* *
* Note: If this function fails (returns -1), the size values will be * 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 * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the
@ -975,17 +946,13 @@ extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
* *
* \sa SDL_GetWindowSize * \sa SDL_GetWindowSize
*/ */
extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right);
int *top, int *left,
int *bottom, int *right);
/** /**
* Get the size of a window in pixels. * Get the size of a window's client area, in pixels.
* *
* This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI * The window size in pixels may differ from the size in screen coordinates if
* drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a * the window is on a high density display (one with an OS scaling factor).
* platform with high-DPI support (Apple calls this "Retina"), and not
* disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint.
* *
* \param window the window from which the drawable size should be queried * \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 w a pointer to variable for storing the width in pixels, may be NULL
@ -997,26 +964,24 @@ extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window * window,
* \sa SDL_CreateWindow * \sa SDL_CreateWindow
* \sa SDL_GetWindowSize * \sa SDL_GetWindowSize
*/ */
extern DECLSPEC void SDLCALL SDL_GetWindowSizeInPixels(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h);
int *w, int *h);
/** /**
* Set the minimum size of a window's client area. * Set the minimum size of a window's client area, in screen coordinates.
* *
* \param window the window to change * \param window the window to change
* \param min_w the minimum width of the window in pixels * \param min_w the minimum width of the window
* \param min_h the minimum height of the window in pixels * \param min_h the minimum height of the window
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetWindowMinimumSize * \sa SDL_GetWindowMinimumSize
* \sa SDL_SetWindowMaximumSize * \sa SDL_SetWindowMaximumSize
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h);
int min_w, int min_h);
/** /**
* Get the minimum size of a window's client area. * Get the minimum size of a window's client area, in screen coordinates.
* *
* \param window the window to query * \param window the window to query
* \param w a pointer filled in with the minimum width of the window, may be * \param w a pointer filled in with the minimum width of the window, may be
@ -1029,26 +994,24 @@ extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,
* \sa SDL_GetWindowMaximumSize * \sa SDL_GetWindowMaximumSize
* \sa SDL_SetWindowMinimumSize * \sa SDL_SetWindowMinimumSize
*/ */
extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w, int *h);
int *w, int *h);
/** /**
* Set the maximum size of a window's client area. * Set the maximum size of a window's client area, in screen coordinates.
* *
* \param window the window to change * \param window the window to change
* \param max_w the maximum width of the window in pixels * \param max_w the maximum width of the window
* \param max_h the maximum height of the window in pixels * \param max_h the maximum height of the window
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetWindowMaximumSize * \sa SDL_GetWindowMaximumSize
* \sa SDL_SetWindowMinimumSize * \sa SDL_SetWindowMinimumSize
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h);
int max_w, int max_h);
/** /**
* Get the maximum size of a window's client area. * Get the maximum size of a window's client area, in screen coordinates.
* *
* \param window the window to query * \param window the window to query
* \param w a pointer filled in with the maximum width of the window, may be * \param w a pointer filled in with the maximum width of the window, may be
@ -1061,8 +1024,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window,
* \sa SDL_GetWindowMinimumSize * \sa SDL_GetWindowMinimumSize
* \sa SDL_SetWindowMaximumSize * \sa SDL_SetWindowMaximumSize
*/ */
extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window *window, int *w, int *h);
int *w, int *h);
/** /**
* Set the border state of a window. * Set the border state of a window.
@ -1080,8 +1042,7 @@ extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window,
* *
* \sa SDL_GetWindowFlags * \sa SDL_GetWindowFlags
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window *window, SDL_bool bordered);
SDL_bool bordered);
/** /**
* Set the user-resizable state of a window. * Set the user-resizable state of a window.
@ -1099,8 +1060,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window,
* *
* \sa SDL_GetWindowFlags * \sa SDL_GetWindowFlags
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
SDL_bool resizable);
/** /**
* Set the window to always be above the others. * Set the window to always be above the others.
@ -1116,8 +1076,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window * window,
* *
* \sa SDL_GetWindowFlags * \sa SDL_GetWindowFlags
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window *window, SDL_bool on_top);
SDL_bool on_top);
/** /**
* Show a window. * Show a window.
@ -1204,8 +1163,7 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window);
* \sa SDL_GetWindowDisplayMode * \sa SDL_GetWindowDisplayMode
* \sa SDL_SetWindowDisplayMode * \sa SDL_SetWindowDisplayMode
*/ */
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window *window, Uint32 flags);
Uint32 flags);
/** /**
* Get the SDL surface associated with the window. * Get the SDL surface associated with the window.
@ -1271,9 +1229,7 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window);
* \sa SDL_GetWindowSurface * \sa SDL_GetWindowSurface
* \sa SDL_UpdateWindowSurface * \sa SDL_UpdateWindowSurface
*/ */
extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, int numrects);
const SDL_Rect * rects,
int numrects);
/** /**
* Set a window's input grab mode. * Set a window's input grab mode.
@ -1293,8 +1249,7 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
* \sa SDL_GetGrabbedWindow * \sa SDL_GetGrabbedWindow
* \sa SDL_GetWindowGrab * \sa SDL_GetWindowGrab
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window *window, SDL_bool grabbed);
SDL_bool grabbed);
/** /**
* Set a window's keyboard grab mode. * Set a window's keyboard grab mode.
@ -1324,8 +1279,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
* \sa SDL_SetWindowMouseGrab * \sa SDL_SetWindowMouseGrab
* \sa SDL_SetWindowGrab * \sa SDL_SetWindowGrab
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window *window, SDL_bool grabbed);
SDL_bool grabbed);
/** /**
* Set a window's mouse grab mode. * Set a window's mouse grab mode.
@ -1341,8 +1295,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window * window,
* \sa SDL_SetWindowKeyboardGrab * \sa SDL_SetWindowKeyboardGrab
* \sa SDL_SetWindowGrab * \sa SDL_SetWindowGrab
*/ */
extern DECLSPEC void SDLCALL SDL_SetWindowMouseGrab(SDL_Window * window, extern DECLSPEC void SDLCALL SDL_SetWindowMouseGrab(SDL_Window *window, SDL_bool grabbed);
SDL_bool grabbed);
/** /**
* Get a window's input grab mode. * Get a window's input grab mode.
@ -1568,9 +1521,7 @@ typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win,
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data);
SDL_HitTest callback,
void *callback_data);
/** /**
* Request a window to demand attention from the user. * Request a window to demand attention from the user.
@ -1770,8 +1721,7 @@ extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char *extension);
*extension);
/** /**
* Reset all previously set OpenGL context attributes to their default values. * Reset all previously set OpenGL context attributes to their default values.
@ -1838,8 +1788,7 @@ extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
* \sa SDL_GL_DeleteContext * \sa SDL_GL_DeleteContext
* \sa SDL_GL_MakeCurrent * \sa SDL_GL_MakeCurrent
*/ */
extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *window);
window);
/** /**
* Set up an OpenGL context for rendering into an OpenGL window. * Set up an OpenGL context for rendering into an OpenGL window.
@ -1855,8 +1804,7 @@ extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *
* *
* \sa SDL_GL_CreateContext * \sa SDL_GL_CreateContext
*/ */
extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context);
SDL_GLContext context);
/** /**
* Get the currently active OpenGL window. * Get the currently active OpenGL window.
@ -1941,11 +1889,6 @@ extern DECLSPEC void SDLCALL SDL_EGL_SetEGLAttributeCallbacks(SDL_EGLAttribArray
* *
* This returns info useful for calling glViewport(). * This returns info useful for calling glViewport().
* *
* This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI
* drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a
* platform with high-DPI support (Apple calls this "Retina"), and not
* disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint.
*
* \param window the window from which the drawable size should be queried * \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 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 * \param h a pointer to variable for storing the height in pixels, may be
@ -1956,8 +1899,7 @@ extern DECLSPEC void SDLCALL SDL_EGL_SetEGLAttributeCallbacks(SDL_EGLAttribArray
* \sa SDL_CreateWindow * \sa SDL_CreateWindow
* \sa SDL_GetWindowSize * \sa SDL_GetWindowSize
*/ */
extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window *window, int *w, int *h);
int *h);
/** /**
* Set the swap interval for the current OpenGL context. * Set the swap interval for the current OpenGL context.

View file

@ -251,10 +251,6 @@ int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
state->num_windows = 1; state->num_windows = 1;
return 1; return 1;
} }
if (SDL_strcasecmp(argv[index], "--allow-highdpi") == 0) {
state->window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
return 1;
}
if (SDL_strcasecmp(argv[index], "--windows") == 0) { if (SDL_strcasecmp(argv[index], "--windows") == 0) {
++index; ++index;
if (!argv[index] || !SDL_isdigit((unsigned char)*argv[index])) { if (!argv[index] || !SDL_isdigit((unsigned char)*argv[index])) {
@ -716,9 +712,6 @@ static void SDLTest_PrintWindowFlag(char *text, size_t maxlen, Uint32 flag)
case SDL_WINDOW_FOREIGN: case SDL_WINDOW_FOREIGN:
SDL_snprintfcat(text, maxlen, "FOREIGN"); SDL_snprintfcat(text, maxlen, "FOREIGN");
break; break;
case SDL_WINDOW_ALLOW_HIGHDPI:
SDL_snprintfcat(text, maxlen, "ALLOW_HIGHDPI");
break;
case SDL_WINDOW_MOUSE_CAPTURE: case SDL_WINDOW_MOUSE_CAPTURE:
SDL_snprintfcat(text, maxlen, "MOUSE_CAPTURE"); SDL_snprintfcat(text, maxlen, "MOUSE_CAPTURE");
break; break;
@ -767,7 +760,6 @@ static void SDLTest_PrintWindowFlags(char *text, size_t maxlen, Uint32 flags)
SDL_WINDOW_MOUSE_FOCUS, SDL_WINDOW_MOUSE_FOCUS,
SDL_WINDOW_FULLSCREEN_DESKTOP, SDL_WINDOW_FULLSCREEN_DESKTOP,
SDL_WINDOW_FOREIGN, SDL_WINDOW_FOREIGN,
SDL_WINDOW_ALLOW_HIGHDPI,
SDL_WINDOW_MOUSE_CAPTURE, SDL_WINDOW_MOUSE_CAPTURE,
SDL_WINDOW_ALWAYS_ON_TOP, SDL_WINDOW_ALWAYS_ON_TOP,
SDL_WINDOW_SKIP_TASKBAR, SDL_WINDOW_SKIP_TASKBAR,

View file

@ -516,4 +516,7 @@ extern void SDL_ToggleDragAndDropSupport(void);
extern int SDL_GetDisplayIndexForPoint(const SDL_Point *point); extern int SDL_GetDisplayIndexForPoint(const SDL_Point *point);
/* This has been moved out of the public API, but is still available for now */
#define SDL_WINDOW_ALLOW_HIGHDPI 0x00002000
#endif /* SDL_sysvideo_h_ */ #endif /* SDL_sysvideo_h_ */

View file

@ -1650,13 +1650,8 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint
} }
} }
/* Unless the user has specified the high-DPI disabling hint, respect the if (!SDL_GetHintBoolean("SDL_VIDEO_HIGHDPI_DISABLED", SDL_FALSE)) {
* SDL_WINDOW_ALLOW_HIGHDPI flag. flags |= SDL_WINDOW_ALLOW_HIGHDPI;
*/
if (flags & SDL_WINDOW_ALLOW_HIGHDPI) {
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_HIGHDPI_DISABLED, SDL_FALSE)) {
flags &= ~SDL_WINDOW_ALLOW_HIGHDPI;
}
} }
window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); window = (SDL_Window *)SDL_calloc(1, sizeof(*window));

View file

@ -385,10 +385,9 @@ static const char *WIN_GetDPIAwareness(_THIS)
static void WIN_InitDPIAwareness(_THIS) static void WIN_InitDPIAwareness(_THIS)
{ {
const char *hint = SDL_GetHint(SDL_HINT_WINDOWS_DPI_AWARENESS); const char *hint = SDL_GetHint("SDL_WINDOWS_DPI_AWARENESS");
if (hint != NULL) { if (hint == NULL || SDL_strcmp(hint, "permonitorv2") == 0) {
if (SDL_strcmp(hint, "permonitorv2") == 0) {
WIN_DeclareDPIAwarePerMonitorV2(_this); WIN_DeclareDPIAwarePerMonitorV2(_this);
} else if (SDL_strcmp(hint, "permonitor") == 0) { } else if (SDL_strcmp(hint, "permonitor") == 0) {
WIN_DeclareDPIAwarePerMonitor(_this); WIN_DeclareDPIAwarePerMonitor(_this);
@ -398,13 +397,12 @@ static void WIN_InitDPIAwareness(_THIS)
WIN_DeclareDPIAwareUnaware(_this); WIN_DeclareDPIAwareUnaware(_this);
} }
} }
}
static void WIN_InitDPIScaling(_THIS) static void WIN_InitDPIScaling(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_DPI_SCALING, SDL_FALSE)) { if (SDL_GetHintBoolean("SDL_WINDOWS_DPI_SCALING", SDL_TRUE)) {
WIN_DeclareDPIAwarePerMonitorV2(_this); WIN_DeclareDPIAwarePerMonitorV2(_this);
data->dpi_scaling_enabled = SDL_TRUE; data->dpi_scaling_enabled = SDL_TRUE;

View file

@ -21,7 +21,6 @@ const char *HintsEnum[] = {
SDL_HINT_RENDER_VSYNC, SDL_HINT_RENDER_VSYNC,
SDL_HINT_TIMER_RESOLUTION, SDL_HINT_TIMER_RESOLUTION,
SDL_HINT_VIDEO_ALLOW_SCREENSAVER, SDL_HINT_VIDEO_ALLOW_SCREENSAVER,
SDL_HINT_VIDEO_HIGHDPI_DISABLED,
SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES,
SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT, SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT,
@ -45,7 +44,6 @@ const char *HintsVerbose[] = {
"SDL_RENDER_VSYNC", "SDL_RENDER_VSYNC",
"SDL_TIMER_RESOLUTION", "SDL_TIMER_RESOLUTION",
"SDL_VIDEO_ALLOW_SCREENSAVER", "SDL_VIDEO_ALLOW_SCREENSAVER",
"SDL_VIDEO_HIGHDPI_DISABLED",
"SDL_VIDEO_MAC_FULLSCREEN_SPACES", "SDL_VIDEO_MAC_FULLSCREEN_SPACES",
"SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS", "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS",
"SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT", "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT",

View file

@ -1753,7 +1753,7 @@ int video_setWindowCenteredOnDisplay(void *arg)
expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2)); expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2));
expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2)); expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2));
window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_ALLOW_HIGHDPI); window = SDL_CreateWindow(title, x, y, w, h, 0);
SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h);
SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL");

View file

@ -103,9 +103,6 @@ int main(int argc, char *argv[])
/* Enable standard application logging */ /* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Enable highdpi scaling on Windows */
SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, "1");
/* Initialize SDL */ /* Initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) != 0) { if (SDL_Init(SDL_INIT_VIDEO) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
@ -113,7 +110,7 @@ int main(int argc, char *argv[])
} }
/* Create window and renderer for given surface */ /* Create window and renderer for given surface */
window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE);
if (window == NULL) { if (window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError()); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError());
return 1; return 1;