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

Side by Side Diff: ui/aura/monitor_manager.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 | « ui/aura/monitor_manager.h ('k') | ui/aura/root_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/monitor_manager.h" 5 #include "ui/aura/monitor_manager.h"
6 6
7 #include <stdio.h>
8
9 #include "ui/aura/env.h"
10 #include "ui/aura/monitor.h"
11 #include "ui/aura/root_window_host.h"
12 #include "ui/gfx/rect.h"
13
7 namespace aura { 14 namespace aura {
15 namespace {
16 // Default bounds for a monitor.
17 static const int kDefaultHostWindowX = 200;
18 static const int kDefaultHostWindowY = 200;
19 static const int kDefaultHostWindowWidth = 1280;
20 static const int kDefaultHostWindowHeight = 1024;
21 } // namespace
22
23 // static
24 bool MonitorManager::use_fullscreen_host_window_ = false;
25
26 // static
27 Monitor* MonitorManager::CreateMonitorFromSpec(const std::string& spec) {
28 gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY,
29 kDefaultHostWindowWidth, kDefaultHostWindowHeight);
30 int x = 0, y = 0, width, height;
31 if (sscanf(spec.c_str(), "%dx%d", &width, &height) == 2) {
32 bounds.set_size(gfx::Size(width, height));
33 } else if (sscanf(spec.c_str(), "%d+%d-%dx%d", &x, &y, &width, &height)
34 == 4) {
35 bounds = gfx::Rect(x, y, width, height);
36 } else if (use_fullscreen_host_window_) {
37 bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize());
38 }
39 Monitor* monitor = new Monitor();
40 monitor->set_bounds(bounds);
41 return monitor;
42 }
43
44 // static
45 RootWindow* MonitorManager::CreateRootWindowForPrimaryMonitor() {
46 MonitorManager* manager = aura::Env::GetInstance()->monitor_manager();
47 return manager->CreateRootWindowForMonitor(manager->GetMonitorAt(0));
48 }
8 49
9 MonitorManager::MonitorManager() { 50 MonitorManager::MonitorManager() {
10 } 51 }
11 52
12 MonitorManager::~MonitorManager() { 53 MonitorManager::~MonitorManager() {
13 } 54 }
14 55
15 void MonitorManager::AddObserver(MonitorObserver* observer) { 56 void MonitorManager::AddObserver(MonitorObserver* observer) {
16 observers_.AddObserver(observer); 57 observers_.AddObserver(observer);
17 } 58 }
18 59
19 void MonitorManager::RemoveObserver(MonitorObserver* observer) { 60 void MonitorManager::RemoveObserver(MonitorObserver* observer) {
20 observers_.RemoveObserver(observer); 61 observers_.RemoveObserver(observer);
21 } 62 }
22 63
23 RootWindow* MonitorManager::CreateRootWindowForPrimaryMonitor() {
24 return CreateRootWindowForMonitor(GetPrimaryMonitor());
25 }
26
27 void MonitorManager::NotifyBoundsChanged(const Monitor* monitor) { 64 void MonitorManager::NotifyBoundsChanged(const Monitor* monitor) {
28 FOR_EACH_OBSERVER(MonitorObserver, observers_, 65 FOR_EACH_OBSERVER(MonitorObserver, observers_,
29 OnMonitorBoundsChanged(monitor)); 66 OnMonitorBoundsChanged(monitor));
30 } 67 }
31 68
32 } // namespace aura 69 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/monitor_manager.h ('k') | ui/aura/root_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698