Commit a8d41b3b4587aca7d1f967fe8bb862a4b8ebccd0

Ozkan Sezer 2022-06-18T21:51:32

check for shellscalingapi.h presence instead of WINVER >= 0x0603

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a49a581..e56a5f5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1651,6 +1651,7 @@ elseif(WINDOWS)
   check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
   check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
   check_include_file(sensorsapi.h HAVE_SENSORSAPI_H)
+  check_include_file(shellscalingapi.h HAVE_SHELLSCALINGAPI_H)
 
   if(SDL_AUDIO)
     if(NOT WINDOWS_STORE)
diff --git a/configure b/configure
index b6f9b70..1c1ac2d 100755
--- a/configure
+++ b/configure
@@ -14084,11 +14084,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
 printf %s "checking for $CXX option to enable C++11 features... " >&6; }
-if test ${ac_cv_prog_cxx_11+y}
+if test ${ac_cv_prog_cxx_cxx11+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_11=no
+  ac_cv_prog_cxx_cxx11=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -14130,11 +14130,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
 printf %s "checking for $CXX option to enable C++98 features... " >&6; }
-if test ${ac_cv_prog_cxx_98+y}
+if test ${ac_cv_prog_cxx_cxx98+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_98=no
+  ac_cv_prog_cxx_cxx98=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -27104,6 +27104,17 @@ fi
 printf "%s\n" "#define HAVE_ROAPI_H 1" >>confdefs.h
 
     fi
+    ac_fn_c_check_header_compile "$LINENO" "shellscalingapi.h" "ac_cv_header_shellscalingapi_h" "$ac_includes_default"
+if test "x$ac_cv_header_shellscalingapi_h" = xyes
+then :
+  have_shellscalingapi_h=yes
+fi
+
+    if test x$shellscalingapi_h = xyes; then
+
+printf "%s\n" "#define HAVE_SHELLSCALINGAPI_H 1" >>confdefs.h
+
+    fi
 }
 
 CheckOS2()
diff --git a/configure.ac b/configure.ac
index ee8a41e..4420359 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3242,6 +3242,10 @@ CheckWINDOWS()
     if test x$have_roapi_h = xyes; then
         AC_DEFINE(HAVE_ROAPI_H, 1, [ ])
     fi
+    AC_CHECK_HEADER(shellscalingapi.h,have_shellscalingapi_h=yes)
+    if test x$shellscalingapi_h = xyes; then
+        AC_DEFINE(HAVE_SHELLSCALINGAPI_H, 1, [ ])
+    fi
 }
 
 dnl Determine whether the compiler can produce OS/2 executables
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 6f448c0..9cc18ab 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -256,6 +256,7 @@
 #cmakedefine HAVE_TPCSHRD_H @HAVE_TPCSHRD_H@
 #cmakedefine HAVE_SENSORSAPI_H @HAVE_SENSORSAPI_H@
 #cmakedefine HAVE_ROAPI_H @HAVE_ROAPI_H@
+#cmakedefine HAVE_SHELLSCALINGAPI_H @HAVE_SHELLSCALINGAPI_H@
 
 #cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@
 #cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index c758b45..7b6eb5d 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -246,6 +246,7 @@
 #undef HAVE_TPCSHRD_H
 #undef HAVE_SENSORSAPI_H
 #undef HAVE_ROAPI_H
+#undef HAVE_SHELLSCALINGAPI_H
 
 /* SDL internal assertion support */
 #undef SDL_DEFAULT_ASSERT_LEVEL
diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h
index 076bea4..3ad3e8f 100644
--- a/include/SDL_config_windows.h
+++ b/include/SDL_config_windows.h
@@ -122,6 +122,9 @@ typedef unsigned int uintptr_t;
 #if defined(WDK_NTDDI_VERSION) && WDK_NTDDI_VERSION > 0x0A000008 /* 10.0.19041.0 */
 #define HAVE_D3D12_H 1
 #endif
+#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0603  /* Windows 8.1 SDK */
+#define HAVE_SHELLSCALINGAPI_H 1
+#endif
 #define HAVE_MMDEVICEAPI_H 1
 #define HAVE_AUDIOCLIENT_H 1
 #define HAVE_TPCSHRD_H 1
diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h
index 50a4371..b477655 100644
--- a/src/video/windows/SDL_windowsvideo.h
+++ b/src/video/windows/SDL_windowsvideo.h
@@ -274,7 +274,7 @@ typedef struct DISPLAYCONFIG_TARGET_DEVICE_NAME
 
 #endif /* WINVER < 0x0601 */
 
-#if WINVER < 0x0603
+#ifndef HAVE_SHELLSCALINGAPI_H
 
 typedef enum MONITOR_DPI_TYPE {
     MDT_EFFECTIVE_DPI = 0,
@@ -291,7 +291,7 @@ typedef enum PROCESS_DPI_AWARENESS {
 
 #else
 #include <shellscalingapi.h>
-#endif /* WINVER < 0x0603 */
+#endif
 
 #ifndef _DPI_AWARENESS_CONTEXTS_