- added support for alt-enter window toggling in windows OS (by default it is tuned off)

to enable set AllowAltEnterFullscreenToggle=true
This commit is contained in:
Mark Vejvoda
2010-06-30 19:27:07 +00:00
parent 217c92e939
commit 0e94ee5476
3 changed files with 77 additions and 73 deletions

View File

@@ -227,8 +227,10 @@ void MainWindow::eventKeyDown(char key){
// This stupidity only required in win32. // This stupidity only required in win32.
// We reload the textures so that // We reload the textures so that
#ifdef WIN32 #ifdef WIN32
//Renderer &renderer= Renderer::getInstance(); if(Window::getAllowAltEnterFullscreenToggle() == true) {
//renderer.reinitAll(); Renderer &renderer= Renderer::getInstance();
renderer.reinitAll();
}
#endif #endif
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -395,6 +397,8 @@ int glestMain(int argc, char** argv){
if(config.getBool("No2DMouseRendering","false") == false) { if(config.getBool("No2DMouseRendering","false") == false) {
showCursor(false); showCursor(false);
} }
bool allowAltEnterFullscreenToggle = config.getBool("AllowAltEnterFullscreenToggle",boolToStr(Window::getAllowAltEnterFullscreenToggle()).c_str());
Window::setAllowAltEnterFullscreenToggle(allowAltEnterFullscreenToggle);
if(config.getBool("noTeamColors","false") == true) { if(config.getBool("noTeamColors","false") == true) {
MeshCallbackTeamColor::noTeamColors = true; MeshCallbackTeamColor::noTeamColors = true;

View File

@@ -133,6 +133,7 @@ protected:
int w, h; int w, h;
static bool isActive; static bool isActive;
static bool no2DMouseRendering; static bool no2DMouseRendering;
static bool allowAltEnterFullscreenToggle;
public: public:
static bool handleEvent(); static bool handleEvent();
@@ -174,6 +175,9 @@ public:
static void setUseDefaultCursorOnly(bool value) { no2DMouseRendering = value; } static void setUseDefaultCursorOnly(bool value) { no2DMouseRendering = value; }
static bool getUseDefaultCursorOnly() { return no2DMouseRendering; } static bool getUseDefaultCursorOnly() { return no2DMouseRendering; }
static void setAllowAltEnterFullscreenToggle(bool value) { allowAltEnterFullscreenToggle = value; }
static bool getAllowAltEnterFullscreenToggle() { return allowAltEnterFullscreenToggle; }
protected: protected:
virtual void eventCreate(){} virtual void eventCreate(){}
virtual void eventMouseDown(int x, int y, MouseButton mouseButton){} virtual void eventMouseDown(int x, int y, MouseButton mouseButton){}

View File

@@ -50,6 +50,11 @@ SDL_keysym Window::keystate;
bool Window::isActive = false; bool Window::isActive = false;
bool Window::no2DMouseRendering = false; bool Window::no2DMouseRendering = false;
#ifdef WIN32
bool Window::allowAltEnterFullscreenToggle = false;
#else
bool Window::allowAltEnterFullscreenToggle = true;
#endif
// ========== PUBLIC ========== // ========== PUBLIC ==========
@@ -352,21 +357,13 @@ void Window::toggleFullscreen() {
width and height of the current video mode (or the desktop mode, if no mode has been set). width and height of the current video mode (or the desktop mode, if no mode has been set).
Use 0 for Height, Width, and Color Depth to keep the current values. */ Use 0 for Height, Width, and Color Depth to keep the current values. */
/*
//setupGraphicsScreen();
//SDL_Surface *surface = SDL_GetVideoSurface();
//int flags = surface->flags ^ SDL_FULLSCREEN;
//int flags = SDL_OPENGL;
//if(Window::isFullScreen) {
// flags |= SDL_FULLSCREEN;
//}
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
//SDL_SetVideoMode(0, 0, 0, flags); if(Window::allowAltEnterFullscreenToggle == true) {
SDL_Surface *cur_surface = SDL_GetVideoSurface();
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(cur_surface != NULL) {
Window::isFullScreen = !((cur_surface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN);
}
SDL_Surface *sf = SDL_GetVideoSurface(); SDL_Surface *sf = SDL_GetVideoSurface();
SDL_Surface **surface = &sf; SDL_Surface **surface = &sf;
@@ -416,10 +413,9 @@ void Window::toggleFullscreen() {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
SDL_SetClipRect(*surface, &clip); SDL_SetClipRect(*surface, &clip);
*/ }
else {
HWND handle = GetSDLWindow(); HWND handle = GetSDLWindow();
if(Window::isFullScreen == true) { if(Window::isFullScreen == true) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle);
ShowWindow(handle, SW_MAXIMIZE); ShowWindow(handle, SW_MAXIMIZE);
@@ -432,12 +428,12 @@ void Window::toggleFullscreen() {
ShowWindow(handle, SW_RESTORE); ShowWindow(handle, SW_RESTORE);
//showCursor(true); //showCursor(true);
} }
}
//SDL_Surface *sf = SDL_GetVideoSurface();
//SDL_SetVideoMode(0, 0, 0, sf->flags ^SDL_FULLSCREEN);
#else #else
if(Window::allowAltEnterFullscreenToggle == true) {
SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()); SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
}
#endif #endif
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);