OLD | NEW |
---|---|
(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 "ui/aura/display_util.h" | |
6 | |
7 #include "ui/aura/root_window_host.h" | |
8 #include "ui/gfx/display.h" | |
9 #include "base/logging.h" | |
10 #include "base/string_number_conversions.h" | |
11 | |
12 namespace aura { | |
13 namespace { | |
14 | |
15 bool use_fullscreen_host_window = false; | |
ananta
2012/11/09 18:39:51
Should this be prefixed with g_?
oshima
2012/11/09 18:53:49
g_ is for global that can be accessed from other f
| |
16 | |
17 // Default bounds for a display. | |
18 const int kDefaultHostWindowX = 200; | |
19 const int kDefaultHostWindowY = 200; | |
20 const int kDefaultHostWindowWidth = 1280; | |
21 const int kDefaultHostWindowHeight = 1024; | |
22 | |
23 } // namespace | |
24 | |
25 void SetUseFullscreenHostWindow(bool value) { | |
26 use_fullscreen_host_window = value; | |
27 } | |
28 | |
29 bool UseFullscreenHostWindow() { | |
30 return use_fullscreen_host_window; | |
31 } | |
32 | |
33 gfx::Display CreateDisplayFromSpec(const std::string& spec) { | |
34 static int64 synthesized_display_id = 1000; | |
35 gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY, | |
36 kDefaultHostWindowWidth, kDefaultHostWindowHeight); | |
37 int x = 0, y = 0, width, height; | |
38 float scale = 1.0f; | |
39 if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2 || | |
40 sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height, | |
41 &scale) >= 4) { | |
42 bounds.SetRect(x, y, width, height); | |
43 } else if (use_fullscreen_host_window) { | |
44 bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize()); | |
45 } | |
46 gfx::Display display(synthesized_display_id++); | |
47 display.SetScaleAndBounds(scale, bounds); | |
48 DVLOG(1) << "Display bounds=" << bounds.ToString() << ", scale=" << scale; | |
49 return display; | |
50 } | |
51 | |
52 } // namespace aura | |
OLD | NEW |