Chromium Code Reviews| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 observers_.RemoveObserver(observer); | 321 observers_.RemoveObserver(observer); |
| 322 } | 322 } |
| 323 | 323 |
| 324 // static | 324 // static |
| 325 int64_t WindowTreeHostManager::GetPrimaryDisplayId() { | 325 int64_t WindowTreeHostManager::GetPrimaryDisplayId() { |
| 326 CHECK_NE(display::kInvalidDisplayId, primary_display_id); | 326 CHECK_NE(display::kInvalidDisplayId, primary_display_id); |
| 327 return primary_display_id; | 327 return primary_display_id; |
| 328 } | 328 } |
| 329 | 329 |
| 330 aura::Window* WindowTreeHostManager::GetPrimaryRootWindow() { | 330 aura::Window* WindowTreeHostManager::GetPrimaryRootWindow() { |
| 331 // If |primary_tree_host_for_replace_| is set, it means |primary_display_id| | |
| 332 // is kInvalidDisplayId. | |
| 333 if (primary_tree_host_for_replace_) | |
| 334 return GetWindow(primary_tree_host_for_replace_); | |
| 331 return GetRootWindowForDisplayId(primary_display_id); | 335 return GetRootWindowForDisplayId(primary_display_id); |
| 332 } | 336 } |
| 333 | 337 |
| 334 aura::Window* WindowTreeHostManager::GetRootWindowForDisplayId(int64_t id) { | 338 aura::Window* WindowTreeHostManager::GetRootWindowForDisplayId(int64_t id) { |
| 335 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); | 339 AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); |
| 336 return host ? GetWindow(host) : nullptr; | 340 return host ? GetWindow(host) : nullptr; |
| 337 } | 341 } |
| 338 | 342 |
| 339 AshWindowTreeHost* WindowTreeHostManager::GetAshWindowTreeHostForDisplayId( | 343 AshWindowTreeHost* WindowTreeHostManager::GetAshWindowTreeHostForDisplayId( |
| 340 int64_t display_id) { | 344 int64_t display_id) { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 } | 629 } |
| 626 | 630 |
| 627 void WindowTreeHostManager::DeleteHost(AshWindowTreeHost* host_to_delete) { | 631 void WindowTreeHostManager::DeleteHost(AshWindowTreeHost* host_to_delete) { |
| 628 ClearDisplayPropertiesOnHost(host_to_delete); | 632 ClearDisplayPropertiesOnHost(host_to_delete); |
| 629 RootWindowController* controller = | 633 RootWindowController* controller = |
| 630 GetRootWindowController(GetWindow(host_to_delete)); | 634 GetRootWindowController(GetWindow(host_to_delete)); |
| 631 DCHECK(controller); | 635 DCHECK(controller); |
| 632 controller->MoveWindowsTo(GetPrimaryRootWindow()); | 636 controller->MoveWindowsTo(GetPrimaryRootWindow()); |
| 633 // Delete most of root window related objects, but don't delete | 637 // Delete most of root window related objects, but don't delete |
| 634 // root window itself yet because the stack may be using it. | 638 // root window itself yet because the stack may be using it. |
| 635 controller->Shutdown(); | 639 controller->Shutdown(); |
|
oshima
2017/05/12 00:19:21
can you reset the primary_tree_host_for_replace_ i
wutao
2017/05/12 00:43:57
Done.
| |
| 636 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, controller); | 640 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, controller); |
| 637 } | 641 } |
| 638 | 642 |
| 639 void WindowTreeHostManager::OnDisplayRemoved(const display::Display& display) { | 643 void WindowTreeHostManager::OnDisplayRemoved(const display::Display& display) { |
| 640 AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()]; | 644 AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()]; |
| 641 CHECK(host_to_delete) << display.ToString(); | 645 CHECK(host_to_delete) << display.ToString(); |
| 642 | 646 |
| 643 // When the primary root window's display is removed, move the primary | 647 // When the primary root window's display is removed, move the primary |
| 644 // root to the other display. | 648 // root to the other display. |
| 645 if (primary_display_id == display.id()) { | 649 if (primary_display_id == display.id()) { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 | 859 |
| 856 window_tree_hosts_[display.id()] = ash_host; | 860 window_tree_hosts_[display.id()] = ash_host; |
| 857 SetDisplayPropertiesOnHost(ash_host, display); | 861 SetDisplayPropertiesOnHost(ash_host, display); |
| 858 | 862 |
| 859 if (switches::ConstrainPointerToRoot()) | 863 if (switches::ConstrainPointerToRoot()) |
| 860 ash_host->ConfineCursorToRootWindow(); | 864 ash_host->ConfineCursorToRootWindow(); |
| 861 return ash_host; | 865 return ash_host; |
| 862 } | 866 } |
| 863 | 867 |
| 864 } // namespace ash | 868 } // namespace ash |
| OLD | NEW |