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

Unified Diff: athena/screen/screen_manager_impl.cc

Issue 411543006: Explicit container priority (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
Index: athena/screen/screen_manager_impl.cc
diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
index acc367bb2bfbcd451436df66166fd4acf7bf05e6..9faa7482e36d9611ef4eef8bb92ed57200a521ee 100644
--- a/athena/screen/screen_manager_impl.cc
+++ b/athena/screen/screen_manager_impl.cc
@@ -4,6 +4,7 @@
#include "athena/screen/public/screen_manager.h"
+#include "athena/common/container_priorities.h"
#include "athena/common/fill_layout_manager.h"
#include "athena/input/public/accelerator_manager.h"
#include "athena/screen/background_controller.h"
@@ -127,10 +128,24 @@ class ScreenManagerImpl : public ScreenManager {
DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl);
};
+ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window)
+ : root_window_(root_window) {
+ DCHECK(root_window_);
+ DCHECK(!instance);
+ instance = this;
+}
+
+ScreenManagerImpl::~ScreenManagerImpl() {
+ aura::client::SetScreenPositionClient(root_window_, NULL);
+ aura::client::SetWindowTreeClient(root_window_, NULL);
+ instance = NULL;
+}
+
void ScreenManagerImpl::Init() {
// TODO(oshima): Move the background out from ScreenManager.
root_window_->SetLayoutManager(new FillLayoutManager(root_window_));
- background_window_ = CreateContainer(ContainerParams("AthenaBackground"));
+ background_window_ =
+ CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND));
background_window_->SetLayoutManager(
new FillLayoutManager(background_window_));
@@ -153,14 +168,54 @@ aura::Window* ScreenManagerImpl::CreateDefaultContainer(
return container;
}
+// A functor to find a container that has the higher priority.
+struct HigherPriorityFinder {
+ HigherPriorityFinder(int p) : priority(p) {}
+ bool operator()(aura::Window* window) {
+ return window->GetProperty(kContainerParamsKey)->z_order_priority >
+ priority;
+ }
+ int priority;
+};
+
+#if !defined(NDEBUG)
+struct PriorityMatcher {
+ PriorityMatcher(int p) : priority(p) {}
+ bool operator()(aura::Window* window) {
+ return window->GetProperty(kContainerParamsKey)->z_order_priority ==
+ priority;
+ }
+ int priority;
+};
+#endif
+
aura::Window* ScreenManagerImpl::CreateContainer(
const ContainerParams& params) {
aura::Window* container = new aura::Window(NULL);
+ CHECK_GE(params.z_order_priority, 0);
container->Init(aura::WINDOW_LAYER_NOT_DRAWN);
container->SetName(params.name);
+
+ const aura::Window::Windows& children = root_window_->children();
+
+ DCHECK(std::find_if(children.begin(),
+ children.end(),
+ PriorityMatcher(params.z_order_priority))
+ == children.end())
+ << "The container with the priority "
+ << params.z_order_priority << " already exists.";
sadrul 2014/07/23 18:37:24 nice
+
+ container->SetProperty(kContainerParamsKey, new ContainerParams(params));
root_window_->AddChild(container);
+
+ aura::Window::Windows::const_iterator iter =
+ std::find_if(children.begin(),
+ children.end(),
+ HigherPriorityFinder(params.z_order_priority));
+ if (iter != children.end())
+ root_window_->StackChildBelow(container, *iter);
+
container->Show();
- container->SetProperty(kContainerParamsKey, new ContainerParams(params));
return container;
}
@@ -168,24 +223,11 @@ void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) {
background_controller_->SetImage(image);
}
-ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window)
- : root_window_(root_window) {
- DCHECK(root_window_);
- DCHECK(!instance);
- instance = this;
-}
-
-ScreenManagerImpl::~ScreenManagerImpl() {
- aura::client::SetScreenPositionClient(root_window_, NULL);
- aura::client::SetWindowTreeClient(root_window_, NULL);
- instance = NULL;
-}
-
} // namespace
-ScreenManager::ContainerParams::ContainerParams(const std::string& n)
- : name(n),
- can_activate_children(false) {
+ScreenManager::ContainerParams::ContainerParams(const std::string& n,
+ int priority)
+ : name(n), can_activate_children(false), z_order_priority(priority) {
}
// static

Powered by Google App Engine
This is Rietveld 408576698