| 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/common/wm/always_on_top_controller.h" | 5 #include "ash/common/wm/always_on_top_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/workspace/workspace_layout_manager.h" | 7 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 8 #include "ash/common/wm_window.h" | 8 #include "ash/common/wm_window.h" |
| 9 #include "ash/common/wm_window_property.h" | |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 11 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 12 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
| 13 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 14 | 13 |
| 15 namespace ash { | 14 namespace ash { |
| 16 | 15 |
| 17 AlwaysOnTopController::AlwaysOnTopController(WmWindow* viewport) | 16 AlwaysOnTopController::AlwaysOnTopController(WmWindow* viewport) |
| 18 : always_on_top_container_(viewport) { | 17 : always_on_top_container_(viewport) { |
| 19 DCHECK_NE(kShellWindowId_DefaultContainer, viewport->GetShellWindowId()); | 18 DCHECK_NE(kShellWindowId_DefaultContainer, viewport->GetShellWindowId()); |
| 20 always_on_top_container_->SetLayoutManager( | 19 always_on_top_container_->SetLayoutManager( |
| 21 base::MakeUnique<WorkspaceLayoutManager>(viewport)); | 20 base::MakeUnique<WorkspaceLayoutManager>(viewport)); |
| 22 // Container should be empty. | 21 // Container should be empty. |
| 23 DCHECK(always_on_top_container_->GetChildren().empty()); | 22 DCHECK(always_on_top_container_->GetChildren().empty()); |
| 24 always_on_top_container_->aura_window()->AddObserver(this); | 23 always_on_top_container_->aura_window()->AddObserver(this); |
| 25 } | 24 } |
| 26 | 25 |
| 27 AlwaysOnTopController::~AlwaysOnTopController() { | 26 AlwaysOnTopController::~AlwaysOnTopController() { |
| 28 if (always_on_top_container_) | 27 if (always_on_top_container_) |
| 29 always_on_top_container_->aura_window()->RemoveObserver(this); | 28 always_on_top_container_->aura_window()->RemoveObserver(this); |
| 30 } | 29 } |
| 31 | 30 |
| 32 WmWindow* AlwaysOnTopController::GetContainer(WmWindow* window) const { | 31 WmWindow* AlwaysOnTopController::GetContainer(WmWindow* window) const { |
| 33 DCHECK(always_on_top_container_); | 32 DCHECK(always_on_top_container_); |
| 34 if (window->GetBoolProperty(WmWindowProperty::ALWAYS_ON_TOP)) | 33 if (window->aura_window()->GetProperty(aura::client::kAlwaysOnTopKey)) |
| 35 return always_on_top_container_; | 34 return always_on_top_container_; |
| 36 return always_on_top_container_->GetRootWindow()->GetChildByShellWindowId( | 35 return always_on_top_container_->GetRootWindow()->GetChildByShellWindowId( |
| 37 kShellWindowId_DefaultContainer); | 36 kShellWindowId_DefaultContainer); |
| 38 } | 37 } |
| 39 | 38 |
| 40 // TODO(rsadam@): Refactor so that this cast is unneeded. | 39 // TODO(rsadam@): Refactor so that this cast is unneeded. |
| 41 WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const { | 40 WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const { |
| 42 return static_cast<WorkspaceLayoutManager*>( | 41 return static_cast<WorkspaceLayoutManager*>( |
| 43 always_on_top_container_->GetLayoutManager()); | 42 always_on_top_container_->GetLayoutManager()); |
| 44 } | 43 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 70 } | 69 } |
| 71 | 70 |
| 72 void AlwaysOnTopController::OnWindowDestroying(aura::Window* window) { | 71 void AlwaysOnTopController::OnWindowDestroying(aura::Window* window) { |
| 73 if (WmWindow::Get(window) == always_on_top_container_) { | 72 if (WmWindow::Get(window) == always_on_top_container_) { |
| 74 always_on_top_container_->aura_window()->RemoveObserver(this); | 73 always_on_top_container_->aura_window()->RemoveObserver(this); |
| 75 always_on_top_container_ = nullptr; | 74 always_on_top_container_ = nullptr; |
| 76 } | 75 } |
| 77 } | 76 } |
| 78 | 77 |
| 79 } // namespace ash | 78 } // namespace ash |
| OLD | NEW |