summaryrefslogtreecommitdiffstats
path: root/ui/aura/test/test_stacking_client.cc
blob: 4c3ce3160943ee4427de2b56b6607c3171960a38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/aura/test/test_stacking_client.h"

#include "ui/aura/root_window.h"

namespace aura {
namespace test {

TestStackingClient::TestStackingClient()
    : default_container_(new Window(NULL)) {
  RootWindow::GetInstance()->SetStackingClient(this);
  default_container_->Init(ui::Layer::LAYER_HAS_NO_TEXTURE);
  default_container_->SetBounds(
      gfx::Rect(gfx::Point(), RootWindow::GetInstance()->GetHostSize()));
  RootWindow::GetInstance()->AddChild(default_container_.get());
  default_container_->Show();
}

TestStackingClient::~TestStackingClient() {
}

void TestStackingClient::AddChildToDefaultParent(Window* window) {
  default_container_->AddChild(window);
}

bool TestStackingClient::CanActivateWindow(Window* window) const {
  return window->parent() == default_container_;
}

Window* TestStackingClient::GetTopmostWindowToActivate(Window* ignore) const {
  for (aura::Window::Windows::const_reverse_iterator i =
           default_container_->children().rbegin();
       i != default_container_->children().rend();
       ++i) {
    if (*i != ignore && (*i)->CanActivate())
      return *i;
  }
  return NULL;
}

}  // namespace test
}  // namespace aura