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

Side by Side Diff: ui/wm/core/default_screen_position_client.cc

Issue 1426933002: Refactor Windows DPI Point, Rect, and Size for Multiple Monitor DPI Awareness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Other Unit Tests - Moved Inner Classes Outside Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/wm/core/default_screen_position_client.h" 5 #include "ui/wm/core/default_screen_position_client.h"
6 6
7 #include "ui/aura/window_tree_host.h" 7 #include "ui/aura/window_tree_host.h"
8 #include "ui/gfx/display.h" 8 #include "ui/gfx/display.h"
9 #include "ui/gfx/geometry/point_conversions.h" 9 #include "ui/gfx/geometry/point_conversions.h"
10 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/screen.h" 11 #include "ui/gfx/screen.h"
11 12
12 namespace wm { 13 namespace wm {
13 14
14 DefaultScreenPositionClient::DefaultScreenPositionClient() { 15 DefaultScreenPositionClient::DefaultScreenPositionClient() {
15 } 16 }
16 17
17 DefaultScreenPositionClient::~DefaultScreenPositionClient() { 18 DefaultScreenPositionClient::~DefaultScreenPositionClient() {
18 } 19 }
19 20
20 gfx::Point DefaultScreenPositionClient::GetOriginInScreen( 21 gfx::Point DefaultScreenPositionClient::GetOriginInScreen(
21 const aura::Window* root_window) { 22 const aura::Window* root_window) {
22 gfx::Point origin_in_pixels = root_window->GetHost()->GetBounds().origin();
23 aura::Window* window = const_cast<aura::Window*>(root_window); 23 aura::Window* window = const_cast<aura::Window*>(root_window);
24 float scale = gfx::Screen::GetScreenFor(window)-> 24 gfx::Screen* screen = gfx::Screen::GetScreenFor(window);
25 GetDisplayNearestWindow(window).device_scale_factor(); 25 gfx::Rect screen_bounds = root_window->GetHost()->GetBounds();
26 return gfx::ScaleToFlooredPoint(origin_in_pixels, 1.0f / scale); 26 gfx::Rect dip_bounds = screen->ScreenToDIPRectInWindow(window, screen_bounds);
oshima 2016/01/21 17:47:44 is this screen_bounds in native screen coordinates
robliao 2016/01/21 18:19:20 We really need that units refactor. GetOriginInSc
27 return dip_bounds.origin();
27 } 28 }
28 29
29 void DefaultScreenPositionClient::ConvertPointToScreen( 30 void DefaultScreenPositionClient::ConvertPointToScreen(
30 const aura::Window* window, 31 const aura::Window* window,
31 gfx::Point* point) { 32 gfx::Point* point) {
32 const aura::Window* root_window = window->GetRootWindow(); 33 const aura::Window* root_window = window->GetRootWindow();
33 aura::Window::ConvertPointToTarget(window, root_window, point); 34 aura::Window::ConvertPointToTarget(window, root_window, point);
34 gfx::Point origin = GetOriginInScreen(root_window); 35 gfx::Point origin = GetOriginInScreen(root_window);
35 point->Offset(origin.x(), origin.y()); 36 point->Offset(origin.x(), origin.y());
36 } 37 }
(...skipping 13 matching lines...) Expand all
50 ConvertPointToScreen(root_window, point); 51 ConvertPointToScreen(root_window, point);
51 } 52 }
52 53
53 void DefaultScreenPositionClient::SetBounds(aura::Window* window, 54 void DefaultScreenPositionClient::SetBounds(aura::Window* window,
54 const gfx::Rect& bounds, 55 const gfx::Rect& bounds,
55 const gfx::Display& display) { 56 const gfx::Display& display) {
56 window->SetBounds(bounds); 57 window->SetBounds(bounds);
57 } 58 }
58 59
59 } // namespace wm 60 } // namespace wm
OLDNEW
« ui/gfx/display.h ('K') | « ui/views/win/hwnd_message_handler_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698