Mouse pointer works a bit better

SDL2 showed native and MG mouse pointer at the same time. Attempt to fix it.
This commit is contained in:
titiger 2015-10-07 02:14:07 +02:00
parent d80ca9e0b2
commit 8991507526
5 changed files with 9 additions and 22 deletions

View File

@ -4996,8 +4996,6 @@ int glestMain(int argc, char** argv) {
mainWindow= new MainWindow(program);
mainWindow->setUseDefaultCursorOnly(config.getBool("No2DMouseRendering","false"));
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
GameSettings startupGameSettings;
@ -5247,7 +5245,6 @@ int glestMain(int argc, char** argv) {
}
showCursor(true);
mainWindow->setUseDefaultCursorOnly(true);
const Metrics &metrics= Metrics::getInstance();
renderer.clearBuffers();

View File

@ -203,12 +203,13 @@ Program::Program() {
void Program::initNormal(WindowGl *window){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
Config &config = Config::getInstance();
init(window);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
setState(new Intro(this));
showCursor(config.getBool("No2DMouseRendering","false"));
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
@ -603,7 +604,6 @@ void Program::setState(ProgramState *programStateNew, bool cleanupOldState) {
this->programStateOldSystemError = this->programState;
bool msgBoxEnabled = msgBox.getEnabled();
bool showingOSCursor = isCursorShowing();
if(dynamic_cast<Game *>(programStateNew) != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -666,16 +666,11 @@ void Program::setState(ProgramState *programStateNew, bool cleanupOldState) {
updateCameraTimer.reset();
fpsTimer.reset();
if(showingOSCursor == false) {
Config &config = Config::getInstance();
if(config.getBool("No2DMouseRendering","false") == false) {
showCursor(false);
}
sleep(0);
if(dynamic_cast<Intro *>(programStateNew) != NULL && msgBoxEnabled == true) {
showCursor(true);
}
Config &config = Config::getInstance();
if(dynamic_cast<Intro *>(programStateNew) != NULL && msgBoxEnabled == true) {
showCursor(true);
} else {
showCursor(config.getBool("No2DMouseRendering","false"));
}
this->programStateOldSystemError = NULL;

View File

@ -124,7 +124,6 @@ private:
protected:
//int w, h;
static bool isActive;
static bool no2DMouseRendering;
static bool allowAltEnterFullscreenToggle;
static int lastShowMouseState;
@ -187,9 +186,6 @@ public:
void destroy();
void minimize();
static void setUseDefaultCursorOnly(bool value) { no2DMouseRendering = value; }
static bool getUseDefaultCursorOnly() { return no2DMouseRendering; }
static void setAllowAltEnterFullscreenToggle(bool value) { allowAltEnterFullscreenToggle = value; }
static bool getAllowAltEnterFullscreenToggle() { return allowAltEnterFullscreenToggle; }

View File

@ -1685,7 +1685,7 @@ void showCursor(bool b) {
if(isCursorShowing() == b) {
return;
}
//printf("showCursor(bool b) b=%d\n",b);
SDL_ShowCursor(b == true ? SDL_ENABLE : SDL_DISABLE);
}

View File

@ -50,7 +50,6 @@ bool Window::isFullScreen = false;
SDL_keysym Window::keystate;
bool Window::isActive = false;
bool Window::no2DMouseRendering = false;
#ifdef WIN32
bool Window::allowAltEnterFullscreenToggle = false;
#else
@ -428,7 +427,7 @@ bool Window::handleEvent() {
// bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
// showCursor(willShowCursor);
// }
showCursor(true);
showCursor(false);
}
break;
}