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

Unified Diff: ui/views/widget/desktop_aura/desktop_screen_position_client.cc

Issue 12512014: Fix window positioning in high-DPI on Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix another merge conflict. Created 7 years, 8 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 | « ui/views/widget/desktop_aura/desktop_root_window_host_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_root_window_host_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698