diff --git a/src/wgl_context.c b/src/wgl_context.c index beccb13e..9a370b7e 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -256,12 +256,20 @@ static void makeContextCurrentWGL(_GLFWwindow* window) static void swapBuffersWGL(_GLFWwindow* window) { - // HACK: Use DwmFlush when desktop composition is enabled - if (_glfwIsCompositionEnabledWin32() && !window->monitor) + if (!window->monitor) { - int count = abs(window->context.wgl.interval); - while (count--) - DwmFlush(); + if (IsWindowsVistaOrGreater()) + { + BOOL enabled; + + // HACK: Use DwmFlush when desktop composition is enabled + if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled) + { + int count = abs(window->context.wgl.interval); + while (count--) + DwmFlush(); + } + } } SwapBuffers(window->context.wgl.dc); @@ -273,10 +281,18 @@ static void swapIntervalWGL(int interval) window->context.wgl.interval = interval; - // HACK: Disable WGL swap interval when desktop composition is enabled to - // avoid interfering with DWM vsync - if (_glfwIsCompositionEnabledWin32() && !window->monitor) - interval = 0; + if (!window->monitor) + { + if (IsWindowsVistaOrGreater()) + { + BOOL enabled; + + // HACK: Disable WGL swap interval when desktop composition is enabled to + // avoid interfering with DWM vsync + if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled) + interval = 0; + } + } if (_glfw.wgl.EXT_swap_control) _glfw.wgl.SwapIntervalEXT(interval); diff --git a/src/win32_platform.h b/src/win32_platform.h index 50b57441..68d4f8d2 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -396,7 +396,6 @@ typedef struct _GLFWmutexWin32 GLFWbool _glfwRegisterWindowClassWin32(void); void _glfwUnregisterWindowClassWin32(void); -GLFWbool _glfwIsCompositionEnabledWin32(void); WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source); char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source); diff --git a/src/win32_window.c b/src/win32_window.c index 570abc15..11fc0883 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -351,10 +351,12 @@ static void updateWindowStyles(const _GLFWwindow* window) // static void updateFramebufferTransparency(const _GLFWwindow* window) { + BOOL enabled; + if (!IsWindowsVistaOrGreater()) return; - if (_glfwIsCompositionEnabledWin32()) + if (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled) { HRGN region = CreateRectRgn(0, 0, -1, -1); DWM_BLURBEHIND bb = {0}; @@ -1221,20 +1223,6 @@ void _glfwUnregisterWindowClassWin32(void) UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL)); } -// Returns whether desktop compositing is enabled -// -GLFWbool _glfwIsCompositionEnabledWin32(void) -{ - if (IsWindowsVistaOrGreater()) - { - BOOL enabled; - if (SUCCEEDED(DwmIsCompositionEnabled(&enabled))) - return enabled; - } - - return FALSE; -} - ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// @@ -1632,7 +1620,15 @@ int _glfwPlatformWindowHovered(_GLFWwindow* window) int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) { - return window->win32.transparent && _glfwIsCompositionEnabledWin32(); + BOOL enabled; + + if (!window->win32.transparent) + return GLFW_FALSE; + + if (!IsWindowsVistaOrGreater()) + return GLFW_FALSE; + + return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; } void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)