Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2326)

Unified Diff: ash/monitor/monitor_controller.cc

Issue 9701098: MultiMonitor support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix shutdown order Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/monitor/monitor_controller.cc
diff --git a/ash/monitor/monitor_controller.cc b/ash/monitor/monitor_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fbcf562141765b7eef52d4974799f902a95c5f0d
--- /dev/null
+++ b/ash/monitor/monitor_controller.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/monitor/monitor_controller.h"
+
+#include "ash/monitor/multi_monitor_manager.h"
+#include "ash/monitor/secondary_monitor_view.h"
+#include "ash/shell.h"
+#include "ash/wm/base_layout_manager.h"
+#include "ash/wm/root_window_layout_manager.h"
+#include "base/stl_util.h"
+#include "ui/aura/env.h"
+#include "ui/aura/monitor.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+
+namespace ash {
+namespace internal {
+
+namespace {
+
+void SetupAsSecondaryMonitor(aura::RootWindow* root) {
+ root->SetLayoutManager(new internal::RootWindowLayoutManager(root));
+ aura::Window* container = new aura::Window(NULL);
+ container->SetName("SecondaryMonitorContainer");
+ container->Init(ui::Layer::LAYER_NOT_DRAWN);
+ root->AddChild(container);
+ container->Show();
+ container->SetLayoutManager(new internal::BaseLayoutManager(root));
+ CreateSecondaryMonitorWidget(container);
+ root->ShowRootWindow();
+}
+
+} // namespace
+
+MonitorController::MonitorController() {
+ aura::Env::GetInstance()->monitor_manager()->AddObserver(this);
+ Init();
+}
+
+MonitorController::~MonitorController() {
+ aura::Env::GetInstance()->monitor_manager()->RemoveObserver(this);
+ // Remove the root first.
+ aura::Monitor* monitor = Shell::GetRootWindow()->GetProperty(kMonitorKey);
+ root_windows_.erase(monitor);
+ STLDeleteContainerPairSecondPointers(
+ root_windows_.begin(), root_windows_.end());
+}
+
+void MonitorController::OnMonitorBoundsChanged(const aura::Monitor* monitor) {
+ if (aura::MonitorManager::use_fullscreen_host_window()) {
+ 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.
+ }
+}
+
+void MonitorController::Init() {
+ aura::MonitorManager* monitor_manager =
+ aura::Env::GetInstance()->monitor_manager();
+ for (size_t i = 0; i < monitor_manager->GetNumMonitors(); ++i) {
+ aura::Monitor* monitor = monitor_manager->GetMonitorAt(i);
+ const aura::Monitor* key = monitor;
+ if (i == 0) {
+ // primary monitor
Ben Goodger (Google) 2012/03/20 17:09:02 // Primary monitor.
oshima 2012/03/20 19:26:36 Done.
+ root_windows_[key] = Shell::GetRootWindow();
+ } else {
+ aura::RootWindow* root =
+ monitor_manager->CreateRootWindowForMonitor(monitor);
+ root_windows_[key] = root;
+ SetupAsSecondaryMonitor(root);
+ }
+ }
+}
+
+} // namespace internal
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698