From 3b1debaa0d5341bdb954654503424fb12b529894 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 16 Nov 2020 15:28:10 +0300 Subject: Fix mouse lock/high-dpi --- src/core/Frontend.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/core/Frontend.cpp') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 4be23b77..ffcd8b30 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5529,8 +5529,15 @@ CMenuManager::SwitchMenuOnAndOff() gMusicPlaying = 0; } */ - if (m_bMenuActive != menuWasActive) + if (m_bMenuActive != menuWasActive) { m_bMenuStateChanged = true; + + // Keep mouse centered while in game. Done in main.cpp in other conditions. + // IMPROVED_VIDEOMODE because otherwise there is no way for windowed mode. +#if defined(RW_GL3) && defined(IMPROVED_VIDEOMODE) + glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, m_bMenuActive && m_nPrefsWindowed ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED); +#endif + } m_bStartUpFrontEndRequested = false; m_bShutDownFrontEndRequested = false; -- cgit v1.2.3 From f33ed2892a7a083d10c89b93b0122c6b4100a9a2 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 16 Nov 2020 15:49:00 +0300 Subject: Fix mouse lock/high-dpi 2 --- src/core/Frontend.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/core/Frontend.cpp') diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index ffcd8b30..b84b691d 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5433,6 +5433,10 @@ CMenuManager::SetHelperText(int text) void CMenuManager::ShutdownJustMenu() { + // In case we're windowed, keep mouse centered while in game. Done in main.cpp in other conditions. +#if defined(RW_GL3) && defined(IMPROVED_VIDEOMODE) + glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_DISABLED); +#endif m_bMenuActive = false; CTimer::EndUserPause(); } @@ -5532,8 +5536,7 @@ CMenuManager::SwitchMenuOnAndOff() if (m_bMenuActive != menuWasActive) { m_bMenuStateChanged = true; - // Keep mouse centered while in game. Done in main.cpp in other conditions. - // IMPROVED_VIDEOMODE because otherwise there is no way for windowed mode. + // In case we're windowed, keep mouse centered while in game. Done in main.cpp in other conditions. #if defined(RW_GL3) && defined(IMPROVED_VIDEOMODE) glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, m_bMenuActive && m_nPrefsWindowed ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED); #endif -- cgit v1.2.3