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/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // static | 26 // static |
27 bool MonitorManager::use_fullscreen_host_window_ = false; | 27 bool MonitorManager::use_fullscreen_host_window_ = false; |
28 | 28 |
29 // static | 29 // static |
30 gfx::Monitor MonitorManager::CreateMonitorFromSpec(const std::string& spec) { | 30 gfx::Monitor MonitorManager::CreateMonitorFromSpec(const std::string& spec) { |
31 static int synthesized_monitor_id = 1000; | 31 static int synthesized_monitor_id = 1000; |
32 gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY, | 32 gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY, |
33 kDefaultHostWindowWidth, kDefaultHostWindowHeight); | 33 kDefaultHostWindowWidth, kDefaultHostWindowHeight); |
34 int x = 0, y = 0, width, height; | 34 int x = 0, y = 0, width, height; |
35 float scale = 1.0f; | 35 float scale = gfx::Monitor::GetDefaultDeviceScaleFactor(); |
36 if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2) { | 36 if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2) { |
37 bounds.set_size(gfx::Size(width, height)); | 37 bounds.set_size(gfx::Size(width, height)); |
38 } else if (sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, | 38 } else if (sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, |
39 &scale) >= 4 ) { | 39 &scale) >= 4 ) { |
40 bounds = gfx::Rect(x, y, width, height); | 40 bounds = gfx::Rect(x, y, width, height); |
41 } else if (use_fullscreen_host_window_) { | 41 } else if (use_fullscreen_host_window_) { |
42 bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize()); | 42 bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize()); |
43 } | 43 } |
44 gfx::Monitor monitor(synthesized_monitor_id++); | 44 gfx::Monitor monitor(synthesized_monitor_id++); |
45 monitor.SetScaleAndBounds(scale, bounds); | 45 monitor.SetScaleAndBounds(scale, bounds); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 FOR_EACH_OBSERVER(MonitorObserver, observers_, | 80 FOR_EACH_OBSERVER(MonitorObserver, observers_, |
81 OnMonitorAdded(monitor)); | 81 OnMonitorAdded(monitor)); |
82 } | 82 } |
83 | 83 |
84 void MonitorManager::NotifyMonitorRemoved(const gfx::Monitor& monitor) { | 84 void MonitorManager::NotifyMonitorRemoved(const gfx::Monitor& monitor) { |
85 FOR_EACH_OBSERVER(MonitorObserver, observers_, | 85 FOR_EACH_OBSERVER(MonitorObserver, observers_, |
86 OnMonitorRemoved(monitor)); | 86 OnMonitorRemoved(monitor)); |
87 } | 87 } |
88 | 88 |
89 } // namespace aura | 89 } // namespace aura |
OLD | NEW |