diff --git a/internal/glfw/wgl_context_windows.go b/internal/glfw/wgl_context_windows.go index cff168e75..305755f97 100644 --- a/internal/glfw/wgl_context_windows.go +++ b/internal/glfw/wgl_context_windows.go @@ -261,18 +261,23 @@ func makeContextCurrentWGL(window *Window) error { } func swapBuffersWGL(window *Window) error { - if window.monitor == nil { - // HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7 - if !winver.IsWindows8OrGreater() && winver.IsWindowsVistaOrGreater() { - enabled, err := _DwmIsCompositionEnabled() + if window.monitor == nil && winver.IsWindowsVistaOrGreater() { + // DWM Composition is always enabled on Win8+ + enabled := winver.IsWindows8OrGreater() + + if !enabled { + var err error + enabled, err = _DwmIsCompositionEnabled() if err != nil { return err } - if enabled { - for i := 0; i < window.context.platform.interval; i++ { - // Ignore an error from DWM functions as they might not be implemented e.g. on Proton (#2113). - _ = _DwmFlush() - } + } + + // HACK: Use DwmFlush when desktop composition is enabled + if enabled { + for i := 0; i < window.context.platform.interval; i++ { + // Ignore an error from DWM functions as they might not be implemented e.g. on Proton (#2113). + _ = _DwmFlush() } } } @@ -292,19 +297,23 @@ func swapIntervalWGL(interval int) error { window.context.platform.interval = interval - if window.monitor == nil { - // HACK: Disable WGL swap interval when desktop composition is enabled on Windows - // Vista and 7 to avoid interfering with DWM vsync - if !winver.IsWindows8OrGreater() && winver.IsWindowsVistaOrGreater() { - enabled, err := _DwmIsCompositionEnabled() + if window.monitor == nil && winver.IsWindowsVistaOrGreater() { + // DWM Composition is always enabled on Win8+ + enabled := winver.IsWindows8OrGreater() + + if !enabled { + e, err := _DwmIsCompositionEnabled() // Ignore an error from DWM functions as they might not be implemented e.g. on Proton (#2113). if err == nil { - enabled = false - } - if enabled { - interval = 0 + enabled = e } } + + // HACK: Disable WGL swap interval when desktop composition is enabled to + // avoid interfering with DWM vsync + if enabled { + interval = 0 + } } if _glfw.platformContext.EXT_swap_control {