Index: ash/wm/always_on_top_controller.cc |
diff --git a/ash/wm/always_on_top_controller.cc b/ash/wm/always_on_top_controller.cc |
index beda3c4aa0c98e61db8b58a3bb6b75281d9efc86..c3b8a07845f3041181cc811c3d088790f2b5e903 100644 |
--- a/ash/wm/always_on_top_controller.cc |
+++ b/ash/wm/always_on_top_controller.cc |
@@ -4,21 +4,21 @@ |
#include "ash/wm/always_on_top_controller.h" |
-#include "ash/shell.h" |
-#include "ash/shell_window_ids.h" |
+#include "ash/wm/common/wm_shell_window_ids.h" |
+#include "ash/wm/common/wm_window.h" |
+#include "ash/wm/common/wm_window_property.h" |
#include "ash/wm/common/workspace/workspace_layout_manager_delegate.h" |
#include "ash/wm/workspace/workspace_layout_manager.h" |
-#include "ui/aura/client/aura_constants.h" |
-#include "ui/aura/window.h" |
+#include "base/memory/ptr_util.h" |
namespace ash { |
-AlwaysOnTopController::AlwaysOnTopController(aura::Window* viewport) |
+AlwaysOnTopController::AlwaysOnTopController(wm::WmWindow* viewport) |
: always_on_top_container_(viewport) { |
always_on_top_container_->SetLayoutManager( |
- new WorkspaceLayoutManager(viewport, nullptr)); |
+ base::WrapUnique(new WorkspaceLayoutManager(viewport, nullptr))); |
// Container should be empty. |
- DCHECK(always_on_top_container_->children().empty()); |
+ DCHECK(always_on_top_container_->GetChildren().empty()); |
always_on_top_container_->AddObserver(this); |
} |
@@ -27,50 +27,53 @@ AlwaysOnTopController::~AlwaysOnTopController() { |
always_on_top_container_->RemoveObserver(this); |
} |
-aura::Window* AlwaysOnTopController::GetContainer(aura::Window* window) const { |
+wm::WmWindow* AlwaysOnTopController::GetContainer(wm::WmWindow* window) const { |
DCHECK(always_on_top_container_); |
- if (window->GetProperty(aura::client::kAlwaysOnTopKey)) |
+ if (window->GetBoolProperty(wm::WmWindowProperty::ALWAYS_ON_TOP)) |
return always_on_top_container_; |
- return Shell::GetContainer(always_on_top_container_->GetRootWindow(), |
- kShellWindowId_DefaultContainer); |
-} |
- |
-void AlwaysOnTopController::OnWindowAdded(aura::Window* child) { |
- // Observe direct child of the containers. |
- if (child->parent() == always_on_top_container_) |
- child->AddObserver(this); |
-} |
- |
-void AlwaysOnTopController::SetLayoutManagerForTest( |
- WorkspaceLayoutManager* layout_manager) { |
- always_on_top_container_->SetLayoutManager(layout_manager); |
+ return always_on_top_container_->GetRootWindow()->GetChildByShellWindowId( |
+ kShellWindowId_DefaultContainer); |
} |
// TODO(rsadam@): Refactor so that this cast is unneeded. |
WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const { |
return static_cast<WorkspaceLayoutManager*>( |
- always_on_top_container_->layout_manager()); |
+ always_on_top_container_->GetLayoutManager()); |
} |
-void AlwaysOnTopController::OnWillRemoveWindow(aura::Window* child) { |
- child->RemoveObserver(this); |
+void AlwaysOnTopController::SetLayoutManagerForTest( |
+ std::unique_ptr<WorkspaceLayoutManager> layout_manager) { |
+ always_on_top_container_->SetLayoutManager(std::move(layout_manager)); |
+} |
+ |
+void AlwaysOnTopController::OnWindowTreeChanged( |
+ wm::WmWindow* window, |
+ const TreeChangeParams& params) { |
+ if (params.old_parent == always_on_top_container_) |
+ params.target->RemoveObserver(this); |
+ else if (params.new_parent == always_on_top_container_) |
+ params.target->AddObserver(this); |
} |
-void AlwaysOnTopController::OnWindowPropertyChanged(aura::Window* window, |
- const void* key, |
- intptr_t old) { |
- if (key == aura::client::kAlwaysOnTopKey) { |
- DCHECK(window->type() == ui::wm::WINDOW_TYPE_NORMAL || |
- window->type() == ui::wm::WINDOW_TYPE_POPUP); |
- aura::Window* container = GetContainer(window); |
- if (window->parent() != container) |
+void AlwaysOnTopController::OnWindowPropertyChanged( |
+ wm::WmWindow* window, |
+ wm::WmWindowProperty property, |
+ intptr_t old) { |
+ if (window != always_on_top_container_ && |
+ property == wm::WmWindowProperty::ALWAYS_ON_TOP) { |
+ DCHECK(window->GetType() == ui::wm::WINDOW_TYPE_NORMAL || |
+ window->GetType() == ui::wm::WINDOW_TYPE_POPUP); |
+ wm::WmWindow* container = GetContainer(window); |
+ if (window->GetParent() != container) |
container->AddChild(window); |
} |
} |
-void AlwaysOnTopController::OnWindowDestroyed(aura::Window* window) { |
- if (window == always_on_top_container_) |
- always_on_top_container_ = NULL; |
+void AlwaysOnTopController::OnWindowDestroying(wm::WmWindow* window) { |
+ if (window == always_on_top_container_) { |
+ always_on_top_container_->RemoveObserver(this); |
+ always_on_top_container_ = nullptr; |
+ } |
} |
} // namespace ash |