From 4a85b177944f621e2bec2937f725682c64af66d6 Mon Sep 17 00:00:00 2001 From: titiger Date: Sun, 6 Nov 2016 22:00:51 +0100 Subject: [PATCH] fiddling around with #138 --- .../shared_lib/include/platform/sdl/window.h | 2 +- .../sources/platform/sdl/window.cpp | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/source/shared_lib/include/platform/sdl/window.h b/source/shared_lib/include/platform/sdl/window.h index 9b71a88a5..1c73626a7 100644 --- a/source/shared_lib/include/platform/sdl/window.h +++ b/source/shared_lib/include/platform/sdl/window.h @@ -108,7 +108,7 @@ private: static bool tryVSynch; static int64 lastToggle; - static void setLastToggle(int64 lastMouseEvent) {Window::lastToggle = lastToggle;} + static void setLastToggle(int64 lastToggle) {Window::lastToggle = lastToggle;} static int64 getLastToggle() {return Window::lastToggle;} static void setLastMouseEvent(int64 lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;} diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 1064392ef..cdf57e0c8 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -48,7 +48,7 @@ MouseState Window::mouseState; bool Window::isKeyPressedDown = false; bool Window::isFullScreen = false; SDL_keysym Window::keystate; -int64 Window::lastToggle = -5000; +int64 Window::lastToggle = -1000; bool Window::isActive = false; #ifdef WIN32 @@ -145,7 +145,7 @@ Window::Window() { Window::isActive = true; lastMouseEvent = 0; - lastToggle = -5000; + lastToggle = -1000; mousePos = Vec2i(0); mouseState.clear(); @@ -175,7 +175,7 @@ Window::Window(SDL_Window *sdlWindow) { Window::isActive = true; lastMouseEvent = 0; - lastToggle = -5000; + lastToggle = -1000; mousePos = Vec2i(0); mouseState.clear(); @@ -370,7 +370,7 @@ bool Window::handleEvent() { && (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] SDLK_RETURN pressed.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - if(Chrono::getCurMillis()-getLastToggle()>5000){ + if(Chrono::getCurMillis()-getLastToggle()>1000){ toggleFullscreen(); setLastToggle(Chrono::getCurMillis()); } @@ -422,10 +422,12 @@ bool Window::handleEvent() { if(global_window) { global_window->eventKeyUp(event.key); } - string keyName = SDL_GetKeyName(event.key.keysym.sym); - if( (keyName == "Return" || keyName == "Enter")){ - setLastToggle(-5000); - } + + // here is the problem, we have with too many key up events: +// string keyName = SDL_GetKeyName(event.key.keysym.sym); +// if( (keyName == "Return" || keyName == "Enter")){ +// setLastToggle(-1000); +// } if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYUP ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); @@ -436,7 +438,7 @@ bool Window::handleEvent() { codeLocation = "k"; // if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.active.state,event.active.gain); // -// if(SystemFlags::VERBreturnOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state); +// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state); // // // Check if the program has lost window focus // if ((event.active.state & (SDL_APPACTIVE | SDL_APPINPUTFOCUS))) {