19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/*
29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    SDL - Simple DirectMedia Layer
39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Copyright (C) 1997-2012 Sam Lantinga
49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Copyright (C) 2001  Hsieh-Fu Tsai
59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is free software; you can redistribute it and/or
79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    modify it under the terms of the GNU Library General Public
89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License as published by the Free Software Foundation; either
99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    version 2 of the License, or (at your option) any later version.
109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    This library is distributed in the hope that it will be useful,
129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    but WITHOUT ANY WARRANTY; without even the implied warranty of
139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Library General Public License for more details.
159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    You should have received a copy of the GNU Library General Public
179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    License along with this library; if not, write to the Free
189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Sam Lantinga
219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    slouken@libsdl.org
229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    Hsieh-Fu Tsai
249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    clare@setabox.com
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h"
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_stdinc.h"
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_nxmodes_c.h"
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallSDL_Rect ** NX_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags)
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (flags & SDL_FULLSCREEN)
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        return SDL_modelist ;
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (SDL_Visual.bpp == format -> BitsPerPixel) {
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        return ((SDL_Rect **) -1) ;
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    } else {
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        return ((SDL_Rect **) 0) ;
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid NX_FreeVideoModes (_THIS)
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    int i ;
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (SDL_modelist) {
489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        for (i = 0; SDL_modelist [i]; ++ i) {
499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall            SDL_free (SDL_modelist [i]) ;
509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        }
519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        SDL_free (SDL_modelist) ;
529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        SDL_modelist = NULL;
539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint NX_EnterFullScreen (_THIS)
579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (! currently_fullscreen) {
599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GR_SCREEN_INFO si ;
609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrGetScreenInfo (& si) ;
629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrResizeWindow (FSwindow, si.cols, si.rows) ;
639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrUnmapWindow (SDL_Window) ;
649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrMapWindow (FSwindow) ;
659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrRaiseWindow (FSwindow) ;
669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrSetFocus (FSwindow) ;
679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        currently_fullscreen = 1 ;
689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    return 1 ;
719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint NX_LeaveFullScreen (_THIS)
749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    if (currently_fullscreen) {
769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrUnmapWindow (FSwindow) ;
779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrMapWindow (SDL_Window) ;
789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrRaiseWindow (SDL_Window) ;
799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        GrSetFocus (SDL_Window) ;
809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall        currently_fullscreen = 0 ;
819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    }
829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall    return 0 ;
849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
85