src/SDL12_compat.c
changeset 89 5db689f27ecd
parent 88 60cb434b52b8
child 91 ecc70507b655
     1.1 --- a/src/SDL12_compat.c	Fri Mar 01 01:08:43 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Fri Mar 01 01:43:04 2019 -0500
     1.3 @@ -2638,6 +2638,12 @@
     1.4      VideoSurface12->pitch = VideoSurface12->surface20->pitch = width * SDL_BYTESPERPIXEL(appfmt);
     1.5      SDL_SetClipRect(VideoSurface12, NULL);
     1.6  
     1.7 +    if (flags12 & SDL12_FULLSCREEN) {
     1.8 +        VideoSurface12->flags |= SDL12_FULLSCREEN;
     1.9 +    } else {
    1.10 +        VideoSurface12->flags &= ~SDL12_FULLSCREEN;
    1.11 +    }
    1.12 +
    1.13      if (flags12 & SDL12_OPENGL) {
    1.14          SDL_assert(!VideoTexture20);  /* either a new window or we destroyed all this */
    1.15          SDL_assert(!VideoRenderer20);
    1.16 @@ -2940,8 +2946,29 @@
    1.17  DECLSPEC int SDLCALL
    1.18  SDL_WM_ToggleFullScreen(SDL12_Surface *surface)
    1.19  {
    1.20 -    FIXME("write me");
    1.21 -    return SDL20_Unsupported();
    1.22 +    int retval = 0;
    1.23 +    if (surface == VideoSurface12) {
    1.24 +        SDL_assert(VideoWindow20);
    1.25 +        const Uint32 flags20 = SDL20_GetWindowFlags(VideoWindow20);
    1.26 +        if (flags20 & SDL_WINDOW_FULLSCREEN) {
    1.27 +            SDL_assert(VideoSurface12->flags & SDL12_FULLSCREEN);
    1.28 +            retval = (SDL20_SetWindowFullscreen(VideoWindow20, 0) == 0);
    1.29 +            if (retval) {
    1.30 +                VideoSurface12->flags &= ~SDL12_FULLSCREEN;
    1.31 +            }
    1.32 +        } else {
    1.33 +            SDL_assert((VideoSurface12->flags & SDL12_FULLSCREEN) == 0);
    1.34 +            const Uint32 newflags20 = (VideoSurface12->flags & SDL12_OPENGL) ? SDL_WINDOW_FULLSCREEN : SDL_WINDOW_FULLSCREEN_DESKTOP;
    1.35 +            retval = (SDL20_SetWindowFullscreen(VideoWindow20, newflags20) == 0);
    1.36 +            if (retval) {
    1.37 +                VideoSurface12->flags |= SDL12_FULLSCREEN;
    1.38 +            }
    1.39 +        }
    1.40 +        if (retval && VideoRenderer20) {
    1.41 +            SDL20_RenderSetLogicalSize(VideoRenderer20, VideoSurface12->w, VideoSurface12->h);
    1.42 +        }
    1.43 +    }
    1.44 +    return retval;
    1.45  }
    1.46  
    1.47  typedef enum