Skip to content

Commit 3fe63a3

Browse files
committed
dispserv_win32: define _WIN32_WINNT before including Windows headers
Fixes "Set Display-Reported Refresh Rate" reporting 0.000 Hz on Windows nightly builds (compiled with MinGW/GCC 10.2.0) while working correctly on builds compiled with newer toolchains (MinGW/GCC 15.2.0). win32_display_server_get_refresh_rate() guards its QueryDisplayConfig implementation with `#if _WIN32_WINNT >= 0x0601`, falling back to `return 0.0f` otherwise. The file already attempted to define _WIN32_WINNT to 0x0601 when undefined, but the fallback #define was placed *after* <objbase.h>, <initguid.h>, <windows.h>, <ntverp.h> and <shlobj.h>, by which point the SDK headers had already locked in the toolchain's default value. Older mingw-w64 runtimes default to a value below 0x0601 when the build system does not specify one, so the function was compiled to unconditionally return 0.0f. Newer mingw-w64 runtimes default to 0x0A00, which is why the issue did not reproduce locally. Move the _WIN32_WINNT (and _WIN32_WINDOWS) fallback defines to the top of the translation unit, before any Windows headers are included, so the version gate is honored regardless of toolchain.
1 parent 7c7bf59 commit 3fe63a3

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

gfx/display_servers/dispserv_win32.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717

1818
#define WIN32_LEAN_AND_MEAN
1919

20+
/* Must be defined BEFORE any Windows headers are pulled in, otherwise
21+
* the SDK locks in the toolchain default (which on older mingw-w64
22+
* runtimes is below 0x0601), and the QueryDisplayConfig code path in
23+
* win32_display_server_get_refresh_rate() gets compiled out, returning
24+
* a hardcoded 0.0f. */
25+
#ifndef _WIN32_WINDOWS
26+
#define _WIN32_WINDOWS 0x0601
27+
#endif
28+
2029
/* VC6 needs objbase included before initguid, but nothing else does */
2130
#include <objbase.h>
2231
#include <initguid.h>

0 commit comments

Comments
 (0)