Index: ui/aura/test/test_activation_client.cc |
diff --git a/ui/aura/test/test_activation_client.cc b/ui/aura/test/test_activation_client.cc |
index 7ba0d41e0f4f8134fef95060fed62db274acad2d..74810ccbe1527c02bcf5f45cd23b065efe73f0bf 100644 |
--- a/ui/aura/test/test_activation_client.cc |
+++ b/ui/aura/test/test_activation_client.cc |
@@ -4,6 +4,7 @@ |
#include "ui/aura/test/test_activation_client.h" |
+#include "ui/aura/client/activation_delegate.h" |
#include "ui/aura/root_window.h" |
#include "ui/aura/window.h" |
@@ -13,8 +14,7 @@ namespace test { |
//////////////////////////////////////////////////////////////////////////////// |
// TestActivationClient, public: |
-TestActivationClient::TestActivationClient(RootWindow* root_window) |
- : active_window_(NULL) { |
+TestActivationClient::TestActivationClient(RootWindow* root_window) { |
client::SetActivationClient(root_window, this); |
} |
@@ -25,22 +25,34 @@ TestActivationClient::~TestActivationClient() { |
// TestActivationClient, client::ActivationClient implementation: |
void TestActivationClient::ActivateWindow(Window* window) { |
- if (active_window_) |
- active_window_->RemoveObserver(this); |
- active_window_ = window; |
- active_window_->AddObserver(this); |
+ Window *last_active = GetActiveWindow(); |
+ if (last_active == window) |
+ return; |
+ |
+ RemoveActiveWindow(window); |
+ active_windows_.push_back(window); |
+ window->AddObserver(this); |
+ if (aura::client::GetActivationDelegate(window)) |
+ aura::client::GetActivationDelegate(window)->OnActivated(); |
+ |
+ if (last_active) { |
sky
2012/03/14 04:05:44
nit: combine into a single if.
DaveMoore
2012/03/14 19:54:58
Done.
|
+ if (aura::client::GetActivationDelegate(last_active)) |
+ aura::client::GetActivationDelegate(last_active)->OnLostActive(); |
+ } |
+ |
} |
void TestActivationClient::DeactivateWindow(Window* window) { |
- if (window == active_window_) { |
- if (active_window_) |
- active_window_->RemoveObserver(this); |
- active_window_ = NULL; |
+ if (window && window == GetActiveWindow()) { |
+ RemoveActiveWindow(window); |
sky
2012/03/14 04:05:44
How come deactivate removes from the vector?
DaveMoore
2012/03/14 19:54:58
You're right...it shouldn't.
On 2012/03/14 04:05:4
|
+ if (aura::client::GetActivationDelegate(window)) |
+ aura::client::GetActivationDelegate(window)->OnLostActive(); |
} |
} |
- |
Window* TestActivationClient::GetActiveWindow() { |
- return active_window_; |
+ if (active_windows_.size() == 0) |
sky
2012/03/14 04:05:44
empty
DaveMoore
2012/03/14 19:54:58
Done.
|
+ return NULL; |
+ return active_windows_.back(); |
} |
bool TestActivationClient::CanFocusWindow(Window* window) const { |
@@ -51,9 +63,26 @@ bool TestActivationClient::CanFocusWindow(Window* window) const { |
// TestActivationClient, WindowObserver implementation: |
void TestActivationClient::OnWindowDestroyed(Window* window) { |
- if (window == active_window_) { |
- window->RemoveObserver(this); |
- active_window_ = NULL; |
+ if (window == GetActiveWindow()) { |
+ active_windows_.pop_back(); |
sky
2012/03/14 04:05:44
This should remove the observer too.
DaveMoore
2012/03/14 19:54:58
Done.
|
+ Window *next_active = GetActiveWindow(); |
sky
2012/03/14 04:05:44
'window *' -> 'window* '
DaveMoore
2012/03/14 19:54:58
Done.
|
+ if (next_active) { |
sky
2012/03/14 04:05:44
nit: combine into a single if.
DaveMoore
2012/03/14 19:54:58
Done.
|
+ if (aura::client::GetActivationDelegate(next_active)) |
+ aura::client::GetActivationDelegate(next_active)->OnActivated(); |
+ } |
+ return; |
+ } |
+ |
+ RemoveActiveWindow(window); |
+} |
+ |
+void TestActivationClient::RemoveActiveWindow(Window* window) { |
+ for (unsigned int i = 0; i < active_windows_.size(); ++i) { |
sky
2012/03/14 04:05:44
unsigned int -> size_t
DaveMoore
2012/03/14 19:54:58
Done.
|
+ if (active_windows_[i] == window) { |
+ active_windows_.erase(active_windows_.begin() + i); |
+ window->RemoveObserver(this); |
+ return; |
+ } |
} |
} |