SDL_GetDisplays() follows the SDL_GetStringRule

This commit is contained in:
Sam Lantinga
2024-07-18 16:44:56 -07:00
parent 01199469de
commit 9758e102bc
15 changed files with 32 additions and 51 deletions

View File

@@ -265,7 +265,7 @@ SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetDisplayForWindow,(SDL_Window *a),(a),return
SDL_DYNAPI_PROC(const char*,SDL_GetDisplayName,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetDisplayProperties,(SDL_DisplayID a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetDisplayUsableBounds,(SDL_DisplayID a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_DisplayID*,SDL_GetDisplays,(int *a),(a),return)
SDL_DYNAPI_PROC(const SDL_DisplayID*,SDL_GetDisplays,(int *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetError,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetEventFilter,(SDL_EventFilter *a, void **b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_GetFloatProperty,(SDL_PropertiesID a, const char *b, float c),(a,b,c),return)

View File

@@ -1192,7 +1192,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
}
if (state->verbose & VERBOSE_MODES) {
SDL_DisplayID *displays;
const SDL_DisplayID *displays;
SDL_Rect bounds, usablebounds;
const SDL_DisplayMode **modes;
const SDL_DisplayMode *mode;
@@ -1270,7 +1270,6 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_Log("DXGI Adapter Index: %d Output Index: %d", adapterIndex, outputIndex);
#endif
}
SDL_free(displays);
}
if (state->verbose & VERBOSE_RENDER) {
@@ -1287,11 +1286,10 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
state->displayID = SDL_GetPrimaryDisplay();
if (state->display_index > 0) {
SDL_DisplayID *displays = SDL_GetDisplays(&n);
const SDL_DisplayID *displays = SDL_GetDisplays(&n);
if (state->display_index < n) {
state->displayID = displays[state->display_index];
}
SDL_free(displays);
if (SDL_WINDOWPOS_ISUNDEFINED(state->window_x)) {
state->window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->displayID);
@@ -2021,7 +2019,7 @@ static void SDLTest_PasteScreenShot(void)
static void FullscreenTo(SDLTest_CommonState *state, int index, int windowId)
{
int num_displays;
SDL_DisplayID *displays;
const SDL_DisplayID *displays;
SDL_Window *window;
SDL_WindowFlags flags;
const SDL_DisplayMode *mode;
@@ -2062,7 +2060,6 @@ static void FullscreenTo(SDLTest_CommonState *state, int index, int windowId)
SDL_SetWindowFullscreen(window, SDL_TRUE);
}
}
SDL_free(displays);
}
int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event *event)
@@ -2158,7 +2155,7 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
if (window) {
int num_displays;
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
const SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
if (displays) {
SDL_DisplayID displayID = SDL_GetDisplayForWindow(window);
int current_index = -1;
@@ -2181,7 +2178,6 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
SDL_WINDOWPOS_CENTERED_DISPLAY(dest),
SDL_WINDOWPOS_CENTERED_DISPLAY(dest));
}
SDL_free(displays);
}
}
}

View File

@@ -699,7 +699,7 @@ static void SDL_UpdateDesktopBounds(void)
SDL_Rect rect;
SDL_zero(rect);
SDL_DisplayID *displays = SDL_GetDisplays(NULL);
const SDL_DisplayID *displays = SDL_GetDisplays(NULL);
if (displays) {
for (int i = 0; displays[i]; ++i) {
SDL_Rect bounds;
@@ -711,7 +711,6 @@ static void SDL_UpdateDesktopBounds(void)
}
}
}
SDL_free(displays);
}
SDL_copyp(&_this->desktop_bounds, &rect);
}
@@ -850,7 +849,7 @@ void SDL_DelVideoDisplay(SDL_DisplayID displayID, SDL_bool send_event)
SDL_UpdateDesktopBounds();
}
SDL_DisplayID *SDL_GetDisplays(int *count)
const SDL_DisplayID *SDL_GetDisplays(int *count)
{
int i;
SDL_DisplayID *displays;
@@ -879,7 +878,7 @@ SDL_DisplayID *SDL_GetDisplays(int *count)
*count = 0;
}
}
return displays;
return SDL_FreeLater(displays);
}
SDL_VideoDisplay *SDL_GetVideoDisplay(SDL_DisplayID displayID)

View File

@@ -315,14 +315,13 @@ static int KMSDRM_ShowCursor(SDL_Cursor *cursor)
This happens on video quit, where we get here after
the mouse focus has been unset, yet SDL wants to
restore the system default cursor (makes no sense here). */
SDL_DisplayID *displays = SDL_GetDisplays(NULL);
const SDL_DisplayID *displays = SDL_GetDisplays(NULL);
if (displays) {
/* Iterate on the displays, hiding the cursor. */
for (i = 0; i < displays[i]; i++) {
display = SDL_GetVideoDisplay(displays[i]);
ret = KMSDRM_RemoveCursorFromBO(display);
}
SDL_free(displays);
}
} else {
display = SDL_GetVideoDisplayForWindow(window);

View File

@@ -535,7 +535,7 @@ static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display,
/* Deinitializes the internal of the SDL Displays in the SDL display list. */
static void KMSDRM_DeinitDisplays(SDL_VideoDevice *_this)
{
SDL_DisplayID *displays;
const SDL_DisplayID *displays;
SDL_DisplayData *dispdata;
int i;
@@ -559,7 +559,6 @@ static void KMSDRM_DeinitDisplays(SDL_VideoDevice *_this)
dispdata->crtc = NULL;
}
}
SDL_free(displays);
}
}

View File

@@ -310,7 +310,7 @@ int UIKit_AddDisplay(SDL_bool send_event){
void UIKit_DelDisplay(UIScreen *uiscreen, SDL_bool send_event)
{
SDL_DisplayID *displays;
const SDL_DisplayID *displays;
int i;
displays = SDL_GetDisplays(NULL);
@@ -326,7 +326,6 @@ void UIKit_DelDisplay(UIScreen *uiscreen, SDL_bool send_event)
break;
}
}
SDL_free(displays);
}
}

View File

@@ -516,7 +516,7 @@ static void Wayland_move_window(SDL_Window *window)
{
SDL_WindowData *wind = window->internal;
SDL_DisplayData *display;
SDL_DisplayID *displays;
const SDL_DisplayID *displays;
if (wind->outputs && wind->num_outputs) {
display = wind->outputs[wind->num_outputs - 1];
@@ -559,7 +559,6 @@ static void Wayland_move_window(SDL_Window *window)
break;
}
}
SDL_free(displays);
}
}

View File

@@ -639,7 +639,7 @@ static int X11_AddXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int screen
static void X11_HandleXRandROutputChange(SDL_VideoDevice *_this, const XRROutputChangeNotifyEvent *ev)
{
SDL_DisplayID *displays;
const SDL_DisplayID *displays;
SDL_VideoDisplay *display = NULL;
int i;
@@ -657,7 +657,6 @@ static void X11_HandleXRandROutputChange(SDL_VideoDevice *_this, const XRROutput
break;
}
}
SDL_free(displays);
}
if (ev->connection == RR_Disconnected) { /* output is going away */

View File

@@ -416,7 +416,7 @@ static int X11_CaptureMouse(SDL_Window *window)
static SDL_MouseButtonFlags X11_GetGlobalMouseState(float *x, float *y)
{
SDL_VideoData *videodata = SDL_GetVideoDevice()->internal;
SDL_DisplayID *displays;
const SDL_DisplayID *displays;
Display *display = GetDisplay();
int i;
@@ -458,7 +458,6 @@ static SDL_MouseButtonFlags X11_GetGlobalMouseState(float *x, float *y)
}
}
}
SDL_free(displays);
}
}