Index: base/win/win_util.cc |
diff --git a/base/win/win_util.cc b/base/win/win_util.cc |
index ce59baa287d4e9820ea4428492c27834d5e37b05..3b7d3195ac6c0b2622ef39c263cf2479d6c4606f 100644 |
--- a/base/win/win_util.cc |
+++ b/base/win/win_util.cc |
@@ -16,6 +16,7 @@ |
#include <roapi.h> |
#include <sddl.h> |
#include <setupapi.h> |
+#include <shellscalingapi.h> |
#include <shlwapi.h> |
#include <signal.h> |
#include <stddef.h> |
@@ -597,5 +598,30 @@ void DisableFlicks(HWND hwnd) { |
TABLET_DISABLE_FLICKFALLBACKKEYS)); |
} |
+bool IsProcessPerMonitorDpiAware() { |
+ enum class PerMonitorDpiAware { |
+ UNKNOWN = 0, |
+ PER_MONITOR_DPI_UNAWARE, |
+ PER_MONITOR_DPI_AWARE, |
+ }; |
+ static PerMonitorDpiAware per_monitor_dpi_aware = PerMonitorDpiAware::UNKNOWN; |
+ if (per_monitor_dpi_aware == PerMonitorDpiAware::UNKNOWN) { |
+ per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_UNAWARE; |
+ HMODULE shcore_dll = ::LoadLibrary(L"shcore.dll"); |
+ if (shcore_dll) { |
+ auto get_process_dpi_awareness_func = |
+ reinterpret_cast<decltype(::GetProcessDpiAwareness)*>( |
+ ::GetProcAddress(shcore_dll, "GetProcessDpiAwareness")); |
+ if (get_process_dpi_awareness_func) { |
+ PROCESS_DPI_AWARENESS awareness; |
+ if (SUCCEEDED(get_process_dpi_awareness_func(nullptr, &awareness)) && |
+ awareness == PROCESS_PER_MONITOR_DPI_AWARE) |
+ per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; |
+ } |
+ } |
+ } |
+ return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; |
+} |
+ |
} // namespace win |
} // namespace base |