diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 8dcb15c97b..e14ed8e9c9 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -62,6 +62,7 @@ namespace MainWindow static HMENU menu; static HINSTANCE hInst; + static int cursorCounter = 0; //W32Util::LayeredWindow *layer; #define MAX_LOADSTRING 100 @@ -177,6 +178,19 @@ namespace MainWindow ResizeDisplay(); } + void CorrectCursor() { + if (g_bFullScreen && globalUIState == UISTATE_INGAME) { + while (cursorCounter >= 0) { + cursorCounter = ShowCursor(FALSE); + } + } else { + if (cursorCounter < 0) { + cursorCounter = ShowCursor(TRUE); + SetCursor(LoadCursor(NULL, IDC_ARROW)); + } + } + } + void setTexScalingLevel(int num) { g_Config.iTexScalingLevel = num; if(gpu) gpu->ClearCacheNextFrame(); @@ -393,12 +407,7 @@ namespace MainWindow case WM_TIMER: // Hack: Take the opportunity to also show/hide the mouse cursor in fullscreen mode. - if (g_bFullScreen && globalUIState == UISTATE_INGAME) { - ShowCursor(FALSE); - } else { - ShowCursor(TRUE); - SetCursor(LoadCursor(NULL, IDC_ARROW)); - } + CorrectCursor(); SetTimer(hWnd, TIMER_CURSORUPDATE, CURSORUPDATE_INTERVAL_MS, 0); return 0; @@ -1472,9 +1481,6 @@ namespace MainWindow void _ViewNormal(HWND hWnd) { - ShowCursor(TRUE); - SetCursor(LoadCursor(NULL, IDC_ARROW)); - // put caption and border styles back DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE); DWORD dwNewStyle = dwOldStyle | WS_CAPTION | WS_THICKFRAME; @@ -1493,14 +1499,12 @@ namespace MainWindow // reset full screen indicator g_bFullScreen = FALSE; + CorrectCursor(); ResizeDisplay(); } void _ViewFullScreen(HWND hWnd) { - if (globalUIState == UISTATE_INGAME) - ShowCursor(FALSE); - // keep in mind normal window rectangle ::GetWindowRect(hWnd, &g_normalRC); @@ -1522,6 +1526,7 @@ namespace MainWindow // set full screen indicator g_bFullScreen = TRUE; + CorrectCursor(); ResizeDisplay(); }