Displays are now referenced by instance ID instead of index

This commit is contained in:
Sam Lantinga 2023-01-29 13:30:55 -08:00
parent 758c0dd6d8
commit 22c69bccdf
157 changed files with 1620 additions and 1589 deletions

View file

@ -215,7 +215,7 @@ typedef struct SDL_DisplayEvent
{
Uint32 type; /**< ::SDL_DISPLAYEVENT_* */
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
Uint32 display; /**< The associated display index */
SDL_DisplayID displayID;/**< The associated display */
Sint32 data1; /**< event dependent data */
} SDL_DisplayEvent;

View file

@ -413,8 +413,9 @@
/* ##SDL_video.h */
#define SDL_GetDisplayDPI SDL_GetDisplayPhysicalDPI
#define SDL_GetPointDisplayIndex SDL_GetDisplayIndexForPoint
#define SDL_GetRectDisplayIndex SDL_GetDisplayIndexForRect
#define SDL_GetPointDisplayIndex SDL_GetDisplayForPoint
#define SDL_GetRectDisplayIndex SDL_GetDisplayForRect
#define SDL_GetWindowDisplayIndex SDL_GetDisplayForWindow
#define SDL_WINDOW_FULLSCREEN SDL_WINDOW_FULLSCREEN_EXCLUSIVE
#define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_MOUSE_GRABBED
@ -795,8 +796,9 @@
/* ##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
#define SDL_GetPointDisplayIndex SDL_GetPointDisplayIndex_renamed_SDL_GetDisplayForPoint
#define SDL_GetRectDisplayIndex SDL_GetRectDisplayIndex_renamed_SDL_GetDisplayForRect
#define SDL_GetWindowDisplayIndex SDL_GetWindowDisplayIndex_renamed_SDL_GetDisplayForWindow
#define SDL_WINDOW_FULLSCREEN SDL_WINDOW_FULLSCREEN_renamed_SDL_WINDOW_FULLSCREEN_EXCLUSIVE
#define SDL_WINDOW_INPUT_GRABBED SDL_WINDOW_INPUT_GRABBED_renamed_SDL_WINDOW_MOUSE_GRABBED

View file

@ -42,7 +42,7 @@ extern "C" {
/* Platform specific functions for Windows */
#if defined(__WIN32__) || defined(__GDK__)
typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam);
/**
@ -60,19 +60,18 @@ extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook ca
#if defined(__WIN32__) || defined(__WINGDK__)
/**
* Get the D3D9 adapter index that matches the specified display index.
* Get the D3D9 adapter index that matches the specified display.
*
* The returned adapter index can be passed to `IDirect3D9::CreateDevice` and
* controls on which monitor a full screen application will appear.
*
* \param displayIndex the display index for which to get the D3D9 adapter
* index
* \param displayID the instance of the display to query
* \returns the D3D9 adapter index 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.
*/
extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex );
extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID);
typedef struct IDirect3DDevice9 IDirect3DDevice9;
@ -131,16 +130,13 @@ extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* ren
#if defined(__WIN32__) || defined(__WINGDK__)
/**
* Get the DXGI Adapter and Output indices for the specified display index.
* Get the DXGI Adapter and Output indices for the specified display.
*
* The DXGI Adapter and Output indices can be passed to `EnumAdapters` and
* `EnumOutputs` respectively to get the objects required to create a DX10 or
* DX11 device and swap chain.
*
* Before SDL 2.0.4 this function did not return a value. Since SDL 2.0.4 it
* returns an SDL_bool.
*
* \param displayIndex the display index for which to get both indices
* \param displayID the instance of the display to query
* \param adapterIndex a pointer to be filled in with the adapter index
* \param outputIndex a pointer to be filled in with the output index
* \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
@ -148,7 +144,7 @@ extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* ren
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex );
extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex);
#endif /* defined(__WIN32__) || defined(__WINGDK__) */
@ -182,9 +178,9 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int prio
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy);
#endif /* __LINUX__ */
/* Platform specific functions for iOS */
#ifdef __IOS__

View file

@ -40,6 +40,7 @@ extern "C" {
#endif
typedef Uint32 SDL_DisplayID;
typedef Uint32 SDL_WindowID;
/**
@ -300,53 +301,61 @@ extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void);
/**
* Get the number of available video displays.
* Get a list of currently connected displays.
*
* \returns a number >= 1 or a negative error code on failure; call
* SDL_GetError() for more information.
* \param count a pointer filled in with the number of displays returned
* \returns a 0 terminated array of display instance IDs which should be
* freed with SDL_free(), or NULL on error; call SDL_GetError() for
* more details.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_DisplayID *SDLCALL SDL_GetDisplays(int *count);
/**
* Return the primary display.
*
* \returns the instance ID of the primary display on success or 0 on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void);
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
/**
* Get the name of a display in UTF-8 encoding.
*
* \param displayIndex the index of display from which the name should be
* queried
* \returns the name of a display or NULL for an invalid display index or
* failure; call SDL_GetError() for more information.
* \param displayID the instance ID of the display to query
* \returns the name of a display or NULL on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC const char *SDLCALL SDL_GetDisplayName(int displayIndex);
extern DECLSPEC const char *SDLCALL SDL_GetDisplayName(SDL_DisplayID displayID);
/**
* Get the desktop area represented by a display, in screen coordinates.
*
* The primary display (`displayIndex` zero) is always located at 0,0.
* The primary display is always located at (0,0).
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param rect the SDL_Rect structure filled in with the display bounds
* \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_GetNumVideoDisplays
* \sa SDL_GetDisplayUsableBounds
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect);
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect);
/**
* Get the usable desktop area represented by a display, in screen
* coordinates.
*
* The primary display (`displayIndex` zero) is always located at 0,0.
*
* This is the same area as SDL_GetDisplayBounds() reports, but with portions
* reserved by the system removed. For example, on Apple's macOS, this
* subtracts the area occupied by the menu bar and dock.
@ -355,13 +364,7 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rec
* so these are good guidelines for the maximum space available to a
* non-fullscreen window.
*
* The parameter `rect` is ignored if it is NULL.
*
* This function also returns -1 if the parameter `displayIndex` is out of
* range.
*
* \param displayIndex the index of the display to query the usable bounds
* from
* \param displayID the instance ID of the display to query
* \param rect the SDL_Rect structure filled in with the display bounds
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
@ -369,9 +372,9 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rec
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect *rect);
extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect);
/**
* Get the dots/pixels-per-inch for a display.
@ -379,9 +382,6 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rec
* Diagonal, horizontal and vertical DPI can all be optionally returned if the
* appropriate parameter is non-NULL.
*
* A failure of this function usually means that either no DPI information is
* available or the `displayIndex` is out of range.
*
* **WARNING**: This reports the DPI that the hardware reports, and it is not
* always reliable! It is almost always better to use SDL_GetWindowSize() to
* find the window size, which might be in logical points instead of pixels,
@ -390,8 +390,7 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rec
* will be rethinking how high-dpi details should be managed in SDL3 to make
* things more consistent, reliable, and clear.
*
* \param displayIndex the index of the display from which DPI information
* should be queried
* \param displayID the instance ID of the display to query
* \param ddpi a pointer filled in with the diagonal DPI of the display; may
* be NULL
* \param hdpi a pointer filled in with the horizontal DPI of the display; may
@ -403,53 +402,51 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rec
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayPhysicalDPI(int displayIndex, float *ddpi, float *hdpi, float *vdpi);
extern DECLSPEC int SDLCALL SDL_GetDisplayPhysicalDPI(SDL_DisplayID displayID, float *ddpi, float *hdpi, float *vdpi);
/**
* Get the orientation of a display.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \returns The SDL_DisplayOrientation enum value of the display, or
* `SDL_ORIENTATION_UNKNOWN` if it isn't available.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex);
extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(SDL_DisplayID displayID);
/**
* Get the number of available display modes.
*
* The `displayIndex` needs to be in the range from 0 to
* SDL_GetNumVideoDisplays() - 1.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \returns a number >= 1 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_GetDisplayMode
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(SDL_DisplayID displayID);
/**
* Get information about a specific display mode.
*
* The display modes are sorted in this priority:
*
* - width -> largest to smallest
* - height -> largest to smallest
* - display_scale -> smallest to largest
* - screen_w -> largest to smallest
* - screen_h -> largest to smallest
* - pixel_w -> largest to smallest
* - pixel_h -> largest to smallest
* - bits per pixel -> more colors to fewer colors
* - packed pixel layout -> largest to smallest
* - refresh rate -> highest to lowest
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param modeIndex the index of the display mode to query
* \param mode an SDL_DisplayMode structure filled in with the mode at
* `modeIndex`
@ -460,7 +457,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex);
*
* \sa SDL_GetNumDisplayModes
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, SDL_DisplayMode *mode);
extern DECLSPEC int SDLCALL SDL_GetDisplayMode(SDL_DisplayID displayID, int modeIndex, SDL_DisplayMode *mode);
/**
* Get information about the desktop's display mode.
@ -470,7 +467,7 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
* function will return the previous native display mode, and not the current
* display mode.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param mode an SDL_DisplayMode structure filled in with the current display
* mode
* \returns 0 on success or a negative error code on failure; call
@ -482,7 +479,7 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex,
* \sa SDL_GetDisplayMode
* \sa SDL_SetWindowDisplayMode
*/
extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode *mode);
extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayID displayID, SDL_DisplayMode *mode);
/**
* Get information about the current display mode.
@ -492,7 +489,7 @@ extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_Disp
* function will return the current display mode, and not the previous native
* display mode.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param mode an SDL_DisplayMode structure filled in with the current display
* mode
* \returns 0 on success or a negative error code on failure; call
@ -502,11 +499,10 @@ extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_Disp
*
* \sa SDL_GetDesktopDisplayMode
* \sa SDL_GetDisplayMode
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
* \sa SDL_SetWindowDisplayMode
*/
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode *mode);
extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID, SDL_DisplayMode *mode);
/**
* Get the closest match to the requested display mode.
@ -518,9 +514,9 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_Disp
* and finally checking the refresh rate. If all the available modes are too
* small, then NULL is returned.
*
* \param displayIndex the index of the display to query
* \param displayID the instance ID of the display to query
* \param mode an SDL_DisplayMode structure containing the desired display
* mode
* mode, should be zero initialized
* \param closest an SDL_DisplayMode structure filled in with the closest
* match of the available display modes
* \returns the passed in value `closest` or NULL if no matching video mode
@ -531,51 +527,48 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_Disp
* \sa SDL_GetDisplayMode
* \sa SDL_GetNumDisplayModes
*/
extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode *mode, SDL_DisplayMode *closest);
extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(SDL_DisplayID displayID, const SDL_DisplayMode *mode, SDL_DisplayMode *closest);
/**
* Get the index of the display containing a point
* Get the display containing a point
*
* \param point the point to query
* \returns the index of the display containing the point or a negative error
* code on failure; call SDL_GetError() for more information.
* \returns the instance ID of the display containing the point or 0 on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayIndexForPoint(const SDL_Point *point);
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
/**
* Get the index of the display primarily containing a rect
* Get the display primarily containing a rect
*
* \param rect the rect to query
* \returns the index of the display entirely containing the rect or closest
* to the center of the rect on success or a negative error code on
* failure; call SDL_GetError() for more information.
* \returns the instance ID of the display entirely containing the rect or closest
* to the center of the rect on success or 0 on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetDisplayIndexForRect(const SDL_Rect *rect);
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForRect(const SDL_Rect *rect);
/**
* Get the index of the display associated with a window.
* Get the display associated with a window.
*
* \param window the window to query
* \returns the index of the display containing the center of the window on
* success or a negative error code on failure; call SDL_GetError()
* for more information.
* \returns the instance ID of the display containing the center of the window on
* success or 0 on failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetDisplayBounds
* \sa SDL_GetNumVideoDisplays
* \sa SDL_GetDisplays
*/
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window *window);
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForWindow(SDL_Window *window);
/**
* Set the display mode to use when a window is visible at fullscreen.