Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/monitor/monitor_controller.h" | |
| 6 | |
| 7 #include "ash/monitor/multi_monitor_manager.h" | |
| 8 #include "ash/monitor/secondary_monitor_view.h" | |
| 9 #include "ash/shell.h" | |
| 10 #include "ash/wm/base_layout_manager.h" | |
| 11 #include "ash/wm/root_window_layout_manager.h" | |
| 12 #include "base/stl_util.h" | |
| 13 #include "ui/aura/env.h" | |
| 14 #include "ui/aura/monitor.h" | |
| 15 #include "ui/aura/root_window.h" | |
| 16 #include "ui/aura/window.h" | |
| 17 | |
| 18 namespace ash { | |
| 19 namespace internal { | |
| 20 | |
| 21 namespace { | |
| 22 | |
| 23 void SetupAsSecondaryMonitor(aura::RootWindow* root) { | |
| 24 root->SetLayoutManager(new internal::RootWindowLayoutManager(root)); | |
| 25 aura::Window* container = new aura::Window(NULL); | |
| 26 container->SetName("SecondaryMonitorContainer"); | |
| 27 container->Init(ui::Layer::LAYER_NOT_DRAWN); | |
| 28 root->AddChild(container); | |
| 29 container->Show(); | |
| 30 container->SetLayoutManager(new internal::BaseLayoutManager(root)); | |
| 31 CreateSecondaryMonitorWidget(container); | |
| 32 root->ShowRootWindow(); | |
| 33 } | |
| 34 | |
| 35 } // namespace | |
| 36 | |
| 37 MonitorController::MonitorController() { | |
| 38 aura::Env::GetInstance()->monitor_manager()->AddObserver(this); | |
| 39 Init(); | |
| 40 } | |
| 41 | |
| 42 MonitorController::~MonitorController() { | |
| 43 aura::Env::GetInstance()->monitor_manager()->RemoveObserver(this); | |
| 44 // Remove the root first. | |
| 45 aura::Monitor* monitor = Shell::GetRootWindow()->GetProperty(kMonitorKey); | |
| 46 root_windows_.erase(monitor); | |
| 47 STLDeleteContainerPairSecondPointers( | |
| 48 root_windows_.begin(), root_windows_.end()); | |
| 49 } | |
| 50 | |
| 51 void MonitorController::OnMonitorBoundsChanged(const aura::Monitor* monitor) { | |
| 52 if (aura::MonitorManager::use_fullscreen_host_window()) { | |
| 53 root_windows_[monitor]->SetHostBounds(monitor->bounds()); | |
|
Ben Goodger (Google)
2012/03/20 17:09:02
nit: no braces
oshima
2012/03/20 19:26:36
Done.
| |
| 54 } | |
| 55 } | |
| 56 | |
| 57 void MonitorController::Init() { | |
| 58 aura::MonitorManager* monitor_manager = | |
| 59 aura::Env::GetInstance()->monitor_manager(); | |
| 60 for (size_t i = 0; i < monitor_manager->GetNumMonitors(); ++i) { | |
| 61 aura::Monitor* monitor = monitor_manager->GetMonitorAt(i); | |
| 62 const aura::Monitor* key = monitor; | |
| 63 if (i == 0) { | |
| 64 // primary monitor | |
|
Ben Goodger (Google)
2012/03/20 17:09:02
// Primary monitor.
oshima
2012/03/20 19:26:36
Done.
| |
| 65 root_windows_[key] = Shell::GetRootWindow(); | |
| 66 } else { | |
| 67 aura::RootWindow* root = | |
| 68 monitor_manager->CreateRootWindowForMonitor(monitor); | |
| 69 root_windows_[key] = root; | |
| 70 SetupAsSecondaryMonitor(root); | |
| 71 } | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 } // namespace internal | |
| 76 } // namespace ash | |
| OLD | NEW |