OLD | NEW |
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/screen_ash.h" | 5 #include "ash/screen_ash.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/shelf_layout_manager.h" | 8 #include "ash/wm/shelf_layout_manager.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
11 #include "ui/aura/monitor.h" | |
12 #include "ui/aura/monitor_manager.h" | 11 #include "ui/aura/monitor_manager.h" |
13 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
| 13 #include "ui/gfx/monitor.h" |
| 14 #include "ui/gfx/screen.h" |
14 | 15 |
15 namespace ash { | 16 namespace ash { |
16 | 17 |
17 // TODO(oshima): For m19, the origin of work area/monitor bounds for | |
18 // views/aura is (0,0) because it's simple and enough. Fix this when | |
19 // real multi monitor support is implemented. | |
20 | |
21 namespace { | 18 namespace { |
22 aura::MonitorManager* GetMonitorManager() { | 19 aura::MonitorManager* GetMonitorManager() { |
23 return aura::Env::GetInstance()->monitor_manager(); | 20 return aura::Env::GetInstance()->monitor_manager(); |
24 } | 21 } |
25 } // namespace | 22 } // namespace |
26 | 23 |
27 ScreenAsh::ScreenAsh(aura::RootWindow* root_window) | 24 ScreenAsh::ScreenAsh(aura::RootWindow* root_window) |
28 : root_window_(root_window) { | 25 : root_window_(root_window) { |
29 } | 26 } |
30 | 27 |
31 ScreenAsh::~ScreenAsh() { | 28 ScreenAsh::~ScreenAsh() { |
32 } | 29 } |
33 | 30 |
34 // static | 31 // static |
35 gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) { | 32 gfx::Rect ScreenAsh::GetMaximizedWindowBounds(aura::Window* window) { |
36 return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window); | 33 return Shell::GetInstance()->shelf()->GetMaximizedWindowBounds(window); |
37 } | 34 } |
38 | 35 |
39 // static | 36 // static |
40 gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) { | 37 gfx::Rect ScreenAsh::GetUnmaximizedWorkAreaBounds(aura::Window* window) { |
41 return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window); | 38 return Shell::GetInstance()->shelf()->GetUnmaximizedWorkAreaBounds(window); |
42 } | 39 } |
43 | 40 |
44 gfx::Point ScreenAsh::GetCursorScreenPointImpl() { | 41 gfx::Point ScreenAsh::GetCursorScreenPoint() { |
45 return root_window_->last_mouse_location(); | 42 return root_window_->last_mouse_location(); |
46 } | 43 } |
47 | 44 |
48 gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestWindowImpl( | 45 gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPoint() { |
49 gfx::NativeWindow window) { | 46 const gfx::Point point = gfx::Screen::GetCursorScreenPoint(); |
50 return GetMonitorManager()->GetMonitorNearestWindow(window)-> | |
51 GetWorkAreaBounds(); | |
52 } | |
53 | |
54 gfx::Rect ScreenAsh::GetMonitorAreaNearestWindowImpl( | |
55 gfx::NativeWindow window) { | |
56 // See the comment at the top. | |
57 return gfx::Rect( | |
58 GetMonitorManager()->GetMonitorNearestWindow(window)->size()); | |
59 } | |
60 | |
61 gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestPointImpl( | |
62 const gfx::Point& point) { | |
63 return GetMonitorManager()->GetMonitorNearestPoint(point)-> | |
64 GetWorkAreaBounds(); | |
65 } | |
66 | |
67 gfx::Rect ScreenAsh::GetMonitorAreaNearestPointImpl(const gfx::Point& point) { | |
68 // See the comment at the top. | |
69 return gfx::Rect(GetMonitorManager()->GetMonitorNearestPoint(point)->size()); | |
70 } | |
71 | |
72 gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPointImpl() { | |
73 const gfx::Point point = GetCursorScreenPoint(); | |
74 return root_window_->GetTopWindowContainingPoint(point); | 47 return root_window_->GetTopWindowContainingPoint(point); |
75 } | 48 } |
76 | 49 |
77 gfx::Size ScreenAsh::GetPrimaryMonitorSizeImpl() { | 50 int ScreenAsh::GetNumMonitors() { |
78 return GetMonitorManager()->GetMonitorAt(0)->size(); | |
79 } | |
80 | |
81 int ScreenAsh::GetNumMonitorsImpl() { | |
82 return GetMonitorManager()->GetNumMonitors(); | 51 return GetMonitorManager()->GetNumMonitors(); |
83 } | 52 } |
84 | 53 |
| 54 |
| 55 gfx::Monitor ScreenAsh::GetMonitorNearestWindow(gfx::NativeView window) const { |
| 56 gfx::Monitor monitor = GetMonitorManager()->GetMonitorNearestWindow(window); |
| 57 // TODO(oshima): For m19, work area/monitor bounds that chrome/webapps sees |
| 58 // has (0, 0) origin because it's simpler and enough. Fix this when |
| 59 // real multi monitor support is implemented. |
| 60 monitor.SetBoundsAndUpdateWorkArea(gfx::Rect(monitor.size())); |
| 61 return monitor; |
| 62 } |
| 63 |
| 64 gfx::Monitor ScreenAsh::GetMonitorNearestPoint(const gfx::Point& point) const { |
| 65 gfx::Monitor monitor = GetMonitorManager()->GetMonitorNearestPoint(point); |
| 66 // See comment above. |
| 67 monitor.SetBoundsAndUpdateWorkArea(gfx::Rect(monitor.size())); |
| 68 return monitor; |
| 69 } |
| 70 |
| 71 gfx::Monitor ScreenAsh::GetPrimaryMonitor() const { |
| 72 gfx::Monitor monitor = GetMonitorManager()->GetMonitorAt(0); |
| 73 // See comment above. |
| 74 monitor.SetBoundsAndUpdateWorkArea(gfx::Rect(monitor.size())); |
| 75 return monitor; |
| 76 } |
| 77 |
85 } // namespace ash | 78 } // namespace ash |
OLD | NEW |