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

Side by Side Diff: ash/display/screen_position_controller.cc

Issue 2648583003: Handle floating point coordinates from ozone to exosphere (Closed)
Patch Set: added F variant to screen position client. fixed exo tests. Created 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/display/screen_position_controller.h" 5 #include "ash/display/screen_position_controller.h"
6 6
7 #include "ash/common/wm/window_positioning_utils.h" 7 #include "ash/common/wm/window_positioning_utils.h"
8 #include "ash/common/wm/window_state.h" 8 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
10 #include "ash/common/wm_window.h" 10 #include "ash/common/wm_window.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 } 69 }
70 } 70 }
71 #endif 71 #endif
72 *target_root = root_window; 72 *target_root = root_window;
73 *point = point_in_root; 73 *point = point_in_root;
74 } 74 }
75 75
76 void ScreenPositionController::ConvertPointToScreen(const aura::Window* window, 76 void ScreenPositionController::ConvertPointToScreen(const aura::Window* window,
77 gfx::Point* point) { 77 gfx::Point* point) {
78 gfx::PointF point_f(*point);
79 ConvertPointToScreenF(window, &point_f);
80 *point = gfx::ToFlooredPoint(point_f);
81 }
82
83 void ScreenPositionController::ConvertPointToScreenF(const aura::Window* window,
84 gfx::PointF* point) {
78 const aura::Window* root = window->GetRootWindow(); 85 const aura::Window* root = window->GetRootWindow();
79 aura::Window::ConvertPointToTarget(window, root, point); 86 aura::Window::ConvertPointToTargetF(window, root, point);
80 const gfx::Point display_origin = 87 const gfx::Point display_origin =
81 display::Screen::GetScreen() 88 display::Screen::GetScreen()
82 ->GetDisplayNearestWindow(const_cast<aura::Window*>(root)) 89 ->GetDisplayNearestWindow(const_cast<aura::Window*>(root))
83 .bounds() 90 .bounds()
84 .origin(); 91 .origin();
85 point->Offset(display_origin.x(), display_origin.y()); 92 point->Offset(display_origin.x(), display_origin.y());
86 } 93 }
87 94
88 void ScreenPositionController::ConvertPointFromScreen( 95 void ScreenPositionController::ConvertPointFromScreen(
89 const aura::Window* window, 96 const aura::Window* window,
90 gfx::Point* point) { 97 gfx::Point* point) {
98 gfx::PointF point_f(*point);
99 ConvertPointFromScreenF(window, &point_f);
100 *point = gfx::ToFlooredPoint(point_f);
101 }
102
103 void ScreenPositionController::ConvertPointFromScreenF(
104 const aura::Window* window,
105 gfx::PointF* point) {
91 const aura::Window* root = window->GetRootWindow(); 106 const aura::Window* root = window->GetRootWindow();
92 const gfx::Point display_origin = 107 const gfx::Point display_origin =
93 display::Screen::GetScreen() 108 display::Screen::GetScreen()
94 ->GetDisplayNearestWindow(const_cast<aura::Window*>(root)) 109 ->GetDisplayNearestWindow(const_cast<aura::Window*>(root))
95 .bounds() 110 .bounds()
96 .origin(); 111 .origin();
97 point->Offset(-display_origin.x(), -display_origin.y()); 112 point->Offset(-display_origin.x(), -display_origin.y());
98 aura::Window::ConvertPointToTarget(root, window, point); 113 aura::Window::ConvertPointToTargetF(root, window, point);
99 } 114 }
100 115
101 void ScreenPositionController::ConvertHostPointToScreen( 116 void ScreenPositionController::ConvertHostPointToScreen(
102 aura::Window* root_window, 117 aura::Window* root_window,
103 gfx::Point* point) { 118 gfx::Point* point) {
104 aura::Window* root = root_window->GetRootWindow(); 119 aura::Window* root = root_window->GetRootWindow();
105 aura::Window* target_root = nullptr; 120 aura::Window* target_root = nullptr;
106 ConvertHostPointToRelativeToRootWindow( 121 ConvertHostPointToRelativeToRootWindow(
107 root, WmWindow::ToAuraWindows(WmShell::Get()->GetAllRootWindows()), point, 122 root, WmWindow::ToAuraWindows(WmShell::Get()->GetAllRootWindows()), point,
108 &target_root); 123 &target_root);
109 ConvertPointToScreen(target_root, point); 124 ConvertPointToScreen(target_root, point);
110 } 125 }
111 126
112 void ScreenPositionController::SetBounds(aura::Window* window, 127 void ScreenPositionController::SetBounds(aura::Window* window,
113 const gfx::Rect& bounds, 128 const gfx::Rect& bounds,
114 const display::Display& display) { 129 const display::Display& display) {
115 if (!window->parent()->GetProperty(kUsesScreenCoordinatesKey)) { 130 if (!window->parent()->GetProperty(kUsesScreenCoordinatesKey)) {
116 window->SetBounds(bounds); 131 window->SetBounds(bounds);
117 return; 132 return;
118 } 133 }
119 134
120 wm::SetBoundsInScreen(WmWindow::Get(window), bounds, display); 135 wm::SetBoundsInScreen(WmWindow::Get(window), bounds, display);
121 } 136 }
122 137
123 } // namespace ash 138 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698