Added display properties

main
Sam Lantinga 2023-11-07 09:58:49 -08:00
parent a02afbaea5
commit 0cd4b7d3e3
6 changed files with 32 additions and 0 deletions

View File

@ -339,6 +339,20 @@ extern DECLSPEC SDL_DisplayID *SDLCALL SDL_GetDisplays(int *count);
*/
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
/**
* Get the properties associated with a display.
*
* \param displayID the instance ID of the display to query
* \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetProperty
* \sa SDL_SetProperty
*/
extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_DisplayID displayID);
/**
* Get the name of a display in UTF-8 encoding.
*

View File

@ -923,6 +923,7 @@ SDL3_0.0.0 {
SDL_RWprintf;
SDL_RWvprintf;
SDL_AllocateEventMemory;
SDL_GetDisplayProperties;
# extra symbols go here (don't modify this line)
local: *;
};

View File

@ -948,3 +948,4 @@
#define SDL_RWprintf SDL_RWprintf_REAL
#define SDL_RWvprintf SDL_RWvprintf_REAL
#define SDL_AllocateEventMemory SDL_AllocateEventMemory_REAL
#define SDL_GetDisplayProperties SDL_GetDisplayProperties_REAL

View File

@ -981,3 +981,4 @@ SDL_DYNAPI_PROC(int,SDL_ClearProperty,(SDL_PropertiesID a, const char *b),(a,b),
SDL_DYNAPI_PROC(int,SDL_EnterAppMainCallbacks,(int a, char *b[], SDL_AppInit_func c, SDL_AppIterate_func d, SDL_AppEvent_func e, SDL_AppQuit_func f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(size_t,SDL_RWvprintf,(SDL_RWops *a, const char *b, va_list c),(a,b,c),return)
SDL_DYNAPI_PROC(void*,SDL_AllocateEventMemory,(size_t a),(a),return)
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetDisplayProperties,(SDL_DisplayID a),(a),return)

View File

@ -146,6 +146,8 @@ struct SDL_VideoDisplay
SDL_VideoDevice *device;
SDL_PropertiesID props;
SDL_DisplayData *driverdata;
};

View File

@ -717,6 +717,7 @@ void SDL_DelVideoDisplay(SDL_DisplayID displayID, SDL_bool send_event)
SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_REMOVED, 0);
}
SDL_DestroyProperties(display->props);
SDL_free(display->name);
SDL_ResetFullscreenDisplayModes(display);
SDL_free(display->desktop_mode.driverdata);
@ -820,6 +821,18 @@ SDL_DisplayData *SDL_GetDisplayDriverDataForWindow(SDL_Window *window)
return SDL_GetDisplayDriverData(SDL_GetDisplayForWindow(window));
}
SDL_PropertiesID SDL_GetDisplayProperties(SDL_DisplayID displayID)
{
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);
CHECK_DISPLAY_MAGIC(display, 0);
if (display->props == 0) {
display->props = SDL_CreateProperties();
}
return display->props;
}
const char *SDL_GetDisplayName(SDL_DisplayID displayID)
{
SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID);