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

Unified Diff: ash/mus/shadow_controller.cc

Issue 2539363005: Converts ash to use aura-mus (Closed)
Patch Set: merge Created 4 years 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/mus/shadow_controller.cc
diff --git a/ash/mus/shadow_controller.cc b/ash/mus/shadow_controller.cc
index ce4492c552005996d9f637db77fae90dde2f1bc6..605d0bb1a54b40bac21883775c87d40724ac0a3d 100644
--- a/ash/mus/shadow_controller.cc
+++ b/ash/mus/shadow_controller.cc
@@ -4,61 +4,84 @@
#include "ash/mus/shadow_controller.h"
-#include "ash/mus/property_util.h"
#include "ash/mus/shadow.h"
-#include "services/ui/public/cpp/window.h"
-#include "services/ui/public/cpp/window_tree_client.h"
+#include "ui/aura/client/focus_client.h"
+#include "ui/aura/env.h"
+#include "ui/aura/window.h"
namespace ash {
namespace mus {
namespace {
// Returns the first ancestor of |from| (including |from|) that has a shadow.
-ui::Window* FindAncestorWithShadow(ui::Window* from) {
- ui::Window* result = from;
- while (result && !GetShadow(result))
+aura::Window* FindAncestorWithShadow(aura::Window* from) {
+ aura::Window* result = from;
+ while (result && !Shadow::Get(result))
result = result->parent();
// Small shadows never change.
- return result && GetShadow(result)->style() != Shadow::STYLE_SMALL ? result
- : nullptr;
+ return result && Shadow::Get(result)->style() != Shadow::STYLE_SMALL
+ ? result
+ : nullptr;
}
} // namespace
-ShadowController::ShadowController(ui::WindowTreeClient* window_tree)
- : window_tree_(window_tree), active_window_(nullptr) {
- window_tree_->AddObserver(this);
- SetActiveWindow(FindAncestorWithShadow(window_tree_->GetFocusedWindow()));
+ShadowController::ShadowController() {
+ aura::Env::GetInstance()->AddObserver(this);
+ SetFocusClient(aura::Env::GetInstance()->active_focus_client());
}
ShadowController::~ShadowController() {
- window_tree_->RemoveObserver(this);
+ aura::Env::GetInstance()->RemoveObserver(this);
if (active_window_)
active_window_->RemoveObserver(this);
+ if (active_focus_client_)
+ active_focus_client_->RemoveObserver(this);
}
-void ShadowController::SetActiveWindow(ui::Window* window) {
+void ShadowController::SetActiveWindow(aura::Window* window) {
+ window = FindAncestorWithShadow(window);
if (window == active_window_)
return;
if (active_window_) {
- if (GetShadow(active_window_))
- GetShadow(active_window_)->SetStyle(Shadow::STYLE_INACTIVE);
+ if (Shadow::Get(active_window_))
+ Shadow::Get(active_window_)->SetStyle(Shadow::STYLE_INACTIVE);
active_window_->RemoveObserver(this);
}
active_window_ = window;
if (active_window_) {
- GetShadow(active_window_)->SetStyle(Shadow::STYLE_ACTIVE);
+ Shadow::Get(active_window_)->SetStyle(Shadow::STYLE_ACTIVE);
active_window_->AddObserver(this);
}
}
-void ShadowController::OnWindowTreeFocusChanged(ui::Window* gained_focus,
- ui::Window* lost_focus) {
- SetActiveWindow(FindAncestorWithShadow(gained_focus));
+void ShadowController::SetFocusClient(aura::client::FocusClient* focus_client) {
+ if (active_focus_client_)
+ active_focus_client_->RemoveObserver(this);
+ active_focus_client_ = focus_client;
+ if (active_focus_client_) {
+ active_focus_client_->AddObserver(this);
+ SetActiveWindow(active_focus_client_->GetFocusedWindow());
+ } else {
+ SetActiveWindow(nullptr);
+ }
+}
+
+void ShadowController::OnWindowInitialized(aura::Window* window) {}
+
+void ShadowController::OnActiveFocusClientChanged(
+ aura::client::FocusClient* focus_client,
+ aura::Window* window) {
+ SetFocusClient(focus_client);
+}
+
+void ShadowController::OnWindowFocused(aura::Window* gained_focus,
+ aura::Window* lost_focus) {
+ SetActiveWindow(gained_focus);
}
-void ShadowController::OnWindowDestroying(ui::Window* window) {
+void ShadowController::OnWindowDestroying(aura::Window* window) {
DCHECK_EQ(window, active_window_);
SetActiveWindow(nullptr);
}

Powered by Google App Engine
This is Rietveld 408576698