Allow passing 0 to SDL_SetWindowMinimumSize() and SDL_SetWindowMaximumSize() to indicate no limit
parent
d95b04feaf
commit
422517c036
|
@ -1009,8 +1009,8 @@ extern DECLSPEC int SDLCALL SDL_GetWindowSizeInPixels(SDL_Window *window, int *w
|
|||
* Set the minimum size of a window's client area, in screen coordinates.
|
||||
*
|
||||
* \param window the window to change
|
||||
* \param min_w the minimum width of the window
|
||||
* \param min_h the minimum height of the window
|
||||
* \param min_w the minimum width of the window, or 0 for no limit
|
||||
* \param min_h the minimum height of the window, or 0 for no limit
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
|
@ -1043,8 +1043,8 @@ extern DECLSPEC int SDLCALL SDL_GetWindowMinimumSize(SDL_Window *window, int *w,
|
|||
* Set the maximum size of a window's client area, in screen coordinates.
|
||||
*
|
||||
* \param window the window to change
|
||||
* \param max_w the maximum width of the window
|
||||
* \param max_h the maximum height of the window
|
||||
* \param max_w the maximum width of the window, or 0 for no limit
|
||||
* \param max_h the maximum height of the window, or 0 for no limit
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
|
|
|
@ -2611,10 +2611,10 @@ int SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h)
|
|||
int SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
if (min_w <= 0) {
|
||||
if (min_w < 0) {
|
||||
return SDL_InvalidParamError("min_w");
|
||||
}
|
||||
if (min_h <= 0) {
|
||||
if (min_h < 0) {
|
||||
return SDL_InvalidParamError("min_h");
|
||||
}
|
||||
|
||||
|
@ -2627,11 +2627,16 @@ int SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h)
|
|||
window->min_h = min_h;
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||
int w, h;
|
||||
|
||||
if (_this->SetWindowMinimumSize) {
|
||||
_this->SetWindowMinimumSize(_this, window);
|
||||
}
|
||||
|
||||
/* Ensure that window is not smaller than minimal size */
|
||||
return SDL_SetWindowSize(window, SDL_max(window->w, window->min_w), SDL_max(window->h, window->min_h));
|
||||
w = window->min_w ? SDL_max(window->w, window->min_w) : window->w;
|
||||
h = window->min_h ? SDL_max(window->h, window->min_h) : window->h;
|
||||
return SDL_SetWindowSize(window, w, h);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -2651,10 +2656,10 @@ int SDL_GetWindowMinimumSize(SDL_Window *window, int *min_w, int *min_h)
|
|||
int SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
if (max_w <= 0) {
|
||||
if (max_w < 0) {
|
||||
return SDL_InvalidParamError("max_w");
|
||||
}
|
||||
if (max_h <= 0) {
|
||||
if (max_h < 0) {
|
||||
return SDL_InvalidParamError("max_h");
|
||||
}
|
||||
|
||||
|
@ -2666,11 +2671,16 @@ int SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h)
|
|||
window->max_h = max_h;
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||
int w, h;
|
||||
|
||||
if (_this->SetWindowMaximumSize) {
|
||||
_this->SetWindowMaximumSize(_this, window);
|
||||
}
|
||||
|
||||
/* Ensure that window is not larger than maximal size */
|
||||
return SDL_SetWindowSize(window, SDL_min(window->w, window->max_w), SDL_min(window->h, window->max_h));
|
||||
w = window->max_w ? SDL_min(window->w, window->max_w) : window->w;
|
||||
h = window->max_h ? SDL_min(window->h, window->max_h) : window->h;
|
||||
return SDL_SetWindowSize(window, w, h);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1141,7 +1141,7 @@ static int video_getSetWindowMinimumSize(void *arg)
|
|||
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||
for (desiredH = -2; desiredH < 2; desiredH++) {
|
||||
for (desiredW = -2; desiredW < 2; desiredW++) {
|
||||
if (desiredW <= 0 || desiredH <= 0) {
|
||||
if (desiredW < 0 || desiredH < 0) {
|
||||
SDL_SetWindowMinimumSize(window, desiredW, desiredH);
|
||||
SDLTest_AssertPass("Call to SDL_SetWindowMinimumSize(...,%d,%d)", desiredW, desiredH);
|
||||
checkInvalidParameterError();
|
||||
|
@ -1279,7 +1279,7 @@ static int video_getSetWindowMaximumSize(void *arg)
|
|||
SDLTest_AssertPass("Call to SDL_ClearError()");
|
||||
for (desiredH = -2; desiredH < 2; desiredH++) {
|
||||
for (desiredW = -2; desiredW < 2; desiredW++) {
|
||||
if (desiredW <= 0 || desiredH <= 0) {
|
||||
if (desiredW < 0 || desiredH < 0) {
|
||||
SDL_SetWindowMaximumSize(window, desiredW, desiredH);
|
||||
SDLTest_AssertPass("Call to SDL_SetWindowMaximumSize(...,%d,%d)", desiredW, desiredH);
|
||||
checkInvalidParameterError();
|
||||
|
|
Loading…
Reference in New Issue