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

Unified Diff: athena/screen/screen_manager_impl.cc

Issue 404563002: Athena's FocusRules (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
« no previous file with comments | « athena/screen/public/screen_manager.h ('k') | athena/virtual_keyboard/virtual_keyboard_manager_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/screen/screen_manager_impl.cc
diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
index 4fd24e5906d8127bbd096af6a90c2d120a5f5c95..6e5aa8a1218f8628491a43329cc697891309d33e 100644
--- a/athena/screen/screen_manager_impl.cc
+++ b/athena/screen/screen_manager_impl.cc
@@ -14,14 +14,35 @@
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/window.h"
+#include "ui/aura/window_property.h"
#include "ui/aura/window_tree_host.h"
+#include "ui/wm/core/base_focus_rules.h"
#include "ui/wm/core/capture_controller.h"
namespace athena {
namespace {
+DEFINE_OWNED_WINDOW_PROPERTY_KEY(ScreenManager::ContainerParams,
+ kContainerParamsKey,
+ NULL);
+
ScreenManager* instance = NULL;
+class AthenaFocusRules : public wm::BaseFocusRules {
+ public:
+ AthenaFocusRules() {}
+ virtual ~AthenaFocusRules() {}
+
+ virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE {
sadrul 2014/07/18 04:06:12 // wm::BaseFocusRules:
oshima 2014/07/18 04:13:22 Done.
+ ScreenManager::ContainerParams* params =
+ window->GetProperty(kContainerParamsKey);
+ return params && params->can_activate_children;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AthenaFocusRules);
+};
+
class AthenaWindowTreeClient : public aura::client::WindowTreeClient {
public:
explicit AthenaWindowTreeClient(aura::Window* container)
@@ -78,16 +99,6 @@ class AthenaScreenPositionClient : public aura::client::ScreenPositionClient {
DISALLOW_COPY_AND_ASSIGN(AthenaScreenPositionClient);
};
-aura::Window* CreateContainerInternal(aura::Window* parent,
- const std::string& name) {
- aura::Window* container = new aura::Window(NULL);
- container->Init(aura::WINDOW_LAYER_NOT_DRAWN);
- container->SetName(name);
- parent->AddChild(container);
- container->Show();
- return container;
-}
-
class ScreenManagerImpl : public ScreenManager {
public:
explicit ScreenManagerImpl(aura::Window* root_window);
@@ -98,8 +109,8 @@ class ScreenManagerImpl : public ScreenManager {
private:
// ScreenManager:
virtual aura::Window* CreateDefaultContainer(
- const std::string& name) OVERRIDE;
- virtual aura::Window* CreateContainer(const std::string& name) OVERRIDE;
+ const ContainerParams& params) OVERRIDE;
+ virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE;
virtual aura::Window* GetContext() OVERRIDE { return root_window_; }
virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE;
@@ -116,9 +127,10 @@ class ScreenManagerImpl : public ScreenManager {
};
void ScreenManagerImpl::Init() {
+ // TODO(oshima): Move the background out from ScreenManager.
root_window_->SetLayoutManager(new FillLayoutManager(root_window_));
- background_window_ =
- CreateContainerInternal(root_window_, "AthenaBackground");
+ background_window_ = CreateContainer(ContainerParams("AthenaBackground"));
+
background_window_->SetLayoutManager(
new FillLayoutManager(background_window_));
background_controller_.reset(new BackgroundController(background_window_));
@@ -128,8 +140,8 @@ void ScreenManagerImpl::Init() {
}
aura::Window* ScreenManagerImpl::CreateDefaultContainer(
- const std::string& name) {
- aura::Window* container = CreateContainerInternal(root_window_, name);
+ const ContainerParams& params) {
+ aura::Window* container = CreateContainer(params);
window_tree_client_.reset(new AthenaWindowTreeClient(container));
aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get());
@@ -140,8 +152,15 @@ aura::Window* ScreenManagerImpl::CreateDefaultContainer(
return container;
}
-aura::Window* ScreenManagerImpl::CreateContainer(const std::string& name) {
- return CreateContainerInternal(root_window_, name);
+aura::Window* ScreenManagerImpl::CreateContainer(
+ const ContainerParams& params) {
+ aura::Window* container = new aura::Window(NULL);
+ container->Init(aura::WINDOW_LAYER_NOT_DRAWN);
+ container->SetName(params.name);
+ root_window_->AddChild(container);
+ container->Show();
+ container->SetProperty(kContainerParamsKey, new ContainerParams(params));
+ return container;
}
void ScreenManagerImpl::SetBackgroundImage(const gfx::ImageSkia& image) {
@@ -163,6 +182,11 @@ ScreenManagerImpl::~ScreenManagerImpl() {
} // namespace
+ScreenManager::ContainerParams::ContainerParams(const std::string& n)
+ : name(n),
+ can_activate_children(false) {
+}
+
// static
ScreenManager* ScreenManager::Create(aura::Window* root_window) {
(new ScreenManagerImpl(root_window))->Init();
@@ -183,4 +207,9 @@ void ScreenManager::Shutdown() {
DCHECK(!instance);
}
+// static
+wm::FocusRules* ScreenManager::CreateFocusRules() {
+ return new AthenaFocusRules();
+}
+
} // namespace athena
« no previous file with comments | « athena/screen/public/screen_manager.h ('k') | athena/virtual_keyboard/virtual_keyboard_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698