Chromium Code Reviews| 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> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/string_number_conversions.h" | |
| 12 #include "content/public/common/content_switches.h" | |
| 10 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 11 #include "ui/aura/monitor_observer.h" | 14 #include "ui/aura/monitor_observer.h" |
| 12 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/root_window_host.h" | 16 #include "ui/aura/root_window_host.h" |
| 14 #include "ui/gfx/monitor.h" | 17 #include "ui/gfx/monitor.h" |
| 15 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 16 | 19 |
| 17 namespace aura { | 20 namespace aura { |
| 18 namespace { | 21 namespace { |
| 19 // Default bounds for a monitor. | 22 // Default bounds for a monitor. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 34 int x = 0, y = 0, width, height; | 37 int x = 0, y = 0, width, height; |
| 35 float scale = 1.0f; | 38 float scale = 1.0f; |
| 36 if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2) { | 39 if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2) { |
| 37 bounds.set_size(gfx::Size(width, height)); | 40 bounds.set_size(gfx::Size(width, height)); |
| 38 } else if (sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, | 41 } else if (sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, |
| 39 &scale) >= 4 ) { | 42 &scale) >= 4 ) { |
| 40 bounds = gfx::Rect(x, y, width, height); | 43 bounds = gfx::Rect(x, y, width, height); |
| 41 } else if (use_fullscreen_host_window_) { | 44 } else if (use_fullscreen_host_window_) { |
| 42 bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize()); | 45 bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize()); |
| 43 } | 46 } |
| 47 | |
| 48 // Setting a default device scale factor overrides the monitor scale factor. | |
| 49 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 50 switches::kDefaultDeviceScaleFactor)) { | |
| 51 int default_device_scale_factor; | |
| 52 base::StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
|
sky
2012/04/27 19:44:46
check return value.
flackr
2012/04/30 14:05:15
Done.
| |
| 53 switches::kDefaultDeviceScaleFactor), | |
| 54 &default_device_scale_factor); | |
| 55 scale = default_device_scale_factor; | |
| 56 } | |
| 57 | |
| 44 gfx::Monitor monitor(synthesized_monitor_id++, bounds); | 58 gfx::Monitor monitor(synthesized_monitor_id++, bounds); |
| 45 monitor.set_device_scale_factor(scale); | 59 monitor.set_device_scale_factor(scale); |
| 46 DVLOG(1) << "Monitor bounds=" << bounds.ToString() << ", scale=" << scale; | 60 DVLOG(1) << "Monitor bounds=" << bounds.ToString() << ", scale=" << scale; |
| 47 return monitor; | 61 return monitor; |
| 48 } | 62 } |
| 49 | 63 |
| 50 // static | 64 // static |
| 51 RootWindow* MonitorManager::CreateRootWindowForPrimaryMonitor() { | 65 RootWindow* MonitorManager::CreateRootWindowForPrimaryMonitor() { |
| 52 MonitorManager* manager = aura::Env::GetInstance()->monitor_manager(); | 66 MonitorManager* manager = aura::Env::GetInstance()->monitor_manager(); |
| 53 RootWindow* root = | 67 RootWindow* root = |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 80 FOR_EACH_OBSERVER(MonitorObserver, observers_, | 94 FOR_EACH_OBSERVER(MonitorObserver, observers_, |
| 81 OnMonitorAdded(monitor)); | 95 OnMonitorAdded(monitor)); |
| 82 } | 96 } |
| 83 | 97 |
| 84 void MonitorManager::NotifyMonitorRemoved(const gfx::Monitor& monitor) { | 98 void MonitorManager::NotifyMonitorRemoved(const gfx::Monitor& monitor) { |
| 85 FOR_EACH_OBSERVER(MonitorObserver, observers_, | 99 FOR_EACH_OBSERVER(MonitorObserver, observers_, |
| 86 OnMonitorRemoved(monitor)); | 100 OnMonitorRemoved(monitor)); |
| 87 } | 101 } |
| 88 | 102 |
| 89 } // namespace aura | 103 } // namespace aura |
| OLD | NEW |