| 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/single_monitor_manager.h" | 5 #include "ui/aura/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.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 internal { | 17 namespace internal { |
| 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 monitor_(new Monitor()) { | |
| 32 Init(); | 31 Init(); |
| 33 } | 32 } |
| 34 | 33 |
| 35 SingleMonitorManager::~SingleMonitorManager() { | 34 SingleMonitorManager::~SingleMonitorManager() { |
| 36 if (root_window_) | 35 // All monitors must have been deleted when monitor manager is deleted. |
| 37 root_window_->RemoveObserver(this); | 36 CHECK(!root_window_); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void SingleMonitorManager::OnNativeMonitorResized(const gfx::Size& size) { | 39 void SingleMonitorManager::OnNativeMonitorsChanged( |
| 40 const std::vector<const Monitor*>& monitors) { |
| 41 DCHECK(monitors.size() > 0); |
| 41 if (use_fullscreen_host_window()) { | 42 if (use_fullscreen_host_window()) { |
| 42 monitor_->set_size(size); | 43 monitor_->set_size(monitors[0]->bounds().size()); |
| 43 NotifyBoundsChanged(monitor_.get()); | 44 NotifyBoundsChanged(monitor_.get()); |
| 44 } | 45 } |
| 45 } | 46 } |
| 46 | 47 |
| 47 RootWindow* SingleMonitorManager::CreateRootWindowForMonitor( | 48 RootWindow* SingleMonitorManager::CreateRootWindowForMonitor( |
| 48 Monitor* monitor) { | 49 Monitor* monitor) { |
| 49 DCHECK(!root_window_); | 50 DCHECK(!root_window_); |
| 50 DCHECK_EQ(monitor_.get(), monitor); | 51 DCHECK_EQ(monitor_.get(), monitor); |
| 51 root_window_ = new RootWindow(monitor->bounds()); | 52 root_window_ = new RootWindow(monitor->bounds()); |
| 52 root_window_->AddObserver(this); | 53 root_window_->AddObserver(this); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 switches::kAuraHostWindowSize); | 94 switches::kAuraHostWindowSize); |
| 94 monitor_.reset(CreateMonitorFromSpec(size_str)); | 95 monitor_.reset(CreateMonitorFromSpec(size_str)); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void SingleMonitorManager::Update(const gfx::Size size) { | 98 void SingleMonitorManager::Update(const gfx::Size size) { |
| 98 monitor_->set_size(size); | 99 monitor_->set_size(size); |
| 99 } | 100 } |
| 100 | 101 |
| 101 } // namespace inernal | 102 } // namespace inernal |
| 102 } // namespace aura | 103 } // namespace aura |
| OLD | NEW |