From f82a8f09ebc6e51a63e08bf63287a4789d8cc3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 2 Aug 2018 00:01:26 +0200 Subject: [PATCH] Win32: Disable mouse trails for full screen When mouse trails are enabled, the cursor becomes invisible when the OpenGL ICD detects a full screen window and switches to page flipping. Mouse trails are now disabled as long as any full screen windows are visible. Fixes #1263. --- src/win32_platform.h | 4 ++++ src/win32_window.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/win32_platform.h b/src/win32_platform.h index 59815146..50b57441 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -142,6 +142,9 @@ typedef enum // HACK: Define versionhelpers.h functions manually as MinGW lacks the header BOOL IsWindowsVersionOrGreater(WORD major, WORD minor, WORD sp); +#define IsWindowsXPOrGreater() \ + IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), \ + LOBYTE(_WIN32_WINNT_WINXP), 0) #define IsWindowsVistaOrGreater() \ IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), \ LOBYTE(_WIN32_WINNT_VISTA), 0) @@ -300,6 +303,7 @@ typedef struct _GLFWlibraryWin32 _GLFWwindow* disabledCursorWindow; RAWINPUT* rawInput; int rawInputSize; + UINT mouseTrailSize; struct { HINSTANCE instance; diff --git a/src/win32_window.c b/src/win32_window.c index d467f2ae..a689bdfe 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -529,7 +529,18 @@ static void fitToMonitor(_GLFWwindow* window) static void acquireMonitor(_GLFWwindow* window) { if (!_glfw.win32.acquiredMonitorCount) + { SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED); + + // HACK: When mouse trails are enabled the cursor becomes invisible when + // the OpenGL ICD switches to page flipping + if (IsWindowsXPOrGreater()) + { + SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0); + SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0); + } + } + if (!window->monitor->window) _glfw.win32.acquiredMonitorCount++; @@ -546,8 +557,14 @@ static void releaseMonitor(_GLFWwindow* window) _glfw.win32.acquiredMonitorCount--; if (!_glfw.win32.acquiredMonitorCount) + { SetThreadExecutionState(ES_CONTINUOUS); + // HACK: Restore mouse trail length saved in acquireMonitor + if (IsWindowsXPOrGreater()) + SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0); + } + _glfwInputMonitorWindow(window->monitor, NULL); _glfwRestoreVideoModeWin32(window->monitor); }