Index: athena/input/input_manager_impl.cc |
diff --git a/athena/input/input_manager_impl.cc b/athena/input/input_manager_impl.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2b7bcc6703613f88d22dbcf626f8829000078111 |
--- /dev/null |
+++ b/athena/input/input_manager_impl.cc |
@@ -0,0 +1,121 @@ |
+// 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/input/public/input_manager.h" |
+ |
+#include "athena/input/accelerator_manager_impl.h" |
+#include "base/logging.h" |
+#include "ui/aura/client/event_client.h" |
+#include "ui/aura/env.h" |
+#include "ui/events/event_target.h" |
+ |
+namespace athena { |
+namespace { |
+ |
+InputManager* instance = NULL; |
+ |
+class InputManagerImpl : public InputManager, |
+ public ui::EventTarget, |
+ public aura::client::EventClient { |
+ public: |
+ InputManagerImpl(); |
+ virtual ~InputManagerImpl(); |
+ |
+ void Init(); |
+ void Shutdown(); |
+ |
+ private: |
+ // InputManager: |
+ virtual void OnRootWindowCreated(aura::Window* root_window) OVERRIDE; |
+ virtual ui::EventTarget* GetToplevelEventTarget() OVERRIDE { return this; } |
sadrul
2014/06/04 22:57:53
This is also in aura::client::EventClient?
oshima
2014/06/04 23:35:55
Yes. I can rename it to something else if you want
|
+ virtual AcceleratorManager* GetAcceleratorManager() OVERRIDE { |
+ return accelerator_manager_.get(); |
+ } |
+ |
+ // Overridden from aura::client::EventClient: |
+ virtual bool CanProcessEventsWithinSubtree( |
+ const aura::Window* window) const OVERRIDE { |
+ return true; |
+ } |
+ |
+ // ui::EventTarget: |
+ virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE; |
+ virtual EventTarget* GetParentTarget() OVERRIDE; |
+ virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const OVERRIDE; |
+ virtual ui::EventTargeter* GetEventTargeter() OVERRIDE; |
+ virtual void OnEvent(ui::Event* event) OVERRIDE; |
+ |
+ scoped_ptr<AcceleratorManagerImpl> accelerator_manager_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(InputManagerImpl); |
+}; |
+ |
+InputManagerImpl::InputManagerImpl() |
+ : accelerator_manager_(new AcceleratorManagerImpl) { |
+ DCHECK(!instance); |
+ instance = this; |
+} |
+ |
+InputManagerImpl::~InputManagerImpl() { |
+ DCHECK_EQ(instance, this); |
+ Shutdown(); |
+ instance = NULL; |
+} |
+ |
+void InputManagerImpl::Init() { |
+ accelerator_manager_->Init(); |
+} |
+ |
+void InputManagerImpl::Shutdown() { |
+ accelerator_manager_.reset(); |
+} |
+ |
+void InputManagerImpl::OnRootWindowCreated(aura::Window* root_window) { |
+ aura::client::SetEventClient(root_window, this); |
+ accelerator_manager_->OnRootWindowCreated(root_window); |
+} |
+ |
+bool InputManagerImpl::CanAcceptEvent(const ui::Event& event) { |
+ return true; |
+} |
+ |
+ui::EventTarget* InputManagerImpl::GetParentTarget() { |
+ return aura::Env::GetInstance(); |
+} |
+ |
+scoped_ptr<ui::EventTargetIterator> InputManagerImpl::GetChildIterator() const { |
+ return scoped_ptr<ui::EventTargetIterator>(); |
+} |
+ |
+ui::EventTargeter* InputManagerImpl::GetEventTargeter() { |
+ NOTREACHED(); |
+ return NULL; |
+} |
+ |
+void InputManagerImpl::OnEvent(ui::Event* event) { |
+} |
+ |
+} // namespace |
+ |
+// static |
+InputManager* InputManager::Create() { |
+ (new InputManagerImpl)->Init(); |
+ DCHECK(instance); |
+ return instance; |
+} |
+ |
+// static |
+InputManager* InputManager::Get() { |
+ DCHECK(instance); |
+ return instance; |
+} |
+ |
+// static |
+void InputManager::Shutdown() { |
+ DCHECK(instance); |
+ delete instance; |
+ DCHECK(!instance); |
+} |
+ |
+} // namespace athena |