Chromium Code Reviews| Index: base/win/win_util.cc |
| diff --git a/base/win/win_util.cc b/base/win/win_util.cc |
| index ce59baa287d4e9820ea4428492c27834d5e37b05..a757907378bd54fc4448d64d86ffb2bda4f8f05f 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,29 @@ void DisableFlicks(HWND hwnd) { |
| TABLET_DISABLE_FLICKFALLBACKKEYS)); |
| } |
| +bool IsProcessPerMonitorDpiAware() { |
| + static enum class PerMonitorDpiAware { |
| + UNKNOWN = 0, |
| + PER_MONITOR_DPI_UNAWARE, |
| + PER_MONITOR_DPI_AWARE, |
| + } per_monitor_dpi_aware = PerMonitorDpiAware::UNKNOWN; |
|
oshima
2016/06/27 18:58:52
nit: new line would make it easier to read.
robliao
2016/06/27 19:07:31
sgtm. Done.
|
| + 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 |