src/video/SDL_video.c
changeset 6984 ae9c4b12f3e2
parent 6956 afdc35fa58e9
child 7009 161b7b6a5303
     1.1 --- a/src/video/SDL_video.c	Fri Mar 08 23:04:53 2013 -0800
     1.2 +++ b/src/video/SDL_video.c	Fri Mar 08 23:33:07 2013 -0800
     1.3 @@ -1566,6 +1566,14 @@
     1.4  SDL_SetWindowSize(SDL_Window * window, int w, int h)
     1.5  {
     1.6      CHECK_WINDOW_MAGIC(window, );
     1.7 +    if (w <= 0) {
     1.8 +        SDL_InvalidParamError("w");
     1.9 +        return;
    1.10 +    }
    1.11 +    if (h <= 0) {
    1.12 +        SDL_InvalidParamError("h");
    1.13 +        return;
    1.14 +    }
    1.15  
    1.16      /* FIXME: Should this change fullscreen modes? */
    1.17      if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
    1.18 @@ -1584,30 +1592,27 @@
    1.19  void
    1.20  SDL_GetWindowSize(SDL_Window * window, int *w, int *h)
    1.21  {
    1.22 -    int dummy;
    1.23 -
    1.24 -    if (!w) {
    1.25 -        w = &dummy;
    1.26 +    CHECK_WINDOW_MAGIC(window, );
    1.27 +    if (w) {
    1.28 +        *w = window->w;
    1.29      }
    1.30 -    if (!h) {
    1.31 -        h = &dummy;
    1.32 -    }
    1.33 -
    1.34 -    *w = 0;
    1.35 -    *h = 0;
    1.36 -
    1.37 -    CHECK_WINDOW_MAGIC(window, );
    1.38 -
    1.39 -    if (_this && window && window->magic == &_this->window_magic) {
    1.40 -        *w = window->w;
    1.41 +    if (h) {
    1.42          *h = window->h;
    1.43 -    }
    1.44 +    }                                
    1.45  }
    1.46  
    1.47  void
    1.48  SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
    1.49  {
    1.50      CHECK_WINDOW_MAGIC(window, );
    1.51 +    if (min_w <= 0) {
    1.52 +        SDL_InvalidParamError("min_w");
    1.53 +        return;
    1.54 +    }
    1.55 +    if (min_h <= 0) {
    1.56 +        SDL_InvalidParamError("min_h");
    1.57 +        return;
    1.58 +    }
    1.59      
    1.60      if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
    1.61          window->min_w = min_w;
    1.62 @@ -1623,22 +1628,11 @@
    1.63  void
    1.64  SDL_GetWindowMinimumSize(SDL_Window * window, int *min_w, int *min_h)
    1.65  {
    1.66 -    int dummy;
    1.67 -    
    1.68 -    if (!min_w) {
    1.69 -        min_w = &dummy;
    1.70 +    CHECK_WINDOW_MAGIC(window, );
    1.71 +    if (min_w) {
    1.72 +        *min_w = window->min_w;
    1.73      }
    1.74 -    if (!min_h) {
    1.75 -        min_h = &dummy;
    1.76 -    }
    1.77 -    
    1.78 -    *min_w = 0;
    1.79 -    *min_h = 0;
    1.80 -    
    1.81 -    CHECK_WINDOW_MAGIC(window, );
    1.82 -    
    1.83 -    if (_this && window && window->magic == &_this->window_magic) {
    1.84 -        *min_w = window->min_w;
    1.85 +    if (min_h) {
    1.86          *min_h = window->min_h;
    1.87      }
    1.88  }
    1.89 @@ -1647,6 +1641,14 @@
    1.90  SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
    1.91  {
    1.92      CHECK_WINDOW_MAGIC(window, );
    1.93 +    if (max_w <= 0) {
    1.94 +        SDL_InvalidParamError("max_w");
    1.95 +        return;
    1.96 +    }
    1.97 +    if (max_h <= 0) {
    1.98 +        SDL_InvalidParamError("max_h");
    1.99 +        return;
   1.100 +    }
   1.101      
   1.102      if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
   1.103          window->max_w = max_w;
   1.104 @@ -1662,22 +1664,11 @@
   1.105  void
   1.106  SDL_GetWindowMaximumSize(SDL_Window * window, int *max_w, int *max_h)
   1.107  {
   1.108 -    int dummy;
   1.109 -    
   1.110 -    if (!max_w) {
   1.111 -        max_w = &dummy;
   1.112 +    CHECK_WINDOW_MAGIC(window, );
   1.113 +    if (max_w) {
   1.114 +        *max_w = window->max_w;
   1.115      }
   1.116 -    if (!max_h) {
   1.117 -        max_h = &dummy;
   1.118 -    }
   1.119 -    
   1.120 -    *max_w = 0;
   1.121 -    *max_h = 0;
   1.122 -    
   1.123 -    CHECK_WINDOW_MAGIC(window, );
   1.124 -    
   1.125 -    if (_this && window && window->magic == &_this->window_magic) {
   1.126 -        *max_w = window->max_w;
   1.127 +    if (max_h) {
   1.128          *max_h = window->max_h;
   1.129      }
   1.130  }