From ac3349faafd80b2df91dcfb591b03506a9610e6e Mon Sep 17 00:00:00 2001
From: pionere <[EMAIL REDACTED]>
Date: Wed, 9 Nov 2022 09:11:04 +0100
Subject: [PATCH] solve FIXMEs in SDL_video.c
---
src/video/SDL_video.c | 65 +++++++++++++++++++++++--------------------
1 file changed, 35 insertions(+), 30 deletions(-)
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 321d6d0267ac..56b387de7524 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -694,29 +694,32 @@ SDL_GetDisplayName(int displayIndex)
int
SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect)
{
+ SDL_VideoDisplay *display;
+
CHECK_DISPLAY_INDEX(displayIndex, -1);
- if (rect) {
- SDL_VideoDisplay *display = &_this->displays[displayIndex];
+ if (!rect)
+ return SDL_InvalidParamError("rect");
- if (_this->GetDisplayBounds) {
- if (_this->GetDisplayBounds(_this, display, rect) == 0) {
- return 0;
- }
- }
+ display = &_this->displays[displayIndex];
- /* Assume that the displays are left to right */
- if (displayIndex == 0) {
- rect->x = 0;
- rect->y = 0;
- } else {
- SDL_GetDisplayBounds(displayIndex-1, rect);
- rect->x += rect->w;
+ if (_this->GetDisplayBounds) {
+ if (_this->GetDisplayBounds(_this, display, rect) == 0) {
+ return 0;
}
- rect->w = display->current_mode.w;
- rect->h = display->current_mode.h;
}
- return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
+
+ /* Assume that the displays are left to right */
+ if (displayIndex == 0) {
+ rect->x = 0;
+ rect->y = 0;
+ } else {
+ SDL_GetDisplayBounds(displayIndex-1, rect);
+ rect->x += rect->w;
+ }
+ rect->w = display->current_mode.w;
+ rect->h = display->current_mode.h;
+ return 0;
}
static int
@@ -729,25 +732,27 @@ ParseDisplayUsableBoundsHint(SDL_Rect *rect)
int
SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect)
{
+ SDL_VideoDisplay *display;
+
CHECK_DISPLAY_INDEX(displayIndex, -1);
- if (rect) {
- SDL_VideoDisplay *display = &_this->displays[displayIndex];
+ if (!rect)
+ return SDL_InvalidParamError("rect");
- if ((displayIndex == 0) && ParseDisplayUsableBoundsHint(rect)) {
- return 0;
- }
+ display = &_this->displays[displayIndex];
- if (_this->GetDisplayUsableBounds) {
- if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
- return 0;
- }
- }
+ if ((displayIndex == 0) && ParseDisplayUsableBoundsHint(rect)) {
+ return 0;
+ }
- /* Oh well, just give the entire display bounds. */
- return SDL_GetDisplayBounds(displayIndex, rect);
+ if (_this->GetDisplayUsableBounds) {
+ if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) {
+ return 0;
+ }
}
- return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */
+
+ /* Oh well, just give the entire display bounds. */
+ return SDL_GetDisplayBounds(displayIndex, rect);
}
int