summaryrefslogtreecommitdiffstats
path: root/athena
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-24 11:09:12 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-24 11:09:12 +0000
commit1b9697d6c8789ab555e5fc76ae90937fd8a248d5 (patch)
tree181e4ee5cb5745cd483c8989021622fcd887b610 /athena
parent3fdee23063ccc0f35d8562ed32f09a3f69d6a184 (diff)
downloadchromium_src-1b9697d6c8789ab555e5fc76ae90937fd8a248d5.zip
chromium_src-1b9697d6c8789ab555e5fc76ae90937fd8a248d5.tar.gz
chromium_src-1b9697d6c8789ab555e5fc76ae90937fd8a248d5.tar.bz2
Explicit container priority
* This will allow a client to create & destroy a container with specific z order, without relying on the order it is created. (will be used for login/lock screen) * Changed to single click to open home card, instead of double click because it's easier and consistent with ash. (ash uses single click to open/activate things) * I tried to add check but I couldn't come up with good solution using window oberver as the child is always added to the top first. BUG=394121 Review URL: https://codereview.chromium.org/411543006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285185 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'athena')
-rw-r--r--athena/athena.gyp3
-rw-r--r--athena/common/container_priorities.h20
-rw-r--r--athena/home/home_card_impl.cc3
-rw-r--r--athena/home/minimized_home.cc2
-rw-r--r--athena/main/debug/debug_window.cc4
-rw-r--r--athena/screen/public/screen_manager.h5
-rw-r--r--athena/screen/screen_manager_impl.cc80
-rw-r--r--athena/screen/screen_manager_unittest.cc62
-rw-r--r--athena/virtual_keyboard/virtual_keyboard_manager_impl.cc4
-rw-r--r--athena/wm/window_manager_impl.cc3
10 files changed, 161 insertions, 25 deletions
diff --git a/athena/athena.gyp b/athena/athena.gyp
index 3f1dc9f..93f5057 100644
--- a/athena/athena.gyp
+++ b/athena/athena.gyp
@@ -36,8 +36,8 @@
'activity/public/activity_manager.h',
'activity/public/activity_view_manager.h',
'activity/public/activity_view_model.h',
- # move athena_export.h to common/
'athena_export.h',
+ 'common/container_priorities.h',
'common/fill_layout_manager.cc',
'common/fill_layout_manager.h',
'common/switches.cc',
@@ -158,6 +158,7 @@
'activity/activity_manager_unittest.cc',
'home/home_card_unittest.cc',
'input/accelerator_manager_unittest.cc',
+ 'screen/screen_manager_unittest.cc',
'wm/window_manager_unittest.cc',
],
}
diff --git a/athena/common/container_priorities.h b/athena/common/container_priorities.h
new file mode 100644
index 0000000..0b34996
--- /dev/null
+++ b/athena/common/container_priorities.h
@@ -0,0 +1,20 @@
+// Copyright 2014 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.
+
+#ifndef ATHENA_COMMON_CONTAINER_PRIORITIES_H_
+#define ATHENA_COMMON_CONTAINER_PRIORITIES_H_
+
+namespace athena {
+
+enum ContainerPriorities {
+ CP_BACKGROUND = 0,
+ CP_DEFAULT,
+ CP_HOME_CARD,
+ CP_VIRTUAL_KEYBOARD,
+ CP_DEBUG,
+};
+
+} // namespace athena
+
+#endif // ATHENA_COMMON_CONTAINER_PRIORITIES_H_
diff --git a/athena/home/home_card_impl.cc b/athena/home/home_card_impl.cc
index 2bf8d50..7718b38 100644
--- a/athena/home/home_card_impl.cc
+++ b/athena/home/home_card_impl.cc
@@ -6,6 +6,7 @@
#include <limits>
+#include "athena/common/container_priorities.h"
#include "athena/home/app_list_view_delegate.h"
#include "athena/home/bottom_home_view.h"
#include "athena/home/minimized_home.h"
@@ -329,7 +330,7 @@ void HomeCardImpl::UpdateVirtualKeyboardBounds(
void HomeCardImpl::Init() {
InstallAccelerators();
- ScreenManager::ContainerParams params("HomeCardContainer");
+ ScreenManager::ContainerParams params("HomeCardContainer", CP_HOME_CARD);
params.can_activate_children = true;
aura::Window* container = ScreenManager::Get()->CreateContainer(params);
layout_manager_ = new HomeCardLayoutManager(this);
diff --git a/athena/home/minimized_home.cc b/athena/home/minimized_home.cc
index 577390d..206bf6a 100644
--- a/athena/home/minimized_home.cc
+++ b/athena/home/minimized_home.cc
@@ -40,7 +40,7 @@ class MinimizedHomeView : public views::View {
}
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE {
- if (event.IsLeftMouseButton() && event.GetClickCount() > 1) {
+ if (event.IsLeftMouseButton() && event.GetClickCount() == 1) {
delegate_->OnDragUpCompleted();
SetColor(kDragHandleColorNormal);
return true;
diff --git a/athena/main/debug/debug_window.cc b/athena/main/debug/debug_window.cc
index e495418..abd3517be 100644
--- a/athena/main/debug/debug_window.cc
+++ b/athena/main/debug/debug_window.cc
@@ -4,6 +4,7 @@
#include "athena/main/debug/debug_window.h"
+#include "athena/common/container_priorities.h"
#include "athena/resources/athena_resources.h"
#include "athena/screen/public/screen_manager.h"
#include "base/bind.h"
@@ -168,7 +169,8 @@ class DebugWidget {
private:
void CreateContainer() {
- athena::ScreenManager::ContainerParams params("DebugContainer");
+ athena::ScreenManager::ContainerParams params("DebugContainer",
+ athena::CP_DEBUG);
container_ = athena::ScreenManager::Get()->CreateContainer(params);
}
diff --git a/athena/screen/public/screen_manager.h b/athena/screen/public/screen_manager.h
index 622f047..9e87306 100644
--- a/athena/screen/public/screen_manager.h
+++ b/athena/screen/public/screen_manager.h
@@ -29,11 +29,14 @@ namespace athena {
class ATHENA_EXPORT ScreenManager {
public:
struct ContainerParams {
- ContainerParams(const std::string& name);
+ ContainerParams(const std::string& name, int z_order_priority);
std::string name;
// True if the container can activate its child window.
bool can_activate_children;
+
+ // Defines the z_order priority of the container.
+ int z_order_priority;
};
// Creates, returns and deletes the singleton object of the ScreenManager
diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
index acc367b..744f076 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,56 @@ 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();
+
+#if !defined(NDEBUG)
+ 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.";
+#endif
+
+ 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 +225,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
diff --git a/athena/screen/screen_manager_unittest.cc b/athena/screen/screen_manager_unittest.cc
new file mode 100644
index 0000000..1a04ae8
--- /dev/null
+++ b/athena/screen/screen_manager_unittest.cc
@@ -0,0 +1,62 @@
+// Copyright 2014 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 "athena/screen/public/screen_manager.h"
+
+#include <string>
+
+#include "athena/test/athena_test_base.h"
+#include "ui/aura/window.h"
+
+typedef athena::test::AthenaTestBase ScreenManagerTest;
+
+namespace athena {
+namespace {
+
+aura::Window* Create(const std::string& name, int z_order_priority) {
+ ScreenManager::ContainerParams params(name, z_order_priority);
+ return ScreenManager::Get()->CreateContainer(params);
+}
+
+void CheckZOrder(aura::Window* w1, aura::Window* w2) {
+ aura::Window* parent = w1->parent();
+ const aura::Window::Windows& children = parent->children();
+ aura::Window::Windows::const_iterator begin_iter = children.begin();
+ aura::Window::Windows::const_iterator end_iter = children.end();
+
+ aura::Window::Windows::const_iterator w1_iter =
+ std::find(begin_iter, end_iter, w1);
+ aura::Window::Windows::const_iterator w2_iter =
+ std::find(begin_iter, end_iter, w2);
+ EXPECT_NE(end_iter, w1_iter);
+ EXPECT_NE(end_iter, w2_iter);
+ EXPECT_TRUE(w1_iter < w2_iter);
+}
+
+} // namespace
+
+TEST_F(ScreenManagerTest, Zorder) {
+ aura::Window* window_10 = Create("test10", 10);
+ aura::Window* window_11 = Create("test11", 11);
+ aura::Window* window_12 = Create("test12", 12);
+
+ {
+ SCOPED_TRACE("Init");
+ CheckZOrder(window_10, window_11);
+ CheckZOrder(window_11, window_12);
+ }
+ {
+ SCOPED_TRACE("Delete");
+ delete window_11;
+ CheckZOrder(window_10, window_12);
+ }
+ {
+ SCOPED_TRACE("Insert");
+ window_11 = Create("test11", 11);
+ CheckZOrder(window_10, window_11);
+ CheckZOrder(window_11, window_12);
+ }
+}
+
+} // namespace athena
diff --git a/athena/virtual_keyboard/virtual_keyboard_manager_impl.cc b/athena/virtual_keyboard/virtual_keyboard_manager_impl.cc
index a989c11..c0024be 100644
--- a/athena/virtual_keyboard/virtual_keyboard_manager_impl.cc
+++ b/athena/virtual_keyboard/virtual_keyboard_manager_impl.cc
@@ -4,6 +4,7 @@
#include "athena/virtual_keyboard/public/virtual_keyboard_manager.h"
+#include "athena/common/container_priorities.h"
#include "athena/common/fill_layout_manager.h"
#include "athena/screen/public/screen_manager.h"
#include "athena/virtual_keyboard/vk_webui_controller.h"
@@ -76,7 +77,8 @@ class VirtualKeyboardManagerImpl : public VirtualKeyboardManager {
private:
void Init() {
- athena::ScreenManager::ContainerParams params("VirtualKeyboardContainer");
+ athena::ScreenManager::ContainerParams params("VirtualKeyboardContainer",
+ CP_VIRTUAL_KEYBOARD);
container_ = athena::ScreenManager::Get()->CreateContainer(params);
container_->SetLayoutManager(new FillLayoutManager(container_));
keyboard::SetOverrideContentUrl(GURL(keyboard::kKeyboardURL));
diff --git a/athena/wm/window_manager_impl.cc b/athena/wm/window_manager_impl.cc
index 7f659e1..4bb04501 100644
--- a/athena/wm/window_manager_impl.cc
+++ b/athena/wm/window_manager_impl.cc
@@ -4,6 +4,7 @@
#include "athena/wm/public/window_manager.h"
+#include "athena/common/container_priorities.h"
#include "athena/input/public/accelerator_manager.h"
#include "athena/screen/public/screen_manager.h"
#include "athena/wm/bezel_controller.h"
@@ -86,7 +87,7 @@ class AthenaContainerLayoutManager : public aura::LayoutManager {
class WindowManagerImpl* instance = NULL;
WindowManagerImpl::WindowManagerImpl() {
- ScreenManager::ContainerParams params("DefaultContainer");
+ ScreenManager::ContainerParams params("DefaultContainer", CP_DEFAULT);
params.can_activate_children = true;
container_.reset(ScreenManager::Get()->CreateDefaultContainer(params));
container_->SetLayoutManager(new AthenaContainerLayoutManager);