gl_vidsdl.c (VID_Toggle): New proc for easy windowed-fullscreen toggling

using SDL. Works only under X11.
keys.c (Key_Event): Moved ALT-Enter windowed-fulscreen toggle handling to
main() in main.c so that it works properly for now.
main.c (main): Moved ALT-Enter windowed-fulscreen toggle handling from
keys.c to main() so that it works properly for now.


git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@14 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2010-02-16 09:10:43 +00:00
parent 454f953008
commit dc8da67934
3 changed files with 31 additions and 11 deletions

View file

@ -1413,6 +1413,27 @@ void VID_Init (void)
// is removed, we get 800x600.
}
// new proc by S.A., called by alt-return key binding.
void VID_Toggle (void)
{
// VID_Restart ();
S_ClearBuffer ();
if ( SDL_WM_ToggleFullScreen(draw_context) == 1 )
{
Sbar_Changed(); // Sbar seems to need refreshing
windowed=!windowed;
if ((int)vid_fullscreen.value == 0)
Cvar_Set ("vid_fullscreen", "1");
else
Cvar_Set ("vid_fullscreen", "0");
} else {
Con_Printf ("SDL_WM_ToggleFullScreen failed\n");
}
}
/*
================
VID_SyncCvars -- johnfitz -- set vid cvars to match current video mode

View file

@ -1023,17 +1023,10 @@ void Key_Event (int key, qboolean down)
}
// johnfitz -- alt-enter to toggle fullscreen. FIXME -- this does NOT work
#if 0
if (!down && (key == K_ENTER) && keydown[K_ALT])
{
extern cvar_t vid_fullscreen;
if (vid_fullscreen.value)
Cvar_Set ("vid_fullscreen", "0");
else
Cvar_Set ("vid_fullscreen", "1");
VID_Restart ();
}
#endif
// But this hack (from sf.net/uhexen2) for SDLFitz works for me. S.A
// *** moved to main.c so that it works properly ***
// if (!down && (key == K_ENTER) && keydown[K_ALT])
// VID_Toggle();
// johnfitz
//

View file

@ -117,6 +117,12 @@ int main(int argc, char *argv[])
if (event.key.type == SDL_KEYDOWN)
Con_ToggleConsole_f();
}
else if ((event.key.keysym.sym == SDLK_RETURN) &&
(event.key.keysym.mod & KMOD_ALT))
{
if (event.key.type == SDL_KEYDOWN)
VID_Toggle();
}
else
{
Key_Event(Key_Map(&(event.key)), event.key.type == SDL_KEYDOWN);