OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/aura/test/test_stacking_client.h" | 5 #include "ui/aura/test/test_stacking_client.h" |
6 | 6 |
7 #include "ui/aura/root_window.h" | 7 #include "ui/aura/root_window.h" |
8 | 8 |
9 namespace aura { | 9 namespace aura { |
10 namespace test { | 10 namespace test { |
11 | 11 |
12 TestStackingClient::TestStackingClient() | 12 TestStackingClient::TestStackingClient() |
13 : default_container_(new Window(NULL)) { | 13 : default_container_(new Window(NULL)) { |
14 RootWindow::GetInstance()->SetStackingClient(this); | 14 RootWindow::GetInstance()->SetStackingClient(this); |
15 default_container_->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); | 15 default_container_->Init(ui::Layer::LAYER_HAS_NO_TEXTURE); |
16 default_container_->SetBounds( | 16 default_container_->SetBounds( |
17 gfx::Rect(gfx::Point(), RootWindow::GetInstance()->GetHostSize())); | 17 gfx::Rect(gfx::Point(), RootWindow::GetInstance()->GetHostSize())); |
18 RootWindow::GetInstance()->AddChild(default_container_.get()); | 18 RootWindow::GetInstance()->AddChild(default_container_.get()); |
19 default_container_->Show(); | 19 default_container_->Show(); |
20 } | 20 } |
21 | 21 |
22 TestStackingClient::~TestStackingClient() { | 22 TestStackingClient::~TestStackingClient() { |
23 } | 23 } |
24 | 24 |
25 void TestStackingClient::AddChildToDefaultParent(Window* window) { | 25 void TestStackingClient::AddChildToDefaultParent(Window* window) { |
26 default_container_->AddChild(window); | 26 default_container_->AddChild(window); |
27 } | 27 } |
28 | 28 |
29 bool TestStackingClient::CanActivateWindow(Window* window) const { | |
30 return window->parent() == default_container_; | |
31 } | |
32 | |
33 Window* TestStackingClient::GetTopmostWindowToActivate(Window* ignore) const { | |
34 for (aura::Window::Windows::const_reverse_iterator i = | |
35 default_container_->children().rbegin(); | |
36 i != default_container_->children().rend(); | |
37 ++i) { | |
38 if (*i != ignore && (*i)->CanActivate()) | |
39 return *i; | |
40 } | |
41 return NULL; | |
42 } | |
43 | |
44 } // namespace test | 29 } // namespace test |
45 } // namespace aura | 30 } // namespace aura |
OLD | NEW |