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

Unified Diff: ash/wm/aura/wm_globals_aura.cc

Issue 1907863002: Converts DockedWindowLayoutManager to common ash/wm types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment 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
« no previous file with comments | « ash/wm/aura/wm_globals_aura.h ('k') | ash/wm/aura/wm_root_window_controller_aura.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/aura/wm_globals_aura.cc
diff --git a/ash/wm/aura/wm_globals_aura.cc b/ash/wm/aura/wm_globals_aura.cc
index 0895ce17fda8169cb56b3f9d9b7e4b3f93a8c845..1fe39cb62c461e058190e65bfcc247e74b3fd497 100644
--- a/ash/wm/aura/wm_globals_aura.cc
+++ b/ash/wm/aura/wm_globals_aura.cc
@@ -9,8 +9,10 @@
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/wm/aura/wm_window_aura.h"
+#include "ash/wm/common/wm_activation_observer.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/window_util.h"
+#include "ui/aura/client/focus_client.h"
#include "ui/wm/public/activation_client.h"
namespace ash {
@@ -33,6 +35,10 @@ WmGlobalsAura::WmGlobalsAura() {
WmGlobalsAura::~WmGlobalsAura() {
instance_ = nullptr;
+ if (added_activation_observer_) {
+ aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
+ ->RemoveObserver(this);
+ }
}
// static
@@ -42,6 +48,12 @@ WmGlobalsAura* WmGlobalsAura::Get() {
return instance_;
}
+WmWindow* WmGlobalsAura::GetFocusedWindow() {
+ return WmWindowAura::Get(
+ aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())
+ ->GetFocusedWindow());
+}
+
WmWindow* WmGlobalsAura::GetActiveWindow() {
return WmWindowAura::Get(wm::GetActiveWindow());
}
@@ -86,5 +98,27 @@ std::vector<WmWindow*> WmGlobalsAura::GetAllRootWindows() {
return wm_windows;
}
+void WmGlobalsAura::AddActivationObserver(WmActivationObserver* observer) {
+ if (!added_activation_observer_) {
+ added_activation_observer_ = true;
+ aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
+ ->AddObserver(this);
+ }
+ activation_observers_.AddObserver(observer);
+}
+
+void WmGlobalsAura::RemoveActivationObserver(WmActivationObserver* observer) {
+ activation_observers_.RemoveObserver(observer);
+}
+
+void WmGlobalsAura::OnWindowActivated(
+ aura::client::ActivationChangeObserver::ActivationReason reason,
+ aura::Window* gained_active,
+ aura::Window* lost_active) {
+ FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_,
+ OnWindowActivated(WmWindowAura::Get(gained_active),
+ WmWindowAura::Get(lost_active)));
+}
+
} // namespace wm
} // namespace ash
« no previous file with comments | « ash/wm/aura/wm_globals_aura.h ('k') | ash/wm/aura/wm_root_window_controller_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698