Allow creation of window bigger than visible size
authorPatrice Mandin
Sun, 27 May 2007 08:54:38 +0000
changeset 2108a930c8e4d8b0
parent 2107 757dfb38f574
child 2109 51cbe188a49e
Allow creation of window bigger than visible size
src/video/gem/SDL_gemvideo.c
     1.1 --- a/src/video/gem/SDL_gemvideo.c	Sat May 26 20:10:49 2007 +0000
     1.2 +++ b/src/video/gem/SDL_gemvideo.c	Sun May 27 08:54:38 2007 +0000
     1.3 @@ -639,28 +639,25 @@
     1.4  GEM_SetVideoMode(_THIS, SDL_Surface * current,
     1.5                   int width, int height, int bpp, Uint32 flags)
     1.6  {
     1.7 -    int maxwidth, maxheight;
     1.8      Uint32 modeflags, screensize;
     1.9      SDL_bool use_shadow1, use_shadow2;
    1.10  
    1.11 -        /*--- Verify if asked mode can be used ---*/
    1.12 -    if (flags & SDL_FULLSCREEN) {
    1.13 -        maxwidth = VDI_w;
    1.14 -        maxheight = VDI_h;
    1.15 -    } else {
    1.16 -        /* Windowed mode */
    1.17 -        maxwidth = GEM_desk_w;
    1.18 -        maxheight = GEM_desk_h;
    1.19 -    }
    1.20 -
    1.21      /* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
    1.22      if ((width & 15) != 0) {
    1.23          width = (width | 15) + 1;
    1.24      }
    1.25  
    1.26 -    if ((maxwidth < width) || (maxheight < height) || (VDI_bpp != bpp)) {
    1.27 -        SDL_SetError("Couldn't find requested mode in list");
    1.28 -        return (NULL);
    1.29 +        /*--- Verify if asked mode can be used ---*/
    1.30 +    if (VDI_bpp != bpp) {
    1.31 +        SDL_SetError("%d bpp mode not supported", bpp);
    1.32 +        return(NULL);
    1.33 +    }
    1.34 +
    1.35 +    if (flags & SDL_FULLSCREEN) {
    1.36 +        if ((VDI_w < width) || (VDI_h < height)) {
    1.37 +            SDL_SetError("%dx%d mode is too large", width, height);
    1.38 +            return (NULL);
    1.39 +        }
    1.40      }
    1.41  
    1.42          /*--- Allocate the new pixel format for the screen ---*/
    1.43 @@ -775,8 +772,16 @@
    1.44              }
    1.45  
    1.46              /* Center window */
    1.47 -            x2 = GEM_desk_x + ((GEM_desk_w - w2) >> 1);
    1.48 -            y2 = GEM_desk_y + ((GEM_desk_h - h2) >> 1);
    1.49 +            x2 = (GEM_desk_w - w2) >> 1;
    1.50 +            y2 = (GEM_desk_h - h2) >> 1;
    1.51 +            if (x2<0) {
    1.52 +                x2 = 0;
    1.53 +            }
    1.54 +            if (y2<0) {
    1.55 +                y2 = 0;
    1.56 +            }
    1.57 +            x2 += GEM_desk_x;
    1.58 +            y2 += GEM_desk_y;
    1.59  
    1.60              /* Destroy existing window */
    1.61              if (GEM_handle >= 0) {