diff options
-rw-r--r-- | ash/display/display_info.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/toolbar/wrench_menu_model.cc | 6 | ||||
-rw-r--r-- | ui/aura/remote_root_window_host_win.cc | 20 | ||||
-rw-r--r-- | ui/base/win/dpi_setup.cc | 11 | ||||
-rw-r--r-- | ui/gfx/screen_win.cc | 2 | ||||
-rw-r--r-- | win8/metro_driver/display_properties.cc | 2 | ||||
-rw-r--r-- | win8/metro_driver/display_properties.h | 11 | ||||
-rw-r--r-- | win8/metro_driver/metro_driver.gyp | 1 |
8 files changed, 47 insertions, 13 deletions
diff --git a/ash/display/display_info.cc b/ash/display/display_info.cc index 01c604f..4ee73c0 100644 --- a/ash/display/display_info.cc +++ b/ash/display/display_info.cc @@ -17,6 +17,7 @@ #if defined(OS_WIN) #include "ui/aura/window_tree_host.h" +#include "ui/gfx/win/dpi.h" #endif namespace ash { @@ -95,6 +96,12 @@ DisplayInfo DisplayInfo::CreateFromSpecWithID(const std::string& spec, sscanf(main_spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, &device_scale_factor) >= 4) { bounds_in_native.SetRect(x, y, width, height); + } else { +#if defined(OS_WIN) + if (gfx::IsHighDPIEnabled()) { + device_scale_factor = gfx::GetModernUIScale(); + } +#endif } std::vector<Resolution> resolutions; diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc index 65c6315..5c99a57 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model.cc +++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc @@ -65,7 +65,6 @@ #include "chrome/browser/enumerate_modules_model_win.h" #include "chrome/browser/ui/metro_pin_tab_helper_win.h" #include "content/public/browser/gpu_data_manager.h" -#include "ui/gfx/win/dpi.h" #include "win8/util/win8_util.h" #endif @@ -551,10 +550,7 @@ void WrenchMenuModel::Build(bool is_new_menu) { #if defined(USE_AURA) if (base::win::GetVersion() >= base::win::VERSION_WIN8 && - content::GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor() && - gfx::win::GetUndocumentedDPIScale() == 1.0f && - gfx::GetDPIScale() == 1.0 && - gfx::GetModernUIScale() == 1.0f) { + content::GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) { if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) { // Metro mode, add the 'Relaunch Chrome in desktop mode'. AddSeparator(ui::NORMAL_SEPARATOR); diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc index 7b99866..b8c14b7 100644 --- a/ui/aura/remote_root_window_host_win.cc +++ b/ui/aura/remote_root_window_host_win.cc @@ -24,6 +24,7 @@ #include "ui/events/keycodes/keyboard_code_conversion_win.h" #include "ui/base/view_prop.h" #include "ui/gfx/insets.h" +#include "ui/gfx/win/dpi.h" #include "ui/metro_viewer/metro_viewer_messages.h" namespace aura { @@ -483,18 +484,24 @@ void RemoteRootWindowHostWin::OnTextInputClientUpdated( input_scopes, character_bounds)); } +gfx::Point PointFromNativeEvent(int32 x, int32 y) { + static float scale_factor = gfx::GetModernUIScale(); + gfx::Point result( x * scale_factor, y * scale_factor); + return result; +} + void RemoteRootWindowHostWin::OnMouseMoved(int32 x, int32 y, int32 flags) { if (ignore_mouse_moves_until_set_cursor_ack_) return; - gfx::Point location(x, y); + gfx::Point location = PointFromNativeEvent(x, y); ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, flags, 0); delegate_->OnHostMouseEvent(&event); } void RemoteRootWindowHostWin::OnMouseButton( const MetroViewerHostMsg_MouseButtonParams& params) { - gfx::Point location(params.x, params.y); + gfx::Point location = PointFromNativeEvent(params.x, params.y); ui::MouseEvent mouse_event(params.event_type, location, location, static_cast<int>(params.flags), static_cast<int>(params.changed_button)); @@ -556,8 +563,9 @@ void RemoteRootWindowHostWin::OnTouchDown(int32 x, int32 y, uint64 timestamp, uint32 pointer_id) { + gfx::Point location = PointFromNativeEvent(x, y); ui::TouchEvent event(ui::ET_TOUCH_PRESSED, - gfx::Point(x, y), + location, pointer_id, base::TimeDelta::FromMicroseconds(timestamp)); delegate_->OnHostTouchEvent(&event); @@ -567,8 +575,9 @@ void RemoteRootWindowHostWin::OnTouchUp(int32 x, int32 y, uint64 timestamp, uint32 pointer_id) { + gfx::Point location = PointFromNativeEvent(x, y); ui::TouchEvent event(ui::ET_TOUCH_RELEASED, - gfx::Point(x, y), + location, pointer_id, base::TimeDelta::FromMicroseconds(timestamp)); delegate_->OnHostTouchEvent(&event); @@ -578,8 +587,9 @@ void RemoteRootWindowHostWin::OnTouchMoved(int32 x, int32 y, uint64 timestamp, uint32 pointer_id) { + gfx::Point location = PointFromNativeEvent(x, y); ui::TouchEvent event(ui::ET_TOUCH_MOVED, - gfx::Point(x, y), + location, pointer_id, base::TimeDelta::FromMicroseconds(timestamp)); delegate_->OnHostTouchEvent(&event); diff --git a/ui/base/win/dpi_setup.cc b/ui/base/win/dpi_setup.cc index ad4e6e8..39bf185 100644 --- a/ui/base/win/dpi_setup.cc +++ b/ui/base/win/dpi_setup.cc @@ -4,6 +4,7 @@ #include "ui/base/win/dpi_setup.h" +#include "base/command_line.h" #include "ui/base/layout.h" #include "ui/gfx/display.h" #include "ui/gfx/win/dpi.h" @@ -12,7 +13,15 @@ namespace ui { namespace win { void InitDeviceScaleFactor() { - gfx::InitDeviceScaleFactor(gfx::GetDPIScale()); + float scale = 1.0; + if (CommandLine::ForCurrentProcess()->HasSwitch("silent-launch")) { + if (gfx::IsHighDPIEnabled()) + scale = gfx::GetModernUIScale(); + } + else { + scale = gfx::GetDPIScale(); + } + gfx::InitDeviceScaleFactor(scale); } } // namespace win diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc index 7903cc5..5413c9f 100644 --- a/ui/gfx/screen_win.cc +++ b/ui/gfx/screen_win.cc @@ -129,7 +129,7 @@ gfx::Display ScreenWin::GetPrimaryDisplay() const { gfx::Display display = GetDisplay(mi); // TODO(kevers|girard): Test if these checks can be reintroduced for high-DIP // once more of the app is DIP-aware. - if (!IsInHighDPIMode()) { + if (!(IsInHighDPIMode() || IsHighDPIEnabled())) { DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); } diff --git a/win8/metro_driver/display_properties.cc b/win8/metro_driver/display_properties.cc index a7cf427..f1653fd 100644 --- a/win8/metro_driver/display_properties.cc +++ b/win8/metro_driver/display_properties.cc @@ -16,7 +16,7 @@ extern "C" { - __declspec(dllexport) float GetModernUIScale() { +__declspec(dllexport) float GetModernUIScale() { base::win::ScopedCOMInitializer com_init; Microsoft::WRL::ComPtr< ABI::Windows::Graphics::Display::IDisplayPropertiesStatics> diff --git a/win8/metro_driver/display_properties.h b/win8/metro_driver/display_properties.h new file mode 100644 index 0000000..1491b3f --- /dev/null +++ b/win8/metro_driver/display_properties.h @@ -0,0 +1,11 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_METRO_DRIVER_DISPLAY_PROPERTIES_H_ +#define CHROME_BROWSER_UI_METRO_DRIVER_DISPLAY_PROPERTIES_H_ + +// Determines the scale factor used in the modern/metro ui. 1.0 means unscaled. +extern "C" __declspec(dllexport) float GetModernUIScale(); + +#endif // CHROME_BROWSER_UI_METRO_DRIVER_DISPLAY_PROPERTIES_H_ diff --git a/win8/metro_driver/metro_driver.gyp b/win8/metro_driver/metro_driver.gyp index cc572d8..f0d1c76 100644 --- a/win8/metro_driver/metro_driver.gyp +++ b/win8/metro_driver/metro_driver.gyp @@ -65,6 +65,7 @@ ], 'sources': [ 'display_properties.cc', + 'display_properties.h', 'metro_driver.cc', 'metro_driver.h', 'stdafx.h', |