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 "ui/aura/test/single_monitor_manager.h" | 5 #include "ui/aura/test/single_monitor_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "ui/aura/aura_switches.h" | 10 #include "ui/aura/aura_switches.h" |
11 #include "ui/aura/monitor.h" | 11 #include "ui/aura/monitor_aura.h" |
12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
13 #include "ui/aura/root_window_host.h" | 13 #include "ui/aura/root_window_host.h" |
14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
15 | 15 |
16 namespace aura { | 16 namespace aura { |
17 namespace test { | 17 namespace test { |
18 | 18 |
19 using std::string; | 19 using std::string; |
20 | 20 |
21 namespace { | 21 namespace { |
22 // Default bounds for the primary monitor. | 22 // Default bounds for the primary monitor. |
23 static const int kDefaultHostWindowX = 200; | 23 static const int kDefaultHostWindowX = 200; |
24 static const int kDefaultHostWindowY = 200; | 24 static const int kDefaultHostWindowY = 200; |
25 static const int kDefaultHostWindowWidth = 1280; | 25 static const int kDefaultHostWindowWidth = 1280; |
26 static const int kDefaultHostWindowHeight = 1024; | 26 static const int kDefaultHostWindowHeight = 1024; |
27 } | 27 } |
28 | 28 |
29 SingleMonitorManager::SingleMonitorManager() | 29 SingleMonitorManager::SingleMonitorManager() |
30 : root_window_(NULL) { | 30 : root_window_(NULL) { |
31 Init(); | 31 Init(); |
32 } | 32 } |
33 | 33 |
34 SingleMonitorManager::~SingleMonitorManager() { | 34 SingleMonitorManager::~SingleMonitorManager() { |
35 // All monitors must have been deleted when monitor manager is deleted. | 35 // All monitors must have been deleted when monitor manager is deleted. |
36 CHECK(!root_window_); | 36 CHECK(!root_window_); |
37 } | 37 } |
38 | 38 |
39 void SingleMonitorManager::OnNativeMonitorsChanged( | 39 void SingleMonitorManager::OnNativeMonitorsChanged( |
40 const std::vector<const Monitor*>& monitors) { | 40 const std::vector<const MonitorAura*>& monitors) { |
41 DCHECK(monitors.size() > 0); | 41 DCHECK(monitors.size() > 0); |
42 if (use_fullscreen_host_window()) { | 42 if (use_fullscreen_host_window()) { |
43 monitor_->set_size(monitors[0]->bounds().size()); | 43 monitor_->set_size(monitors[0]->bounds().size()); |
44 NotifyBoundsChanged(monitor_.get()); | 44 NotifyBoundsChanged(monitor_.get()); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 RootWindow* SingleMonitorManager::CreateRootWindowForMonitor( | 48 RootWindow* SingleMonitorManager::CreateRootWindowForMonitor( |
49 Monitor* monitor) { | 49 MonitorAura* monitor) { |
50 DCHECK(!root_window_); | 50 DCHECK(!root_window_); |
51 DCHECK_EQ(monitor_.get(), monitor); | 51 DCHECK_EQ(monitor_.get(), monitor); |
52 root_window_ = new RootWindow(monitor->bounds()); | 52 root_window_ = new RootWindow(monitor->bounds()); |
53 root_window_->AddObserver(this); | 53 root_window_->AddObserver(this); |
54 return root_window_; | 54 return root_window_; |
55 } | 55 } |
56 | 56 |
57 const Monitor* SingleMonitorManager::GetMonitorNearestWindow( | 57 MonitorAura* SingleMonitorManager::GetMonitorAt(size_t index) { |
58 const Window* window) const { | |
59 return monitor_.get(); | |
60 } | |
61 | |
62 const Monitor* SingleMonitorManager::GetMonitorNearestPoint( | |
63 const gfx::Point& point) const { | |
64 return monitor_.get(); | |
65 } | |
66 | |
67 Monitor* SingleMonitorManager::GetMonitorAt(size_t index) { | |
68 return !index ? monitor_.get() : NULL; | 58 return !index ? monitor_.get() : NULL; |
69 } | 59 } |
70 | 60 |
71 size_t SingleMonitorManager::GetNumMonitors() const { | 61 size_t SingleMonitorManager::GetNumMonitors() const { |
72 return 1; | 62 return 1; |
73 } | 63 } |
74 | 64 |
75 Monitor* SingleMonitorManager::GetMonitorNearestWindow(const Window* window) { | 65 const MonitorAura* SingleMonitorManager::GetMonitorNearestWindow( |
| 66 const Window* window) const { |
76 return monitor_.get(); | 67 return monitor_.get(); |
77 } | 68 } |
78 | 69 |
| 70 MonitorAura* SingleMonitorManager::GetMonitorNearestWindow( |
| 71 const Window* window) { |
| 72 return monitor_.get(); |
| 73 } |
| 74 |
| 75 const MonitorAura* SingleMonitorManager::GetMonitorNearestPoint( |
| 76 const gfx::Point& point) const { |
| 77 return monitor_.get(); |
| 78 } |
| 79 |
79 void SingleMonitorManager::OnWindowBoundsChanged( | 80 void SingleMonitorManager::OnWindowBoundsChanged( |
80 Window* window, const gfx::Rect& bounds) { | 81 Window* window, const gfx::Rect& bounds) { |
81 if (!use_fullscreen_host_window()) { | 82 if (!use_fullscreen_host_window()) { |
82 Update(bounds.size()); | 83 Update(bounds.size()); |
83 NotifyBoundsChanged(monitor_.get()); | 84 NotifyBoundsChanged(monitor_.get()); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 void SingleMonitorManager::OnWindowDestroying(Window* window) { | 88 void SingleMonitorManager::OnWindowDestroying(Window* window) { |
88 if (root_window_ == window) | 89 if (root_window_ == window) |
89 root_window_ = NULL; | 90 root_window_ = NULL; |
90 } | 91 } |
91 | 92 |
92 void SingleMonitorManager::Init() { | 93 void SingleMonitorManager::Init() { |
93 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 94 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
94 switches::kAuraHostWindowSize); | 95 switches::kAuraHostWindowSize); |
95 monitor_.reset(CreateMonitorFromSpec(size_str)); | 96 monitor_.reset(CreateMonitorFromSpec(size_str)); |
96 } | 97 } |
97 | 98 |
98 void SingleMonitorManager::Update(const gfx::Size size) { | 99 void SingleMonitorManager::Update(const gfx::Size size) { |
99 monitor_->set_size(size); | 100 monitor_->set_size(size); |
100 } | 101 } |
101 | 102 |
102 } // namespace test | 103 } // namespace test |
103 } // namespace aura | 104 } // namespace aura |
OLD | NEW |