diff --git a/include/SDL3/SDL_video.h b/include/SDL3/SDL_video.h index 155adb537..3f7950255 100644 --- a/include/SDL3/SDL_video.h +++ b/include/SDL3/SDL_video.h @@ -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. * diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index 4d1999c23..651431e67 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -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: *; }; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 799e29f2f..08e9878ee 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -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 diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 048aba36f..6943830f1 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -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) diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index b318d75db..3db2d85b1 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -146,6 +146,8 @@ struct SDL_VideoDisplay SDL_VideoDevice *device; + SDL_PropertiesID props; + SDL_DisplayData *driverdata; }; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 3ef3cd98a..280260785 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -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);