1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/display/display_manager.h"
#include <string>
#include <vector>
#include "ash/ash_switches.h"
#include "ash/display/display_controller.h"
#include "ash/host/root_window_host_factory.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/string_number_conversions.h"
#include "base/string_split.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "grit/ash_strings.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/root_window_host.h"
#include "ui/aura/window_property.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/display.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/size_conversions.h"
#if defined(USE_X11)
#include "ui/base/x/x11_util.h"
#endif
#if defined(OS_CHROMEOS)
#include "base/chromeos/chromeos_version.h"
#include "chromeos/display/output_configurator.h"
#endif
#if defined(OS_WIN)
#include "base/win/windows_version.h"
#include "ui/aura/remote_root_window_host_win.h"
#endif
DECLARE_WINDOW_PROPERTY_TYPE(int64);
typedef std::vector<gfx::Display> DisplayList;
namespace ash {
namespace internal {
namespace {
// Default bounds for a display.
const int kDefaultHostWindowX = 200;
const int kDefaultHostWindowY = 200;
const int kDefaultHostWindowWidth = 1366;
const int kDefaultHostWindowHeight = 768;
struct DisplaySortFunctor {
bool operator()(const gfx::Display& a, const gfx::Display& b) {
return a.id() < b.id();
}
};
gfx::Display& GetInvalidDisplay() {
static gfx::Display* invalid_display = new gfx::Display();
return *invalid_display;
}
#if defined(OS_CHROMEOS)
int64 GetDisplayIdForOutput(XID output, int output_index) {
uint16 manufacturer_id = 0;
uint16 product_code = 0;
ui::GetOutputDeviceData(
output, &manufacturer_id, &product_code, NULL);
return gfx::Display::GetID(manufacturer_id, product_code, output_index);
}
#endif
gfx::Insets GetDefaultDisplayOverscan(const gfx::Display& display) {
// Currently we assume 5% overscan and hope for the best if TV claims it
// overscan, but doesn't expose how much.
int width = display.bounds().width() / 40;
int height = display.bounds().height() / 40;
return gfx::Insets(height, width, height, width);
}
} // namespace
using aura::RootWindow;
using aura::Window;
using std::string;
using std::vector;
DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey,
gfx::Display::kInvalidDisplayID);
DisplayManager::DisplayManager() :
force_bounds_changed_(false) {
Init();
}
DisplayManager::~DisplayManager() {
}
// static
void DisplayManager::CycleDisplay() {
Shell::GetInstance()->display_manager()->CycleDisplayImpl();
}
// static
void DisplayManager::ToggleDisplayScale() {
Shell::GetInstance()->display_manager()->ScaleDisplayImpl();
}
bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const {
for (DisplayList::const_iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
if ((*iter).id() == display.id())
return true;
}
return false;
}
bool DisplayManager::HasInternalDisplay() const {
return gfx::Display::InternalDisplayId() != gfx::Display::kInvalidDisplayID;
}
bool DisplayManager::IsInternalDisplayId(int64 id) const {
return gfx::Display::InternalDisplayId() == id;
}
bool DisplayManager::UpdateWorkAreaOfDisplayNearestWindow(
const aura::Window* window,
const gfx::Insets& insets) {
const RootWindow* root = window->GetRootWindow();
gfx::Display& display = FindDisplayForRootWindow(root);
gfx::Rect old_work_area = display.work_area();
display.UpdateWorkAreaFromInsets(insets);
return old_work_area != display.work_area();
}
const gfx::Display& DisplayManager::GetDisplayForId(int64 id) const {
return const_cast<DisplayManager*>(this)->FindDisplayForId(id);
}
const gfx::Display& DisplayManager::FindDisplayContainingPoint(
const gfx::Point& point_in_screen) const {
for (DisplayList::const_iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
const gfx::Display& display = *iter;
if (display.bounds().Contains(point_in_screen))
return display;
}
return GetInvalidDisplay();
}
void DisplayManager::SetOverscanInsets(int64 display_id,
const gfx::Insets& insets_in_dip) {
display_info_[display_id].overscan_insets_in_dip = insets_in_dip;
display_info_[display_id].has_custom_overscan_insets = true;
// Copies the |displays_| because UpdateDisplays() compares the passed
// displays and its internal |displays_|.
DisplayList displays = displays_;
UpdateDisplays(displays);
}
gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const {
std::map<int64, DisplayInfo>::const_iterator it =
display_info_.find(display_id);
return (it != display_info_.end()) ?
it->second.overscan_insets_in_dip : gfx::Insets();
}
void DisplayManager::OnNativeDisplaysChanged(
const std::vector<gfx::Display>& updated_displays) {
if (updated_displays.empty()) {
// Don't update the displays when all displays are disconnected.
// This happens when:
// - the device is idle and powerd requested to turn off all displays.
// - the device is suspended. (kernel turns off all displays)
// - the internal display's brightness is set to 0 and no external
// display is connected.
// - the internal display's brightness is 0 and external display is
// disconnected.
// The display will be updated when one of displays is turned on, and the
// display list will be updated correctly.
return;
}
DisplayList new_displays = updated_displays;
if (HasInternalDisplay()) {
bool internal_display_connected = false;
for (DisplayList::const_iterator iter = updated_displays.begin();
iter != updated_displays.end(); ++iter) {
if ((*iter).IsInternal()) {
internal_display_connected = true;
// Update the internal display cache.
internal_display_.reset(new gfx::Display);
*internal_display_.get() = *iter;
break;
}
}
// If the internal display wasn't connected, use the cached value.
if (!internal_display_connected) {
// Internal display may be reported as disconnect during startup time.
if (!internal_display_.get()) {
internal_display_.reset(
new gfx::Display(gfx::Display::InternalDisplayId(),
gfx::Rect(800, 600)));
}
new_displays.push_back(*internal_display_.get());
}
} else {
new_displays = updated_displays;
}
RefreshDisplayInfo();
for (DisplayList::const_iterator iter = new_displays.begin();
iter != new_displays.end(); ++iter) {
std::map<int64, DisplayInfo>::iterator info =
display_info_.find(iter->id());
if (info != display_info_.end()) {
info->second.original_bounds_in_pixel = iter->bounds_in_pixel();
if (info->second.has_overscan && !info->second.has_custom_overscan_insets)
info->second.overscan_insets_in_dip = GetDefaultDisplayOverscan(*iter);
} else {
display_info_[iter->id()].original_bounds_in_pixel =
iter->bounds_in_pixel();
}
}
UpdateDisplays(new_displays);
}
void DisplayManager::UpdateDisplays(
const std::vector<gfx::Display>& updated_displays) {
DisplayList new_displays = updated_displays;
#if defined(OS_CHROMEOS)
// Overscan is always enabled when not running on the device
// in order for unit tests to work.
bool can_overscan =
!base::chromeos::IsRunningOnChromeOS() ||
(Shell::GetInstance()->output_configurator()->output_state() !=
chromeos::STATE_DUAL_MIRROR &&
updated_displays.size() == 1);
#else
bool can_overscan = true;
#endif
if (can_overscan) {
for (DisplayList::iterator iter = new_displays.begin();
iter != new_displays.end(); ++iter) {
std::map<int64, DisplayInfo>::const_iterator info =
display_info_.find(iter->id());
if (info != display_info_.end()) {
gfx::Rect bounds = info->second.original_bounds_in_pixel;
bounds.Inset(info->second.overscan_insets_in_dip.Scale(
iter->device_scale_factor()));
iter->SetScaleAndBounds(iter->device_scale_factor(), bounds);
}
}
}
std::sort(displays_.begin(), displays_.end(), DisplaySortFunctor());
std::sort(new_displays.begin(), new_displays.end(), DisplaySortFunctor());
DisplayList removed_displays;
std::vector<size_t> changed_display_indices;
std::vector<size_t> added_display_indices;
gfx::Display current_primary;
if (DisplayController::HasPrimaryDisplay())
current_primary = DisplayController::GetPrimaryDisplay();
for (DisplayList::iterator curr_iter = displays_.begin(),
new_iter = new_displays.begin();
curr_iter != displays_.end() || new_iter != new_displays.end();) {
if (curr_iter == displays_.end()) {
// more displays in new list.
added_display_indices.push_back(new_iter - new_displays.begin());
++new_iter;
} else if (new_iter == new_displays.end()) {
// more displays in current list.
removed_displays.push_back(*curr_iter);
++curr_iter;
} else if ((*curr_iter).id() == (*new_iter).id()) {
const gfx::Display& current_display = *curr_iter;
gfx::Display& new_display = *new_iter;
if (force_bounds_changed_ ||
current_display.bounds_in_pixel() != new_display.bounds_in_pixel() ||
current_display.device_scale_factor() !=
new_display.device_scale_factor()) {
changed_display_indices.push_back(new_iter - new_displays.begin());
}
// If the display is primary, then simpy set the origin to (0,0).
// The secondary display's bounds will be updated by
// |DisplayController::UpdateDisplayBoundsForLayout|, so no need
// to change there.
if ((*new_iter).id() == current_primary.id())
new_display.set_bounds(gfx::Rect(new_display.bounds().size()));
new_display.UpdateWorkAreaFromInsets(current_display.GetWorkAreaInsets());
++curr_iter;
++new_iter;
} else if ((*curr_iter).id() < (*new_iter).id()) {
// more displays in current list between ids, which means it is deleted.
removed_displays.push_back(*curr_iter);
++curr_iter;
} else {
// more displays in new list between ids, which means it is added.
added_display_indices.push_back(new_iter - new_displays.begin());
++new_iter;
}
}
// Do not update |displays_| if there's nothing to be updated. Without this,
// it will not update the display layout, which causes the bug
// http://crbug.com/155948.
if (changed_display_indices.empty() && added_display_indices.empty() &&
removed_displays.empty()) {
return;
}
displays_ = new_displays;
// Temporarily add displays to be removed because display object
// being removed are accessed during shutting down the root.
displays_.insert(displays_.end(), removed_displays.begin(),
removed_displays.end());
for (DisplayList::const_reverse_iterator iter = removed_displays.rbegin();
iter != removed_displays.rend(); ++iter) {
Shell::GetInstance()->screen()->NotifyDisplayRemoved(displays_.back());
displays_.pop_back();
}
for (std::vector<size_t>::iterator iter = added_display_indices.begin();
iter != added_display_indices.end(); ++iter) {
Shell::GetInstance()->screen()->NotifyDisplayAdded(displays_[*iter]);
}
for (std::vector<size_t>::iterator iter = changed_display_indices.begin();
iter != changed_display_indices.end(); ++iter) {
Shell::GetInstance()->screen()->NotifyBoundsChanged(displays_[*iter]);
}
EnsurePointerInDisplays();
#if defined(USE_X11) && defined(OS_CHROMEOS)
if (!changed_display_indices.empty() && base::chromeos::IsRunningOnChromeOS())
ui::ClearX11DefaultRootWindow();
#endif
}
RootWindow* DisplayManager::CreateRootWindowForDisplay(
const gfx::Display& display) {
static int root_window_count = 0;
RootWindow::CreateParams params(display.bounds_in_pixel());
params.host = Shell::GetInstance()->root_window_host_factory()->
CreateRootWindowHost(display.bounds_in_pixel());
aura::RootWindow* root_window = new aura::RootWindow(params);
root_window->SetName(StringPrintf("RootWindow-%d", root_window_count++));
// No need to remove RootWindowObserver because
// the DisplayManager object outlives RootWindow objects.
root_window->AddRootWindowObserver(this);
root_window->SetProperty(kDisplayIdKey, display.id());
root_window->Init();
return root_window;
}
gfx::Display* DisplayManager::GetDisplayAt(size_t index) {
return index < displays_.size() ? &displays_[index] : NULL;
}
size_t DisplayManager::GetNumDisplays() const {
return displays_.size();
}
const gfx::Display& DisplayManager::GetDisplayNearestWindow(
const Window* window) const {
if (!window)
return DisplayController::GetPrimaryDisplay();
const RootWindow* root = window->GetRootWindow();
DisplayManager* manager = const_cast<DisplayManager*>(this);
return root ?
manager->FindDisplayForRootWindow(root) :
DisplayController::GetPrimaryDisplay();
}
const gfx::Display& DisplayManager::GetDisplayNearestPoint(
const gfx::Point& point) const {
// Fallback to the primary display if there is no root display containing
// the |point|.
const gfx::Display& display = FindDisplayContainingPoint(point);
return display.is_valid() ? display : DisplayController::GetPrimaryDisplay();
}
const gfx::Display& DisplayManager::GetDisplayMatching(
const gfx::Rect& rect) const {
if (rect.IsEmpty())
return GetDisplayNearestPoint(rect.origin());
int max = 0;
const gfx::Display* matching = 0;
for (std::vector<gfx::Display>::const_iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
const gfx::Display& display = *iter;
gfx::Rect intersect = gfx::IntersectRects(display.bounds(), rect);
int area = intersect.width() * intersect.height();
if (area > max) {
max = area;
matching = &(*iter);
}
}
// Fallback to the primary display if there is no matching display.
return matching ? *matching : DisplayController::GetPrimaryDisplay();
}
std::string DisplayManager::GetDisplayNameFor(
const gfx::Display& display) {
if (!display.is_valid())
return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME);
std::map<int64, DisplayInfo>::const_iterator iter =
display_info_.find(display.id());
if (iter != display_info_.end() && !iter->second.name.empty())
return iter->second.name;
return base::StringPrintf("Display %d", static_cast<int>(display.id()));
}
void DisplayManager::OnRootWindowResized(const aura::RootWindow* root,
const gfx::Size& old_size) {
bool user_may_change_root = false;
#if defined(OS_CHROMEOS)
user_may_change_root = !base::chromeos::IsRunningOnChromeOS();
#endif
if (user_may_change_root) {
gfx::Display& display = FindDisplayForRootWindow(root);
if (display.size() != root->GetHostSize()) {
display.SetSize(root->GetHostSize());
Shell::GetInstance()->screen()->NotifyBoundsChanged(display);
}
}
}
void DisplayManager::Init() {
#if defined(OS_CHROMEOS)
if (base::chromeos::IsRunningOnChromeOS()) {
std::vector<XID> outputs;
ui::GetOutputDeviceHandles(&outputs);
std::vector<std::string> output_names = ui::GetOutputNames(outputs);
for (size_t i = 0; i < output_names.size(); ++i) {
if (chromeos::OutputConfigurator::IsInternalOutputName(
output_names[i])) {
gfx::Display::SetInternalDisplayId(
GetDisplayIdForOutput(outputs[i], i));
break;
}
}
}
#endif
RefreshDisplayInfo();
// TODO(oshima): Move this logic to DisplayChangeObserver.
const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kAshHostWindowBounds);
vector<string> parts;
base::SplitString(size_str, ',', &parts);
for (vector<string>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter) {
AddDisplayFromSpec(*iter);
}
if (displays_.empty())
AddDisplayFromSpec(std::string() /* default */);
}
void DisplayManager::CycleDisplayImpl() {
DCHECK(!displays_.empty());
std::vector<gfx::Display> new_displays;
new_displays.push_back(DisplayController::GetPrimaryDisplay());
// Add if there is only one display.
if (displays_.size() == 1) {
// Layout the 2nd display below the primary as with the real device.
aura::RootWindow* primary = Shell::GetPrimaryRootWindow();
gfx::Rect host_bounds =
gfx::Rect(primary->GetHostOrigin(), primary->GetHostSize());
new_displays.push_back(CreateDisplayFromSpec(
StringPrintf("%d+%d-500x400", host_bounds.x(), host_bounds.bottom())));
}
OnNativeDisplaysChanged(new_displays);
}
void DisplayManager::ScaleDisplayImpl() {
DCHECK(!displays_.empty());
std::vector<gfx::Display> new_displays;
for (DisplayList::const_iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
gfx::Display display = *iter;
float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f;
gfx::Point display_origin = display.bounds_in_pixel().origin();
gfx::Size display_size = gfx::ToFlooredSize(
gfx::ScaleSize(display.size(), factor));
display.SetScaleAndBounds(factor, gfx::Rect(display_origin, display_size));
new_displays.push_back(display);
}
OnNativeDisplaysChanged(new_displays);
}
gfx::Display& DisplayManager::FindDisplayForRootWindow(
const aura::RootWindow* root_window) {
int64 id = root_window->GetProperty(kDisplayIdKey);
// if id is |kInvaildDisplayID|, it's being deleted.
DCHECK(id != gfx::Display::kInvalidDisplayID);
gfx::Display& display = FindDisplayForId(id);
DCHECK(display.is_valid());
return display;
}
gfx::Display& DisplayManager::FindDisplayForId(int64 id) {
for (DisplayList::iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
if ((*iter).id() == id)
return *iter;
}
DLOG(WARNING) << "Could not find display:" << id;
return GetInvalidDisplay();
}
void DisplayManager::AddDisplayFromSpec(const std::string& spec) {
gfx::Display display = CreateDisplayFromSpec(spec);
const gfx::Insets insets = display.GetWorkAreaInsets();
const gfx::Rect& native_bounds = display.bounds_in_pixel();
display.SetScaleAndBounds(display.device_scale_factor(), native_bounds);
display.UpdateWorkAreaFromInsets(insets);
displays_.push_back(display);
}
int64 DisplayManager::SetFirstDisplayAsInternalDisplayForTest() {
gfx::Display::SetInternalDisplayId(displays_[0].id());
internal_display_.reset(new gfx::Display);
*internal_display_ = displays_[0];
return gfx::Display::InternalDisplayId();
}
void DisplayManager::EnsurePointerInDisplays() {
// Don't try to move the pointer during the boot/startup.
if (!DisplayController::HasPrimaryDisplay())
return;
gfx::Point location_in_screen = Shell::GetScreen()->GetCursorScreenPoint();
gfx::Point target_location;
int64 closest_distance_squared = -1;
for (DisplayList::const_iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
const gfx::Rect& display_bounds = iter->bounds();
if (display_bounds.Contains(location_in_screen)) {
target_location = location_in_screen;
break;
}
gfx::Point center = display_bounds.CenterPoint();
// Use the distance squared from the center of the dislay. This is not
// exactly "closest" display, but good enough to pick one
// appropriate (and there are at most two displays).
// We don't care about actual distance, only relative to other displays, so
// using the LengthSquared() is cheaper than Length().
int64 distance_squared = (center - location_in_screen).LengthSquared();
if (closest_distance_squared < 0 ||
closest_distance_squared > distance_squared) {
target_location = center;
closest_distance_squared = distance_squared;
}
}
aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
aura::client::ScreenPositionClient* client =
aura::client::GetScreenPositionClient(root_window);
client->ConvertPointFromScreen(root_window, &target_location);
root_window->MoveCursorTo(target_location);
}
DisplayManager::DisplayInfo::DisplayInfo()
: has_overscan(false),
has_custom_overscan_insets(false) {
}
void DisplayManager::RefreshDisplayInfo() {
#if defined(OS_CHROMEOS)
if (!base::chromeos::IsRunningOnChromeOS())
return;
#endif
#if defined(USE_X11)
std::vector<XID> outputs;
if (!ui::GetOutputDeviceHandles(&outputs))
return;
for (size_t output_index = 0; output_index < outputs.size(); ++output_index) {
uint16 manufacturer_id = 0;
uint16 product_code = 0;
std::string name;
ui::GetOutputDeviceData(
outputs[output_index], &manufacturer_id, &product_code, &name);
int64 id = gfx::Display::GetID(manufacturer_id, product_code, output_index);
if (IsInternalDisplayId(id)) {
display_info_[id].name =
l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME);
} else if (!name.empty()) {
display_info_[id].name = name;
}
ui::GetOutputOverscanFlag(
outputs[output_index], &display_info_[id].has_overscan);
}
#endif
}
void DisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const {
DisplayList::iterator iter_to_update = to_update->begin();
DisplayList::const_iterator iter = displays_.begin();
for (; iter != displays_.end() && iter_to_update != to_update->end();
++iter, ++iter_to_update) {
(*iter_to_update).set_id((*iter).id());
}
}
void DisplayManager::SetHasOverscanFlagForTest(int64 id, bool has_overscan) {
display_info_[id].has_overscan = has_overscan;
}
gfx::Display CreateDisplayFromSpec(const std::string& spec) {
static int64 synthesized_display_id = 1000;
#if defined(OS_WIN)
gfx::Rect bounds(aura::RootWindowHost::GetNativeScreenSize());
#else
gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY,
kDefaultHostWindowWidth, kDefaultHostWindowHeight);
#endif
int x = 0, y = 0, width, height;
float scale = 1.0f;
if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2 ||
sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height,
&scale) >= 4) {
bounds.SetRect(x, y, width, height);
}
gfx::Display display(synthesized_display_id++);
display.SetScaleAndBounds(scale, bounds);
DVLOG(1) << "Display bounds=" << bounds.ToString() << ", scale=" << scale;
return display;
}
} // namespace internal
} // namespace ash
|