Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add parameter checking to SetWindowSize functions; add tests to video…

… suite
  • Loading branch information
ferzkopp committed Mar 9, 2013
1 parent 0c3a589 commit 0d506d87b17805265534c06d4b3acb1ad04336a6
Showing with 545 additions and 148 deletions.
  1. +22 −1 include/SDL_video.h
  2. +34 −43 src/video/SDL_video.c
  3. +489 −104 test/testautomation_video.c
@@ -504,6 +504,9 @@ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
/**
* \brief Get the position of a window.
*
* \param x Pointer to variable for storing the x position, may be NULL
* \param y Pointer to variable for storing the y position, may be NULL
*
* \sa SDL_SetWindowPosition()
*/
extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
@@ -512,6 +515,9 @@ extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
/**
* \brief Set the size of a window's client area.
*
* \param w The width of the window, must be >0
* \param h The height of the window, must be >0
*
* \note You can't change the size of a fullscreen window, it automatically
* matches the size of the display mode.
*
@@ -523,13 +529,19 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
/**
* \brief Get the size of a window's client area.
*
* \param w Pointer to variable for storing the width, may be NULL
* \param h Pointer to variable for storing the height, may be NULL
*
* \sa SDL_SetWindowSize()
*/
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
int *h);

/**
* \brief Set the minimum size of a window's client area.
*
* \param min_w The minimum width of the window, must be >0
* \param min_h The minimum height of the window, must be >0
*
* \note You can't change the minimum size of a fullscreen window, it
* automatically matches the size of the display mode.
@@ -542,7 +554,10 @@ extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,

/**
* \brief Get the minimum size of a window's client area.
*
*
* \param w Pointer to variable for storing the minimum width, may be NULL
* \param h Pointer to variable for storing the minimum height, may be NULL
*
* \sa SDL_GetWindowMaximumSize()
* \sa SDL_SetWindowMinimumSize()
*/
@@ -552,6 +567,9 @@ extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window,
/**
* \brief Set the maximum size of a window's client area.
*
* \param max_w The maximum width of the window, must be >0
* \param max_h The maximum height of the window, must be >0
*
* \note You can't change the maximum size of a fullscreen window, it
* automatically matches the size of the display mode.
*
@@ -563,6 +581,9 @@ extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window,

/**
* \brief Get the maximum size of a window's client area.
*
* \param w Pointer to variable for storing the maximum width, may be NULL
* \param h Pointer to variable for storing the maximum height, may be NULL
*
* \sa SDL_GetWindowMinimumSize()
* \sa SDL_SetWindowMaximumSize()
@@ -1566,6 +1566,14 @@ void
SDL_SetWindowSize(SDL_Window * window, int w, int h)
{
CHECK_WINDOW_MAGIC(window, );
if (w <= 0) {
SDL_InvalidParamError("w");
return;
}
if (h <= 0) {
SDL_InvalidParamError("h");
return;
}

/* FIXME: Should this change fullscreen modes? */
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
@@ -1584,30 +1592,27 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
void
SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
{
int dummy;

if (!w) {
w = &dummy;
}
if (!h) {
h = &dummy;
}

*w = 0;
*h = 0;

CHECK_WINDOW_MAGIC(window, );

if (_this && window && window->magic == &_this->window_magic) {
if (w) {
*w = window->w;
*h = window->h;
}
if (h) {
*h = window->h;
}
}

void
SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
{
CHECK_WINDOW_MAGIC(window, );
if (min_w <= 0) {
SDL_InvalidParamError("min_w");
return;
}
if (min_h <= 0) {
SDL_InvalidParamError("min_h");
return;
}

if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
window->min_w = min_w;
@@ -1623,22 +1628,11 @@ SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
void
SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
{
int dummy;

if (!min_w) {
min_w = &dummy;
}
if (!min_h) {
min_h = &dummy;
}

*min_w = 0;
*min_h = 0;

CHECK_WINDOW_MAGIC(window, );

if (_this && window && window->magic == &_this->window_magic) {
if (min_w) {
*min_w = window->min_w;
}
if (min_h) {
*min_h = window->min_h;
}
}
@@ -1647,6 +1641,14 @@ void
SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
{
CHECK_WINDOW_MAGIC(window, );
if (max_w <= 0) {
SDL_InvalidParamError("max_w");
return;
}
if (max_h <= 0) {
SDL_InvalidParamError("max_h");
return;
}

if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
window->max_w = max_w;
@@ -1662,22 +1664,11 @@ SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
void
SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
{
int dummy;

if (!max_w) {
max_w = &dummy;
}
if (!max_h) {
max_h = &dummy;
}

*max_w = 0;
*max_h = 0;

CHECK_WINDOW_MAGIC(window, );

if (_this && window && window->magic == &_this->window_magic) {
if (max_w) {
*max_w = window->max_w;
}
if (max_h) {
*max_h = window->max_h;
}
}

0 comments on commit 0d506d8

Please sign in to comment.