| 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/window_tree_host_manager.h" | 5 #include "ash/display/window_tree_host_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 CHECK_NE(display::Display::kInvalidDisplayID, primary_display_id); | 325 CHECK_NE(display::Display::kInvalidDisplayID, primary_display_id); |
| 326 return primary_display_id; | 326 return primary_display_id; |
| 327 } | 327 } |
| 328 | 328 |
| 329 aura::Window* WindowTreeHostManager::GetPrimaryRootWindow() { | 329 aura::Window* WindowTreeHostManager::GetPrimaryRootWindow() { |
| 330 return GetRootWindowForDisplayId(primary_display_id); | 330 return GetRootWindowForDisplayId(primary_display_id); |
| 331 } | 331 } |
| 332 | 332 |
| 333 aura::Window* WindowTreeHostManager::GetRootWindowForDisplayId(int64_t id) { | 333 aura::Window* WindowTreeHostManager::GetRootWindowForDisplayId(int64_t id) { |
| 334 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); | 334 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); |
| 335 CHECK(host); | 335 return host ? GetWindow(host) : nullptr; |
| 336 return GetWindow(host); | |
| 337 } | 336 } |
| 338 | 337 |
| 339 AshWindowTreeHost* WindowTreeHostManager::GetAshWindowTreeHostForDisplayId( | 338 AshWindowTreeHost* WindowTreeHostManager::GetAshWindowTreeHostForDisplayId( |
| 340 int64_t display_id) { | 339 int64_t display_id) { |
| 341 CHECK_EQ(1u, window_tree_hosts_.count(display_id)) << "display id = " | 340 const auto host = window_tree_hosts_.find(display_id); |
| 342 << display_id; | 341 return host == window_tree_hosts_.end() ? nullptr : host->second; |
| 343 return window_tree_hosts_[display_id]; | |
| 344 } | 342 } |
| 345 | 343 |
| 346 void WindowTreeHostManager::CloseChildWindows() { | 344 void WindowTreeHostManager::CloseChildWindows() { |
| 347 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); | 345 for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); |
| 348 it != window_tree_hosts_.end(); ++it) { | 346 it != window_tree_hosts_.end(); ++it) { |
| 349 aura::Window* root_window = GetWindow(it->second); | 347 aura::Window* root_window = GetWindow(it->second); |
| 350 RootWindowController* controller = GetRootWindowController(root_window); | 348 RootWindowController* controller = GetRootWindowController(root_window); |
| 351 if (controller) { | 349 if (controller) { |
| 352 controller->CloseChildWindows(); | 350 controller->CloseChildWindows(); |
| 353 } else { | 351 } else { |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 SetDisplayPropertiesOnHost(ash_host, display); | 860 SetDisplayPropertiesOnHost(ash_host, display); |
| 863 | 861 |
| 864 #if defined(OS_CHROMEOS) | 862 #if defined(OS_CHROMEOS) |
| 865 if (switches::ConstrainPointerToRoot()) | 863 if (switches::ConstrainPointerToRoot()) |
| 866 ash_host->ConfineCursorToRootWindow(); | 864 ash_host->ConfineCursorToRootWindow(); |
| 867 #endif | 865 #endif |
| 868 return ash_host; | 866 return ash_host; |
| 869 } | 867 } |
| 870 | 868 |
| 871 } // namespace ash | 869 } // namespace ash |
| OLD | NEW |