Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2892)

Unified Diff: base/win/win_util.cc

Issue 2098993002: Prepare ScreenWin To Use Per-Monitor DPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clang Build Fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/win/win_util.h ('k') | ui/display/win/dpi.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « base/win/win_util.h ('k') | ui/display/win/dpi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698