src/video/SDL_video.c
changeset 7440 9817477202d1
parent 7439 f52afd324ec7
child 7441 468877c2135a
     1.1 --- a/src/video/SDL_video.c	Sat Jul 13 21:42:57 2013 -0400
     1.2 +++ b/src/video/SDL_video.c	Sat Jul 13 21:50:40 2013 -0400
     1.3 @@ -360,23 +360,20 @@
     1.4  static int
     1.5  cmpmodes(const void *A, const void *B)
     1.6  {
     1.7 -    SDL_DisplayMode a = *(const SDL_DisplayMode *) A;
     1.8 -    SDL_DisplayMode b = *(const SDL_DisplayMode *) B;
     1.9 -
    1.10 -    if (a.w != b.w) {
    1.11 -        return b.w - a.w;
    1.12 -    }
    1.13 -    if (a.h != b.h) {
    1.14 -        return b.h - a.h;
    1.15 -    }
    1.16 -    if (SDL_BITSPERPIXEL(a.format) != SDL_BITSPERPIXEL(b.format)) {
    1.17 -        return SDL_BITSPERPIXEL(b.format) - SDL_BITSPERPIXEL(a.format);
    1.18 -    }
    1.19 -    if (SDL_PIXELLAYOUT(a.format) != SDL_PIXELLAYOUT(b.format)) {
    1.20 -        return SDL_PIXELLAYOUT(b.format) - SDL_PIXELLAYOUT(a.format);
    1.21 -    }
    1.22 -    if (a.refresh_rate != b.refresh_rate) {
    1.23 -        return b.refresh_rate - a.refresh_rate;
    1.24 +    const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
    1.25 +    const SDL_DisplayMode *b = (const SDL_DisplayMode *) B;
    1.26 +    if (a == b) {
    1.27 +        return 0;
    1.28 +    } else if (a->w != b->w) {
    1.29 +        return b->w - a->w;
    1.30 +    } else if (a->h != b->h) {
    1.31 +        return b->h - a->h;
    1.32 +    } else if (SDL_BITSPERPIXEL(a->format) != SDL_BITSPERPIXEL(b->format)) {
    1.33 +        return SDL_BITSPERPIXEL(b->format) - SDL_BITSPERPIXEL(a->format);
    1.34 +    } else if (SDL_PIXELLAYOUT(a->format) != SDL_PIXELLAYOUT(b->format)) {
    1.35 +        return SDL_PIXELLAYOUT(b->format) - SDL_PIXELLAYOUT(a->format);
    1.36 +    } else if (a->refresh_rate != b->refresh_rate) {
    1.37 +        return b->refresh_rate - a->refresh_rate;
    1.38      }
    1.39      return 0;
    1.40  }