From 6652bf2353d807f724f398a15cb22c188830f57c Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sun, 17 Oct 2021 11:19:48 +0800 Subject: [PATCH] Bump WINVER, _WIN32_WINNT and _WIN32_IE to _WIN32_WINNT_WIN10 (0x0A00) And bump NTDDI_VERSION to 0x0A00000B (NTDDI_WIN10_CO) at the same time, to unblock the developers from accessing the latest Windows APIs. Pick-to: 6.2 Change-Id: Ifbc28c8f8b073866871685c020301f5f20dc9591 Reviewed-by: Qt CI Bot Reviewed-by: Joerg Bornemann Reviewed-by: Thiago Macieira --- cmake/QtBaseConfigureTests.cmake | 25 ++++++++++++++++ cmake/QtBuild.cmake | 2 +- mkspecs/features/qt_module.prf | 5 ++++ src/corelib/global/qt_windows.h | 29 +++++++------------ src/corelib/io/qfilesystemengine_win.cpp | 9 ------ .../platforms/windows/qwin10helpers.cpp | 2 +- .../windows/qwindowsdialoghelpers.cpp | 2 +- .../windows/qwindowspointerhandler.cpp | 7 ++--- .../windows/qwindowssystemtrayicon.cpp | 14 +++------ .../platforms/windows/qwindowstheme.cpp | 5 ++-- .../platforms/windows/qwindowswindow.cpp | 7 ++--- tests/auto/corelib/io/qdir/tst_qdir.cpp | 2 +- .../thread/qmutex/tst_bench_qmutex.cpp | 4 ++- 13 files changed, 58 insertions(+), 55 deletions(-) diff --git a/cmake/QtBaseConfigureTests.cmake b/cmake/QtBaseConfigureTests.cmake index 717ea1248ec..ae16e8e53be 100644 --- a/cmake/QtBaseConfigureTests.cmake +++ b/cmake/QtBaseConfigureTests.cmake @@ -138,9 +138,34 @@ VERS_1; set(TEST_ld_version_script "${HAVE_LD_VERSION_SCRIPT}" CACHE INTERNAL "linker version script support") endfunction() +function(qt_internal_ensure_latest_win_nt_api) + if(NOT WIN32) + return() + endif() + check_cxx_source_compiles([=[ + #include + #if !defined(_WIN32_WINNT) && !defined(WINVER) + #error "_WIN32_WINNT and WINVER are not defined" + #endif + #if defined(_WIN32_WINNT) && (_WIN32_WINNT < 0x0A00) + #error "_WIN32_WINNT version too low" + #endif + #if defined(WINVER) && (WINVER < 0x0A00) + #error "WINVER version too low" + #endif + int main() { return 0; } + ]=] HAVE_WIN10_WIN32_WINNT) + if(NOT HAVE_WIN10_WIN32_WINNT) + list(APPEND QT_PLATFORM_DEFINITIONS _WIN32_WINNT=0x0A00 WINVER=0x0A00) + set(QT_PLATFORM_DEFINITIONS ${QT_PLATFORM_DEFINITIONS} + CACHE STRING "Qt platform specific pre-processor defines" FORCE) + endif() +endfunction() + function(qt_run_qtbase_config_tests) qt_run_config_test_architecture() qt_run_linker_version_script_support() + qt_internal_ensure_latest_win_nt_api() endfunction() # The qmake build of android does not perform the right architecture tests and diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index b2cdd356679..a4d8c49ad11 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -310,7 +310,7 @@ if(WIN32) endif() if (MINGW) - list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS _WIN32_WINNT=0x0601 MINGW_HAS_SECURE_API=1) + list(APPEND QT_DEFAULT_PLATFORM_DEFINITIONS MINGW_HAS_SECURE_API=1) endif() elseif(LINUX) if(GCC) diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index 62d225b14d0..8bc1175ebb2 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -345,4 +345,9 @@ msvc { QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO += /GUARD:CF } +win32 { + DEFINES *= _WIN32_WINNT=0x0A00 + DEFINES *= WINVER=0x0A00 +} + TARGET = $$qt5LibraryTarget($$TARGET$$QT_LIBINFIX) # Do this towards the end diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h index 7ffe313f006..15255b94347 100644 --- a/src/corelib/global/qt_windows.h +++ b/src/corelib/global/qt_windows.h @@ -45,17 +45,17 @@ #pragma qt_sync_stop_processing #endif -#if defined(Q_CC_MINGW) -// mingw's windows.h does not set _WIN32_WINNT, resulting breaking compilation -# ifndef WINVER -# define WINVER 0x601 -# endif -# ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x601 -# endif -# ifndef NTDDI_VERSION -# define NTDDI_VERSION 0x06010000 -# endif +#ifndef WINVER +# define WINVER 0x0A00 // _WIN32_WINNT_WIN10 +#endif +#ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0A00 +#endif +#ifndef _WIN32_IE +# define _WIN32_IE 0x0A00 +#endif +#ifndef NTDDI_VERSION +# define NTDDI_VERSION 0x0A00000B // NTDDI_WIN10_CO #endif #ifndef NOMINMAX @@ -63,13 +63,6 @@ #endif #include -#if defined(_WIN32_IE) && _WIN32_IE < 0x0501 -# undef _WIN32_IE -#endif -#if !defined(_WIN32_IE) -# define _WIN32_IE 0x0501 -#endif - // already defined when compiled with WINVER >= 0x0500 #ifndef SPI_SETMENUANIMATION #define SPI_SETMENUANIMATION 0x1003 diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 9e009a05e7d..d2da2082fa3 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -627,15 +627,6 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath()); } -#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 // Windows 8 onwards - -typedef struct _FILE_ID_INFO { - ULONGLONG VolumeSerialNumber; - FILE_ID_128 FileId; -} FILE_ID_INFO, *PFILE_ID_INFO; - -#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 - // File ID for Windows up to version 7 and FAT32 drives static inline QByteArray fileId(HANDLE handle) { diff --git a/src/plugins/platforms/windows/qwin10helpers.cpp b/src/plugins/platforms/windows/qwin10helpers.cpp index 9a7fce9cd5c..b8e834d54f6 100644 --- a/src/plugins/platforms/windows/qwin10helpers.cpp +++ b/src/plugins/platforms/windows/qwin10helpers.cpp @@ -46,7 +46,7 @@ #if defined(Q_CC_MINGW) || defined(Q_CC_CLANG) # define HAS_UI_VIEW_SETTINGS_INTEROP // Present from MSVC2015 + SDK 10 onwards -#elif (!defined(Q_CC_MSVC) || _MSC_VER >= 1900) && NTDDI_VERSION >= 0xa000000 +#elif (!defined(Q_CC_MSVC) || _MSC_VER >= 1900) && WINVER >= 0x0A00 # define HAS_UI_VIEW_SETTINGS_INTEROP # define HAS_UI_VIEW_SETTINGS #endif diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 1ddde93f909..55241294188 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -40,7 +40,7 @@ #define QT_NO_URL_CAST_FROM_STRING 1 #ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0601 +#define _WIN32_WINNT 0x0A00 #endif #include "qwindowscombase.h" diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index 46fbfcc8d69..efe02139f13 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -37,11 +37,8 @@ ** ****************************************************************************/ -#if defined(WINVER) && WINVER < 0x0603 -# undef WINVER -#endif -#if !defined(WINVER) -# define WINVER 0x0603 // Enable pointer functions for MinGW +#ifndef WINVER +# define WINVER 0x0A00 // Enable pointer functions for MinGW #endif #include "qwindowspointerhandler.h" diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index 7c473e66b67..0a96d5a0f5b 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -37,18 +37,12 @@ ** ****************************************************************************/ -#if defined(WINVER) && WINVER < 0x0601 -# undef WINVER -#endif -#if !defined(WINVER) -# define WINVER 0x0601 // required for NOTIFYICONDATA_V2_SIZE, ChangeWindowMessageFilterEx() (MinGW 5.3) +#ifndef WINVER +# define WINVER 0x0A00 // required for NOTIFYICONDATA_V2_SIZE, ChangeWindowMessageFilterEx() (MinGW 5.3) #endif -#if defined(NTDDI_VERSION) && NTDDI_VERSION < 0x06010000 -# undef NTDDI_VERSION -#endif -#if !defined(NTDDI_VERSION) -# define NTDDI_VERSION 0x06010000 // required for Shell_NotifyIconGetRect (MinGW 5.3) +#ifndef NTDDI_VERSION +# define NTDDI_VERSION 0x0A00000B // required for Shell_NotifyIconGetRect (MinGW 5.3) #endif #include "qwindowssystemtrayicon.h" diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 6fbf4183da8..85b6c300861 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -38,9 +38,8 @@ ****************************************************************************/ // SHSTOCKICONINFO is only available since Vista -#if _WIN32_WINNT < 0x0601 -# undef _WIN32_WINNT -# define _WIN32_WINNT 0x0601 +#ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0A00 #endif #include "qwindowstheme.h" diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 92cf8c253e4..5988d1498de 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -37,11 +37,8 @@ ** ****************************************************************************/ -#if defined(WINVER) && WINVER < 0x0601 -# undef WINVER -#endif -#if !defined(WINVER) -# define WINVER 0x0601 // Enable touch functions for MinGW +#ifndef WINVER +# define WINVER 0x0A00 // Enable touch functions for MinGW #endif #include "qwindowswindow.h" diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 8b6b3900500..88ccd26611e 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -45,7 +45,7 @@ #endif #if defined(Q_OS_WIN) && !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x500 +#define _WIN32_WINNT 0x0A00 #endif #include "../../../../shared/filesystem.h" diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp index 987612b7b20..1091ef3251b 100644 --- a/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp +++ b/tests/benchmarks/corelib/thread/qmutex/tst_bench_qmutex.cpp @@ -76,7 +76,9 @@ void NativeMutexUnlock(NativeMutexType *mutex) } #endif #elif defined(Q_OS_WIN) -# define _WIN32_WINNT 0x0400 +# if !defined(_WIN32_WINNT) +# define _WIN32_WINNT 0x0A00 +# endif # include typedef CRITICAL_SECTION NativeMutexType; void NativeMutexInitialize(NativeMutexType *mutex)