| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_util.h" | 5 #include "ash/display/display_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/new_window_delegate.h" | 9 #include "ash/common/new_window_delegate.h" |
| 10 #include "ash/common/system/system_notifier.h" | 10 #include "ash/common/system/system_notifier.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/display/display_manager.h" | 12 #include "ash/display/display_manager.h" |
| 13 |
| 14 #include "ash/display/extended_mouse_warp_controller.h" |
| 15 #include "ash/display/null_mouse_warp_controller.h" |
| 16 #include "ash/display/unified_mouse_warp_controller.h" |
| 17 |
| 13 #include "ash/host/ash_window_tree_host.h" | 18 #include "ash/host/ash_window_tree_host.h" |
| 14 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 15 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 16 #include "grit/ash_resources.h" | 21 #include "grit/ash_resources.h" |
| 17 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
| 18 #include "ui/aura/window_tree_host.h" | 23 #include "ui/aura/window_tree_host.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/display/display.h" | 26 #include "ui/display/display.h" |
| 22 #include "ui/display/manager/managed_display_info.h" | 27 #include "ui/display/manager/managed_display_info.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 [ui_scale](const scoped_refptr<display::ManagedDisplayMode>& mode) { | 81 [ui_scale](const scoped_refptr<display::ManagedDisplayMode>& mode) { |
| 77 return mode->ui_scale() == ui_scale; | 82 return mode->ui_scale() == ui_scale; |
| 78 }); | 83 }); |
| 79 if (iter == modes.end()) | 84 if (iter == modes.end()) |
| 80 return scoped_refptr<display::ManagedDisplayMode>(); | 85 return scoped_refptr<display::ManagedDisplayMode>(); |
| 81 return *iter; | 86 return *iter; |
| 82 } | 87 } |
| 83 | 88 |
| 84 } // namespace | 89 } // namespace |
| 85 | 90 |
| 91 std::unique_ptr<MouseWarpController> CreateMouseWarpController( |
| 92 DisplayManager* manager, |
| 93 aura::Window* drag_source) { |
| 94 if (manager->IsInUnifiedMode() && manager->num_connected_displays() >= 2) |
| 95 return base::MakeUnique<UnifiedMouseWarpController>(); |
| 96 // Extra check for |num_connected_displays()| is for SystemDisplayApiTest |
| 97 // that injects MockScreen. |
| 98 if (manager->GetNumDisplays() < 2 || manager->num_connected_displays() < 2) |
| 99 return base::MakeUnique<NullMouseWarpController>(); |
| 100 return base::MakeUnique<ExtendedMouseWarpController>(drag_source); |
| 101 } |
| 102 |
| 86 bool SetDisplayUIScale(int64_t id, float ui_scale) { | 103 bool SetDisplayUIScale(int64_t id, float ui_scale) { |
| 87 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 104 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 88 if (!display_manager->IsActiveDisplayId(id) || | 105 if (!display_manager->IsActiveDisplayId(id) || |
| 89 !display::Display::IsInternalDisplayId(id)) { | 106 !display::Display::IsInternalDisplayId(id)) { |
| 90 return false; | 107 return false; |
| 91 } | 108 } |
| 92 const display::ManagedDisplayInfo& info = display_manager->GetDisplayInfo(id); | 109 const display::ManagedDisplayInfo& info = display_manager->GetDisplayInfo(id); |
| 93 | 110 |
| 94 scoped_refptr<display::ManagedDisplayMode> mode = | 111 scoped_refptr<display::ManagedDisplayMode> mode = |
| 95 GetDisplayModeForUIScale(info, ui_scale); | 112 GetDisplayModeForUIScale(info, ui_scale); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 message_center::NotificationList::Notifications notifications = | 222 message_center::NotificationList::Notifications notifications = |
| 206 message_center::MessageCenter::Get()->GetVisibleNotifications(); | 223 message_center::MessageCenter::Get()->GetVisibleNotifications(); |
| 207 for (auto* const notification : notifications) { | 224 for (auto* const notification : notifications) { |
| 208 if (notification->id() == kDisplayErrorNotificationId) | 225 if (notification->id() == kDisplayErrorNotificationId) |
| 209 return notification->message(); | 226 return notification->message(); |
| 210 } | 227 } |
| 211 return base::string16(); | 228 return base::string16(); |
| 212 } | 229 } |
| 213 | 230 |
| 214 } // namespace ash | 231 } // namespace ash |
| OLD | NEW |