win: Enable high dpi support.
authorCheng Zhao <zcbenz@gmail.com>
Fri, 11 Jul 2014 12:58:00 +0000 (20:58 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 11 Jul 2014 12:58:39 +0000 (20:58 +0800)
atom/app/atom_main.cc

index 04cf78d..35ed4d4 100644 (file)
 #include <shellapi.h>
 
 #include "atom/app/atom_main_delegate.h"
-#include "base/environment.h"
 #include "atom/common/crash_reporter/win/crash_service_main.h"
+#include "base/environment.h"
+#include "base/win/registry.h"
 #include "content/public/app/startup_helper_win.h"
 #include "sandbox/win/src/sandbox_types.h"
+#include "ui/gfx/win/dpi.h"
 #elif defined(OS_LINUX)  // defined(OS_WIN)
 #include "atom/app/atom_main_delegate.h"  // NOLINT
 #include "content/public/app/content_main.h"
@@ -34,6 +36,13 @@ int Start(int argc, char *argv[]);
 
 #if defined(OS_WIN)
 
+namespace {
+
+const wchar_t kRegistryProfilePath[] = L"SOFTWARE\\Google\\Chrome\\Profile";
+const wchar_t kHighDPISupportW[] = L"high-dpi-support";
+
+}  // namespace
+
 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
   int argc = 0;
   wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
@@ -99,6 +108,13 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
   content::InitializeSandboxInfo(&sandbox_info);
   atom::AtomMainDelegate delegate;
 
+  // Now chrome relies on a regkey to enable high dpi support.
+  base::win::RegKey high_dpi_key(HKEY_CURRENT_USER);
+  high_dpi_key.CreateKey(kRegistryProfilePath, KEY_SET_VALUE);
+  high_dpi_key.WriteValue(kHighDPISupportW, 1);
+
+  gfx::EnableHighDPISupport();
+
   content::ContentMainParams params(&delegate);
   params.instance = instance;
   params.sandbox_info = &sandbox_info;