Index: ui/views/widget/desktop_aura/desktop_screen_position_client.cc |
diff --git a/ui/views/widget/desktop_aura/desktop_screen_position_client.cc b/ui/views/widget/desktop_aura/desktop_screen_position_client.cc |
index 5b4dbc0fcc1572f370244d79ca6195a21ee8bd00..2c268b865051cd692a84924aab84254d47adfc23 100644 |
--- a/ui/views/widget/desktop_aura/desktop_screen_position_client.cc |
+++ b/ui/views/widget/desktop_aura/desktop_screen_position_client.cc |
@@ -5,8 +5,25 @@ |
#include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
#include "ui/aura/root_window.h" |
+#include "ui/gfx/display.h" |
+#include "ui/gfx/point_conversions.h" |
+#include "ui/gfx/screen.h" |
+ |
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
+namespace { |
+ |
+gfx::Point GetOrigin(const aura::RootWindow* root_window) { |
+ gfx::Point origin_in_pixels = root_window->GetHostOrigin(); |
+ aura::RootWindow* window = const_cast<aura::RootWindow*>(root_window); |
+ float scale = gfx::Screen::GetScreenFor(window)-> |
+ GetDisplayNearestWindow(window).device_scale_factor(); |
+ return gfx::ToFlooredPoint( |
+ gfx::ScalePoint(origin_in_pixels, 1 / scale)); |
+} |
+ |
+} // namespace |
+ |
namespace views { |
DesktopScreenPositionClient::DesktopScreenPositionClient() { |
@@ -19,14 +36,14 @@ void DesktopScreenPositionClient::ConvertPointToScreen( |
const aura::Window* window, gfx::Point* point) { |
const aura::RootWindow* root_window = window->GetRootWindow(); |
aura::Window::ConvertPointToTarget(window, root_window, point); |
- gfx::Point origin = root_window->GetHostOrigin(); |
+ gfx::Point origin = GetOrigin(root_window); |
point->Offset(origin.x(), origin.y()); |
} |
void DesktopScreenPositionClient::ConvertPointFromScreen( |
const aura::Window* window, gfx::Point* point) { |
const aura::RootWindow* root_window = window->GetRootWindow(); |
- gfx::Point origin = root_window->GetHostOrigin(); |
+ gfx::Point origin = GetOrigin(root_window); |
point->Offset(-origin.x(), -origin.y()); |
aura::Window::ConvertPointToTarget(root_window, window, point); |
} |
@@ -53,7 +70,7 @@ void DesktopScreenPositionClient::SetBounds( |
// The caller expects windows we consider "embedded" to be placed in the |
// screen coordinate system. So we need to offset the root window's |
// position (which is in screen coordinates) from these bounds. |
- gfx::Point host_origin = root->GetHostOrigin(); |
+ gfx::Point host_origin = GetOrigin(root); |
origin.Offset(-host_origin.x(), -host_origin.y()); |
window->SetBounds(gfx::Rect(origin, bounds.size())); |
return; |