| 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 "ash/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 bool operator()(const DisplayInfo& a, const DisplayInfo& b) { | 70 bool operator()(const DisplayInfo& a, const DisplayInfo& b) { |
| 71 return a.id() < b.id(); | 71 return a.id() < b.id(); |
| 72 } | 72 } |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 gfx::Display& GetInvalidDisplay() { | 75 gfx::Display& GetInvalidDisplay() { |
| 76 static gfx::Display* invalid_display = new gfx::Display(); | 76 static gfx::Display* invalid_display = new gfx::Display(); |
| 77 return *invalid_display; | 77 return *invalid_display; |
| 78 } | 78 } |
| 79 | 79 |
| 80 #if defined(OS_CHROMEOS) | |
| 81 | |
| 82 int64 FindInternalDisplayID() { | |
| 83 std::vector<XID> outputs; | |
| 84 ui::GetOutputDeviceHandles(&outputs); | |
| 85 std::vector<std::string> output_names = ui::GetOutputNames(outputs); | |
| 86 for (size_t i = 0; i < output_names.size(); ++i) { | |
| 87 if (chromeos::OutputConfigurator::IsInternalOutputName( | |
| 88 output_names[i])) { | |
| 89 uint16 manufacturer_id = 0; | |
| 90 uint16 product_code = 0; | |
| 91 ui::GetOutputDeviceData( | |
| 92 outputs[i], &manufacturer_id, &product_code, NULL); | |
| 93 return gfx::Display::GetID(manufacturer_id, product_code, i); | |
| 94 } | |
| 95 } | |
| 96 return gfx::Display::kInvalidDisplayID; | |
| 97 } | |
| 98 | |
| 99 #endif | |
| 100 | |
| 101 } // namespace | 80 } // namespace |
| 102 | 81 |
| 103 using aura::RootWindow; | 82 using aura::RootWindow; |
| 104 using aura::Window; | 83 using aura::Window; |
| 105 using std::string; | 84 using std::string; |
| 106 using std::vector; | 85 using std::vector; |
| 107 | 86 |
| 108 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, | 87 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, |
| 109 gfx::Display::kInvalidDisplayID); | 88 gfx::Display::kInvalidDisplayID); |
| 110 | 89 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 if (display.size() != root->GetHostSize()) { | 449 if (display.size() != root->GetHostSize()) { |
| 471 display.SetSize(root->GetHostSize()); | 450 display.SetSize(root->GetHostSize()); |
| 472 display_info_[display.id()].UpdateBounds( | 451 display_info_[display.id()].UpdateBounds( |
| 473 gfx::Rect(root->GetHostOrigin(), root->GetHostSize())); | 452 gfx::Rect(root->GetHostOrigin(), root->GetHostSize())); |
| 474 Shell::GetInstance()->screen()->NotifyBoundsChanged(display); | 453 Shell::GetInstance()->screen()->NotifyBoundsChanged(display); |
| 475 } | 454 } |
| 476 } | 455 } |
| 477 } | 456 } |
| 478 | 457 |
| 479 void DisplayManager::Init() { | 458 void DisplayManager::Init() { |
| 480 #if defined(OS_CHROMEOS) | |
| 481 if (base::chromeos::IsRunningOnChromeOS()) | |
| 482 gfx::Display::SetInternalDisplayId(FindInternalDisplayID()); | |
| 483 #endif | |
| 484 | |
| 485 // TODO(oshima): Move this logic to DisplayChangeObserver. | 459 // TODO(oshima): Move this logic to DisplayChangeObserver. |
| 486 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 460 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 487 switches::kAshHostWindowBounds); | 461 switches::kAshHostWindowBounds); |
| 488 vector<string> parts; | 462 vector<string> parts; |
| 489 base::SplitString(size_str, ',', &parts); | 463 base::SplitString(size_str, ',', &parts); |
| 490 for (vector<string>::const_iterator iter = parts.begin(); | 464 for (vector<string>::const_iterator iter = parts.begin(); |
| 491 iter != parts.end(); ++iter) { | 465 iter != parts.end(); ++iter) { |
| 492 AddDisplayFromSpec(*iter); | 466 AddDisplayFromSpec(*iter); |
| 493 } | 467 } |
| 494 if (displays_.empty()) | 468 if (displays_.empty()) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 // to change there. | 590 // to change there. |
| 617 if (DisplayController::HasPrimaryDisplay() && | 591 if (DisplayController::HasPrimaryDisplay() && |
| 618 display_info.id() == DisplayController::GetPrimaryDisplay().id()) { | 592 display_info.id() == DisplayController::GetPrimaryDisplay().id()) { |
| 619 new_display.set_bounds(gfx::Rect(new_display.bounds().size())); | 593 new_display.set_bounds(gfx::Rect(new_display.bounds().size())); |
| 620 } | 594 } |
| 621 return new_display; | 595 return new_display; |
| 622 } | 596 } |
| 623 | 597 |
| 624 } // namespace internal | 598 } // namespace internal |
| 625 } // namespace ash | 599 } // namespace ash |
| OLD | NEW |