| 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/multi_display_manager.h" | 5 #include "ash/display/multi_display_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 aura::Env::GetInstance()->display_manager()); | 71 aura::Env::GetInstance()->display_manager()); |
| 72 manager->ScaleDisplayImpl(); | 72 manager->ScaleDisplayImpl(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void MultiDisplayManager::InitInternalDisplayInfo() { | 75 void MultiDisplayManager::InitInternalDisplayInfo() { |
| 76 #if defined(OS_CHROMEOS) | 76 #if defined(OS_CHROMEOS) |
| 77 if (!base::chromeos::IsRunningOnChromeOS()) | 77 if (!base::chromeos::IsRunningOnChromeOS()) |
| 78 return; | 78 return; |
| 79 std::vector<XID> outputs; | 79 std::vector<XID> outputs; |
| 80 ui::GetOutputDeviceHandles(&outputs); | 80 ui::GetOutputDeviceHandles(&outputs); |
| 81 std::vector<std::string> output_names = ui::GetOutputNames(outputs); | 81 // Output names are hardware specific and never changes. |
| 82 for (size_t i = 0; i < output_names.size(); ++i) { | 82 output_names_ = ui::GetOutputNames(outputs); |
| 83 for (size_t i = 0; i < output_names_.size(); ++i) { |
| 83 if (chromeos::OutputConfigurator::IsInternalOutputName( | 84 if (chromeos::OutputConfigurator::IsInternalOutputName( |
| 84 output_names[i])) { | 85 output_names_[i])) { |
| 86 // Set internal as primary by default. This may be |
| 87 // overritten by settings later. |
| 88 primary_output_name_ = output_names_[i]; |
| 85 XID internal_output = outputs[i]; | 89 XID internal_output = outputs[i]; |
| 86 uint16 manufacturer_id = 0; | 90 uint16 manufacturer_id = 0; |
| 87 uint32 serial_number = 0; | 91 uint32 serial_number = 0; |
| 88 ui::GetOutputDeviceData( | 92 ui::GetOutputDeviceData( |
| 89 internal_output, &manufacturer_id, &serial_number, NULL); | 93 internal_output, &manufacturer_id, &serial_number, NULL); |
| 90 internal_display_id_ = | 94 internal_display_id_ = |
| 91 gfx::Display::GetID(manufacturer_id, serial_number); | 95 gfx::Display::GetID(manufacturer_id, serial_number); |
| 92 return; | 96 return; |
| 93 } | 97 } |
| 94 } | 98 } |
| 95 #endif | 99 #endif |
| 96 } | 100 } |
| 97 | 101 |
| 102 void MultiDisplayManager::SetOutputNameForPrimaryDisplay( |
| 103 const std::string& name) { |
| 104 primary_output_name_ = name; |
| 105 std::vector<gfx::Display> update = displays_; |
| 106 OnNativeDisplaysChanged(displays_); |
| 107 } |
| 108 |
| 98 bool MultiDisplayManager::HasInternalDisplay() const { | 109 bool MultiDisplayManager::HasInternalDisplay() const { |
| 99 return internal_display_id_ != gfx::Display::kInvalidDisplayID; | 110 return internal_display_id_ != gfx::Display::kInvalidDisplayID; |
| 100 } | 111 } |
| 101 | 112 |
| 102 bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow( | 113 bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow( |
| 103 const aura::Window* window, | 114 const aura::Window* window, |
| 104 const gfx::Insets& insets) { | 115 const gfx::Insets& insets) { |
| 105 const RootWindow* root = window->GetRootWindow(); | 116 const RootWindow* root = window->GetRootWindow(); |
| 106 gfx::Display& display = FindDisplayForRootWindow(root); | 117 gfx::Display& display = FindDisplayForRootWindow(root); |
| 107 gfx::Rect old_work_area = display.work_area(); | 118 gfx::Rect old_work_area = display.work_area(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 160 } |
| 150 } | 161 } |
| 151 // If the internal display wasn't connected, use the cached value. | 162 // If the internal display wasn't connected, use the cached value. |
| 152 if (!internal_display_connected) | 163 if (!internal_display_connected) |
| 153 new_displays.push_back(*internal_display_.get()); | 164 new_displays.push_back(*internal_display_.get()); |
| 154 new_displays.insert( | 165 new_displays.insert( |
| 155 new_displays.end(), updated_displays.begin(), updated_displays.end()); | 166 new_displays.end(), updated_displays.begin(), updated_displays.end()); |
| 156 } else { | 167 } else { |
| 157 new_displays = updated_displays; | 168 new_displays = updated_displays; |
| 158 } | 169 } |
| 170 // Move the primary display to the first if any. |
| 171 MovePrimaryToFirst(); |
| 159 | 172 |
| 160 size_t min = std::min(displays_.size(), new_displays.size()); | 173 size_t min = std::min(displays_.size(), new_displays.size()); |
| 161 | 174 |
| 162 // TODO(oshima): Fix this so that we can differentiate outputs | 175 // TODO(oshima): Fix this so that we can differentiate outputs |
| 163 // and keep a content on one display stays on the same display | 176 // and keep a content on one display stays on the same display |
| 164 // when a display is added or removed. | 177 // when a display is added or removed. |
| 165 for (size_t i = 0; i < min; ++i) { | 178 for (size_t i = 0; i < min; ++i) { |
| 166 gfx::Display& current_display = displays_[i]; | 179 gfx::Display& current_display = displays_[i]; |
| 167 const gfx::Display& new_display = new_displays[i]; | 180 const gfx::Display& new_display = new_displays[i]; |
| 168 if (current_display.bounds_in_pixel() != new_display.bounds_in_pixel() || | 181 if (current_display.bounds_in_pixel() != new_display.bounds_in_pixel() || |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 int64 MultiDisplayManager::EnableInternalDisplayForTest() { | 374 int64 MultiDisplayManager::EnableInternalDisplayForTest() { |
| 362 const int64 kInternalDisplayIdForTest = 9999; | 375 const int64 kInternalDisplayIdForTest = 9999; |
| 363 internal_display_id_ = kInternalDisplayIdForTest; | 376 internal_display_id_ = kInternalDisplayIdForTest; |
| 364 internal_display_.reset(new gfx::Display(internal_display_id_, | 377 internal_display_.reset(new gfx::Display(internal_display_id_, |
| 365 gfx::Rect(800, 600))); | 378 gfx::Rect(800, 600))); |
| 366 return kInternalDisplayIdForTest; | 379 return kInternalDisplayIdForTest; |
| 367 } | 380 } |
| 368 | 381 |
| 369 } // namespace internal | 382 } // namespace internal |
| 370 } // namespace ash | 383 } // namespace ash |
| OLD | NEW |