Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: ash/display/window_tree_host_manager.cc

Issue 2870253006: Fix WindowTreeHostManager::GetPrimaryRootWindow. (Closed)
Patch Set: Reset primary_tree_host_for_replace_. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
640 if (primary_tree_host_for_replace_ == host_to_delete)
641 primary_tree_host_for_replace_ = nullptr;
636 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, controller); 642 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, controller);
637 } 643 }
638 644
639 void WindowTreeHostManager::OnDisplayRemoved(const display::Display& display) { 645 void WindowTreeHostManager::OnDisplayRemoved(const display::Display& display) {
640 AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()]; 646 AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()];
641 CHECK(host_to_delete) << display.ToString(); 647 CHECK(host_to_delete) << display.ToString();
642 648
643 // When the primary root window's display is removed, move the primary 649 // When the primary root window's display is removed, move the primary
644 // root to the other display. 650 // root to the other display.
645 if (primary_display_id == display.id()) { 651 if (primary_display_id == display.id()) {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 861
856 window_tree_hosts_[display.id()] = ash_host; 862 window_tree_hosts_[display.id()] = ash_host;
857 SetDisplayPropertiesOnHost(ash_host, display); 863 SetDisplayPropertiesOnHost(ash_host, display);
858 864
859 if (switches::ConstrainPointerToRoot()) 865 if (switches::ConstrainPointerToRoot())
860 ash_host->ConfineCursorToRootWindow(); 866 ash_host->ConfineCursorToRootWindow();
861 return ash_host; 867 return ash_host;
862 } 868 }
863 869
864 } // namespace ash 870 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698