| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "ash/ash_switches.h" | 14 #include "ash/ash_switches.h" |
| 15 #include "ash/display/display_layout_store.h" | 15 #include "ash/display/display_layout_store.h" |
| 16 #include "ash/display/display_util.h" | 16 #include "ash/display/display_util.h" |
| 17 #include "ash/display/extended_mouse_warp_controller.h" | 17 #include "ash/display/extended_mouse_warp_controller.h" |
| 18 #include "ash/display/null_mouse_warp_controller.h" | 18 #include "ash/display/null_mouse_warp_controller.h" |
| 19 #include "ash/display/screen_ash.h" | 19 #include "ash/display/screen_ash.h" |
| 20 #include "ash/display/unified_mouse_warp_controller.h" | 20 #include "ash/display/unified_mouse_warp_controller.h" |
| 21 #include "ash/screen_util.h" | 21 #include "ash/screen_util.h" |
| 22 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 23 #include "base/auto_reset.h" | 23 #include "base/auto_reset.h" |
| 24 #include "base/command_line.h" | 24 #include "base/command_line.h" |
| 25 #include "base/logging.h" | 25 #include "base/logging.h" |
| 26 #include "base/memory/ptr_util.h" |
| 26 #include "base/metrics/histogram.h" | 27 #include "base/metrics/histogram.h" |
| 27 #include "base/run_loop.h" | 28 #include "base/run_loop.h" |
| 28 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
| 29 #include "base/strings/string_split.h" | 30 #include "base/strings/string_split.h" |
| 30 #include "base/strings/stringprintf.h" | 31 #include "base/strings/stringprintf.h" |
| 31 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
| 32 #include "base/thread_task_runner_handle.h" | 33 #include "base/thread_task_runner_handle.h" |
| 33 #include "grit/ash_strings.h" | 34 #include "grit/ash_strings.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/gfx/display.h" | 36 #include "ui/gfx/display.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 236 } |
| 236 int64_t ids[] = {active_display_list_[0].id(), mirroring_display_id_}; | 237 int64_t ids[] = {active_display_list_[0].id(), mirroring_display_id_}; |
| 237 return ash::GenerateDisplayIdList(std::begin(ids), std::end(ids)); | 238 return ash::GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 238 } else { | 239 } else { |
| 239 CHECK_LE(2u, active_display_list_.size()); | 240 CHECK_LE(2u, active_display_list_.size()); |
| 240 return CreateDisplayIdList(active_display_list_); | 241 return CreateDisplayIdList(active_display_list_); |
| 241 } | 242 } |
| 242 } | 243 } |
| 243 | 244 |
| 244 void DisplayManager::SetLayoutForCurrentDisplays( | 245 void DisplayManager::SetLayoutForCurrentDisplays( |
| 245 scoped_ptr<display::DisplayLayout> layout) { | 246 std::unique_ptr<display::DisplayLayout> layout) { |
| 246 if (GetNumDisplays() == 1) | 247 if (GetNumDisplays() == 1) |
| 247 return; | 248 return; |
| 248 const display::DisplayIdList list = GetCurrentDisplayIdList(); | 249 const display::DisplayIdList list = GetCurrentDisplayIdList(); |
| 249 | 250 |
| 250 DCHECK(display::DisplayLayout::Validate(list, *layout)); | 251 DCHECK(display::DisplayLayout::Validate(list, *layout)); |
| 251 | 252 |
| 252 const display::DisplayLayout& current_layout = | 253 const display::DisplayLayout& current_layout = |
| 253 layout_store_->GetRegisteredDisplayLayout(list); | 254 layout_store_->GetRegisteredDisplayLayout(list); |
| 254 | 255 |
| 255 if (layout->HasSamePlacementList(current_layout)) | 256 if (layout->HasSamePlacementList(current_layout)) |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 // Do not post a task if the software mirroring doesn't exist, or | 1042 // Do not post a task if the software mirroring doesn't exist, or |
| 1042 // during initialization when compositor's init task isn't posted yet. | 1043 // during initialization when compositor's init task isn't posted yet. |
| 1043 // ash::Shell::Init() will call this after the compositor is initialized. | 1044 // ash::Shell::Init() will call this after the compositor is initialized. |
| 1044 if (software_mirroring_display_list_.empty() || !delegate_) | 1045 if (software_mirroring_display_list_.empty() || !delegate_) |
| 1045 return; | 1046 return; |
| 1046 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1047 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1047 FROM_HERE, base::Bind(&DisplayManager::CreateMirrorWindowIfAny, | 1048 FROM_HERE, base::Bind(&DisplayManager::CreateMirrorWindowIfAny, |
| 1048 weak_ptr_factory_.GetWeakPtr())); | 1049 weak_ptr_factory_.GetWeakPtr())); |
| 1049 } | 1050 } |
| 1050 | 1051 |
| 1051 scoped_ptr<MouseWarpController> DisplayManager::CreateMouseWarpController( | 1052 std::unique_ptr<MouseWarpController> DisplayManager::CreateMouseWarpController( |
| 1052 aura::Window* drag_source) const { | 1053 aura::Window* drag_source) const { |
| 1053 if (IsInUnifiedMode() && num_connected_displays() >= 2) | 1054 if (IsInUnifiedMode() && num_connected_displays() >= 2) |
| 1054 return make_scoped_ptr(new UnifiedMouseWarpController()); | 1055 return base::WrapUnique(new UnifiedMouseWarpController()); |
| 1055 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest | 1056 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest |
| 1056 // that injects MockScreen. | 1057 // that injects MockScreen. |
| 1057 if (GetNumDisplays() < 2 || num_connected_displays() < 2) | 1058 if (GetNumDisplays() < 2 || num_connected_displays() < 2) |
| 1058 return make_scoped_ptr(new NullMouseWarpController()); | 1059 return base::WrapUnique(new NullMouseWarpController()); |
| 1059 return make_scoped_ptr(new ExtendedMouseWarpController(drag_source)); | 1060 return base::WrapUnique(new ExtendedMouseWarpController(drag_source)); |
| 1060 } | 1061 } |
| 1061 | 1062 |
| 1062 void DisplayManager::CreateScreenForShutdown() const { | 1063 void DisplayManager::CreateScreenForShutdown() const { |
| 1063 delete screen_for_shutdown; | 1064 delete screen_for_shutdown; |
| 1064 screen_for_shutdown = screen_->CloneForShutdown(); | 1065 screen_for_shutdown = screen_->CloneForShutdown(); |
| 1065 gfx::Screen::SetScreenInstance(screen_for_shutdown); | 1066 gfx::Screen::SetScreenInstance(screen_for_shutdown); |
| 1066 } | 1067 } |
| 1067 | 1068 |
| 1068 void DisplayManager::UpdateInternalDisplayModeListForTest() { | 1069 void DisplayManager::UpdateInternalDisplayModeListForTest() { |
| 1069 if (!gfx::Display::HasInternalDisplay() || | 1070 if (!gfx::Display::HasInternalDisplay() || |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 | 1399 |
| 1399 return old_bounds != target_display->bounds(); | 1400 return old_bounds != target_display->bounds(); |
| 1400 } | 1401 } |
| 1401 | 1402 |
| 1402 void DisplayManager::RunPendingTasksForTest() { | 1403 void DisplayManager::RunPendingTasksForTest() { |
| 1403 if (!software_mirroring_display_list_.empty()) | 1404 if (!software_mirroring_display_list_.empty()) |
| 1404 base::RunLoop().RunUntilIdle(); | 1405 base::RunLoop().RunUntilIdle(); |
| 1405 } | 1406 } |
| 1406 | 1407 |
| 1407 } // namespace ash | 1408 } // namespace ash |
| OLD | NEW |