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 "ash/screen_util.h" | 5 #include "ash/screen_util.h" |
6 | 6 |
7 #include "ash/common/shelf/wm_shelf.h" | 7 #include "ash/common/shelf/wm_shelf.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "ui/aura/client/screen_position_client.h" | 11 #include "ui/aura/client/screen_position_client.h" |
12 #include "ui/aura/window_event_dispatcher.h" | 12 #include "ui/aura/window_event_dispatcher.h" |
13 #include "ui/display/display.h" | 13 #include "ui/display/display.h" |
14 #include "ui/display/manager/display_manager.h" | 14 #include "ui/display/manager/display_manager.h" |
15 #include "ui/display/screen.h" | 15 #include "ui/display/screen.h" |
16 #include "ui/gfx/geometry/size_conversions.h" | 16 #include "ui/gfx/geometry/size_conversions.h" |
| 17 #include "ui/wm/core/coordinate_conversion.h" |
17 | 18 |
18 namespace ash { | 19 namespace ash { |
19 | 20 |
20 // static | 21 // static |
21 gfx::Rect ScreenUtil::GetMaximizedWindowBoundsInParent(aura::Window* window) { | 22 gfx::Rect ScreenUtil::GetMaximizedWindowBoundsInParent(aura::Window* window) { |
22 aura::Window* root_window = window->GetRootWindow(); | 23 aura::Window* root_window = window->GetRootWindow(); |
23 if (GetRootWindowController(root_window)->wm_shelf()->shelf_widget()) | 24 if (GetRootWindowController(root_window)->wm_shelf()->shelf_widget()) |
24 return GetDisplayWorkAreaBoundsInParent(window); | 25 return GetDisplayWorkAreaBoundsInParent(window); |
25 else | 26 else |
26 return GetDisplayBoundsInParent(window); | 27 return GetDisplayBoundsInParent(window); |
27 } | 28 } |
28 | 29 |
29 // static | 30 // static |
30 gfx::Rect ScreenUtil::GetDisplayBoundsInParent(aura::Window* window) { | 31 gfx::Rect ScreenUtil::GetDisplayBoundsInParent(aura::Window* window) { |
31 return ConvertRectFromScreen( | 32 return ::wm::ConvertRectFromScreen( |
32 window->parent(), | 33 window->parent(), |
33 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); | 34 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
34 } | 35 } |
35 | 36 |
36 // static | 37 // static |
37 gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { | 38 gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { |
38 return ConvertRectFromScreen(window->parent(), | 39 return ::wm::ConvertRectFromScreen(window->parent(), |
39 display::Screen::GetScreen() | 40 display::Screen::GetScreen() |
40 ->GetDisplayNearestWindow(window) | 41 ->GetDisplayNearestWindow(window) |
41 .work_area()); | 42 .work_area()); |
42 } | 43 } |
43 | 44 |
44 // static | |
45 gfx::Rect ScreenUtil::ConvertRectToScreen(aura::Window* window, | |
46 const gfx::Rect& rect) { | |
47 gfx::Point point = rect.origin(); | |
48 aura::client::GetScreenPositionClient(window->GetRootWindow()) | |
49 ->ConvertPointToScreen(window, &point); | |
50 return gfx::Rect(point, rect.size()); | |
51 } | |
52 | |
53 // static | |
54 gfx::Rect ScreenUtil::ConvertRectFromScreen(aura::Window* window, | |
55 const gfx::Rect& rect) { | |
56 gfx::Point point = rect.origin(); | |
57 aura::client::GetScreenPositionClient(window->GetRootWindow()) | |
58 ->ConvertPointFromScreen(window, &point); | |
59 return gfx::Rect(point, rect.size()); | |
60 } | |
61 | |
62 // static | |
63 | |
64 } // namespace ash | 45 } // namespace ash |
OLD | NEW |