From d66f27376e48abfaf25384074dc74f0829badc2e Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Mon, 30 Jan 2023 10:36:48 +0100
Subject: [PATCH] Prevent setting an error "invalid display" when the parameter
displayID hasn't been set.
---
src/video/SDL_video.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 96cc25d1b30a..31b0597c4001 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -394,7 +394,7 @@ static int SDLCALL cmpmodes(const void *A, const void *B)
return 0;
}
-static int SDL_UninitializedVideo()
+static int SDL_UninitializedVideo(void)
{
return SDL_SetError("Video subsystem has not been initialized");
}
@@ -558,7 +558,7 @@ int SDL_VideoInit(const char *driver_name)
return -1;
}
-const char *SDL_GetCurrentVideoDriver()
+const char *SDL_GetCurrentVideoDriver(void)
{
if (_this == NULL) {
SDL_UninitializedVideo();
@@ -577,7 +577,7 @@ SDL_bool SDL_IsVideoContextExternal(void)
return SDL_GetHintBoolean(SDL_HINT_VIDEO_EXTERNAL_CONTEXT, SDL_FALSE);
}
-SDL_bool SDL_OnVideoThread()
+SDL_bool SDL_OnVideoThread(void)
{
return (_this && SDL_ThreadID() == _this->thread) ? SDL_TRUE : SDL_FALSE;
}
@@ -1256,7 +1256,8 @@ SDL_DisplayID SDL_GetDisplayForWindowCoordinate(int coordinate)
if (SDL_WINDOWPOS_ISUNDEFINED(coordinate) ||
SDL_WINDOWPOS_ISCENTERED(coordinate)) {
displayID = (coordinate & 0xFFFF);
- if (SDL_GetDisplayIndex(displayID) < 0) {
+ /* 0 or invalid */
+ if (displayID == 0 || SDL_GetDisplayIndex(displayID) < 0) {
displayID = SDL_GetPrimaryDisplay();
}
}