OLD | NEW |
---|---|
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/coordinate_conversion.h" | 5 #include "ui/wm/core/coordinate_conversion.h" |
6 | 6 |
7 #include "ui/aura/client/screen_position_client.h" | 7 #include "ui/aura/client/screen_position_client.h" |
8 #include "ui/gfx/geometry/point.h" | 8 #include "ui/gfx/geometry/point.h" |
9 #include "ui/gfx/geometry/rect.h" | |
9 | 10 |
10 namespace wm { | 11 namespace wm { |
11 | 12 |
12 void ConvertPointToScreen(const aura::Window* window, gfx::Point* point) { | 13 void ConvertPointToScreen(const aura::Window* window, gfx::Point* point) { |
13 DCHECK(window); | 14 DCHECK(window); |
14 DCHECK(window->GetRootWindow()); | 15 DCHECK(window->GetRootWindow()); |
15 DCHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); | 16 DCHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); |
16 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | 17 aura::client::GetScreenPositionClient(window->GetRootWindow())-> |
17 ConvertPointToScreen(window, point); | 18 ConvertPointToScreen(window, point); |
18 } | 19 } |
19 | 20 |
20 void ConvertPointFromScreen(const aura::Window* window, | 21 void ConvertPointFromScreen(const aura::Window* window, |
21 gfx::Point* point_in_screen) { | 22 gfx::Point* point_in_screen) { |
22 DCHECK(window); | 23 DCHECK(window); |
23 DCHECK(window->GetRootWindow()); | 24 DCHECK(window->GetRootWindow()); |
24 DCHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); | 25 DCHECK(aura::client::GetScreenPositionClient(window->GetRootWindow())); |
25 aura::client::GetScreenPositionClient(window->GetRootWindow())-> | 26 aura::client::GetScreenPositionClient(window->GetRootWindow())-> |
26 ConvertPointFromScreen(window, point_in_screen); | 27 ConvertPointFromScreen(window, point_in_screen); |
27 } | 28 } |
28 | 29 |
30 void ConvertRectToScreen(const aura::Window* window, gfx::Rect* rect) { | |
31 gfx::Point point = rect->origin(); | |
32 ConvertPointToScreen(window, &point); | |
33 rect->set_origin(point); | |
sadrul
2017/01/31 16:58:12
It is possible for the window to be rotated/scaled
yhanada
2017/02/01 06:39:27
Done.
oshima
2017/02/01 18:50:56
It is not possible to convert rect to rect over ar
sadrul
2017/02/02 17:33:17
We should fix aura window. Even the new code isn't
| |
34 } | |
35 | |
36 void ConvertRectFromScreen(const aura::Window* window, | |
37 gfx::Rect* rect_in_screen) { | |
38 gfx::Point point = rect_in_screen->origin(); | |
39 ConvertPointFromScreen(window, &point); | |
40 rect_in_screen->set_origin(point); | |
41 } | |
42 | |
29 } // namespace wm | 43 } // namespace wm |
OLD | NEW |