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

Side by Side Diff: ash/monitor/monitor_controller.cc

Issue 9701098: MultiMonitor support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/monitor/monitor_controller.h ('k') | ash/monitor/multi_monitor_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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());
54 }
55
56 void MonitorController::Init() {
57 aura::MonitorManager* monitor_manager =
58 aura::Env::GetInstance()->monitor_manager();
59 for (size_t i = 0; i < monitor_manager->GetNumMonitors(); ++i) {
60 aura::Monitor* monitor = monitor_manager->GetMonitorAt(i);
61 const aura::Monitor* key = monitor;
62 if (i == 0) {
63 // Primary monitor
64 root_windows_[key] = Shell::GetRootWindow();
65 } else {
66 aura::RootWindow* root =
67 monitor_manager->CreateRootWindowForMonitor(monitor);
68 root_windows_[key] = root;
69 SetupAsSecondaryMonitor(root);
70 }
71 }
72 }
73
74 } // namespace internal
75 } // namespace ash
OLDNEW
« no previous file with comments | « ash/monitor/monitor_controller.h ('k') | ash/monitor/multi_monitor_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698