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

Unified Diff: ash/wm/always_on_top_controller.cc

Issue 1923983003: Makes WorkspaceLayoutManager use ash/wm/common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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..0daf6bbe643524ffe269ae286baced31ec7a1e95 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,56 @@ 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);
+ return always_on_top_container_->GetRootWindow()->GetChildByShellWindowId(
+ kShellWindowId_DefaultContainer);
}
-void AlwaysOnTopController::OnWindowAdded(aura::Window* child) {
- // Observe direct child of the containers.
- if (child->parent() == always_on_top_container_)
- child->AddObserver(this);
+// TODO(rsadam@): Refactor so that this cast is unneeded.
+WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const {
+ return static_cast<WorkspaceLayoutManager*>(
+ always_on_top_container_->GetLayoutManager());
}
void AlwaysOnTopController::SetLayoutManagerForTest(
- WorkspaceLayoutManager* layout_manager) {
- always_on_top_container_->SetLayoutManager(layout_manager);
+ std::unique_ptr<WorkspaceLayoutManager> layout_manager) {
+ always_on_top_container_->SetLayoutManager(std::move(layout_manager));
}
-// TODO(rsadam@): Refactor so that this cast is unneeded.
-WorkspaceLayoutManager* AlwaysOnTopController::GetLayoutManager() const {
- return static_cast<WorkspaceLayoutManager*>(
- always_on_top_container_->layout_manager());
-}
+void AlwaysOnTopController::OnWindowTreeChanged(
+ wm::WmWindow* window,
+ const TreeChangeParams& params) {
+ if (window != always_on_top_container_)
+ return;
-void AlwaysOnTopController::OnWillRemoveWindow(aura::Window* child) {
- child->RemoveObserver(this);
+ 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) {
sky 2016/04/27 20:48:05 I'm hoping the order doesn't really matter here (b
James Cook 2016/04/27 23:24:24 Acknowledged.
+ if (window == always_on_top_container_) {
+ always_on_top_container_->RemoveObserver(this);
+ always_on_top_container_ = nullptr;
+ }
}
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698