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/monitor_manager.h" | 5 #include "ui/aura/monitor_manager.h" |
6 | 6 |
| 7 #include <stdio.h> |
| 8 |
| 9 #include "ui/aura/monitor.h" |
| 10 #include "ui/aura/root_window_host.h" |
| 11 #include "ui/gfx/rect.h" |
| 12 |
7 namespace aura { | 13 namespace aura { |
| 14 namespace { |
| 15 // Default bounds for a monitor. |
| 16 static const int kDefaultHostWindowX = 200; |
| 17 static const int kDefaultHostWindowY = 200; |
| 18 static const int kDefaultHostWindowWidth = 1280; |
| 19 static const int kDefaultHostWindowHeight = 1024; |
| 20 } // namespace |
| 21 |
| 22 bool MonitorManager::use_fullscreen_host_window_ = false; |
8 | 23 |
9 MonitorManager::MonitorManager() { | 24 MonitorManager::MonitorManager() { |
10 } | 25 } |
11 | 26 |
12 MonitorManager::~MonitorManager() { | 27 MonitorManager::~MonitorManager() { |
13 } | 28 } |
14 | 29 |
15 void MonitorManager::AddObserver(MonitorObserver* observer) { | 30 void MonitorManager::AddObserver(MonitorObserver* observer) { |
16 observers_.AddObserver(observer); | 31 observers_.AddObserver(observer); |
17 } | 32 } |
18 | 33 |
19 void MonitorManager::RemoveObserver(MonitorObserver* observer) { | 34 void MonitorManager::RemoveObserver(MonitorObserver* observer) { |
20 observers_.RemoveObserver(observer); | 35 observers_.RemoveObserver(observer); |
21 } | 36 } |
22 | 37 |
23 RootWindow* MonitorManager::CreateRootWindowForPrimaryMonitor() { | 38 RootWindow* MonitorManager::CreateRootWindowForPrimaryMonitor() { |
24 return CreateRootWindowForMonitor(GetPrimaryMonitor()); | 39 return CreateRootWindowForMonitor(GetMonitorAt(0)); |
25 } | 40 } |
26 | 41 |
27 void MonitorManager::NotifyBoundsChanged(const Monitor* monitor) { | 42 void MonitorManager::NotifyBoundsChanged(const Monitor* monitor) { |
28 FOR_EACH_OBSERVER(MonitorObserver, observers_, | 43 FOR_EACH_OBSERVER(MonitorObserver, observers_, |
29 OnMonitorBoundsChanged(monitor)); | 44 OnMonitorBoundsChanged(monitor)); |
30 } | 45 } |
31 | 46 |
| 47 Monitor* MonitorManager::CreateMonitorFromSpec(const std::string& spec) { |
| 48 gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY, |
| 49 kDefaultHostWindowWidth, kDefaultHostWindowHeight); |
| 50 int x = 0, y = 0, width, height; |
| 51 if (sscanf(spec.c_str(), "%dx%d", &width, &height) == 2) { |
| 52 bounds.set_size(gfx::Size(width, height)); |
| 53 } else if (sscanf(spec.c_str(), "%d+%d-%dx%d", &x, &y, &width, &height) |
| 54 == 4) { |
| 55 bounds = gfx::Rect(x, y, width, height); |
| 56 } else if (use_fullscreen_host_window_) { |
| 57 bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize()); |
| 58 } |
| 59 Monitor* monitor = new Monitor(); |
| 60 monitor->set_bounds(bounds); |
| 61 return monitor; |
| 62 } |
| 63 |
32 } // namespace aura | 64 } // namespace aura |
OLD | NEW |