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..535034570671140b154e32fcc1c4b56fff8aa5d7 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,31 @@ 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; |
| + 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) { |
| + using GetProcessDpiAwarenessPtr = |
| + HRESULT (WINAPI *) (HANDLE, PROCESS_DPI_AWARENESS*); |
| + GetProcessDpiAwarenessPtr process_dpi_awareness_func = |
| + reinterpret_cast<GetProcessDpiAwarenessPtr>( |
| + ::GetProcAddress(shcore_dll, "GetProcessDpiAwareness")); |
|
scottmg
2016/06/27 17:55:04
How about
auto get_process_dpi_awareness = reinte
robliao
2016/06/27 18:39:29
This is much nicer. Done!
|
| + if (process_dpi_awareness_func) { |
| + PROCESS_DPI_AWARENESS awareness; |
| + if (SUCCEEDED(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 |