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

Side by Side Diff: athena/input/input_manager_impl.cc

Issue 305873002: InputManager/AcceleratorManager for athena (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix auto repeat test Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "athena/input/public/input_manager.h"
6
7 #include "athena/input/accelerator_manager_impl.h"
8 #include "base/logging.h"
9 #include "ui/aura/client/event_client.h"
10 #include "ui/aura/env.h"
11 #include "ui/events/event_target.h"
12
13 namespace athena {
14 namespace {
15
16 InputManager* instance = NULL;
17
18 class InputManagerImpl : public InputManager,
19 public ui::EventTarget,
20 public aura::client::EventClient {
21 public:
22 InputManagerImpl();
23 virtual ~InputManagerImpl();
24
25 void Init();
26 void Shutdown();
27
28 private:
29 // InputManager:
30 virtual void OnRootWindowCreated(aura::Window* root_window) OVERRIDE;
31 virtual ui::EventTarget* GetToplevelEventTarget() OVERRIDE { return this; }
sadrul 2014/06/05 19:24:32 Let's call this something else to disambiguate fro
oshima 2014/06/05 20:36:40 Changed to TopmostEventTarget().
32 virtual AcceleratorManager* GetAcceleratorManager() OVERRIDE {
33 return accelerator_manager_.get();
34 }
35
36 // Overridden from aura::client::EventClient:
37 virtual bool CanProcessEventsWithinSubtree(
38 const aura::Window* window) const OVERRIDE {
39 return true;
40 }
41
42 // ui::EventTarget:
43 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
44 virtual EventTarget* GetParentTarget() OVERRIDE;
45 virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const OVERRIDE;
46 virtual ui::EventTargeter* GetEventTargeter() OVERRIDE;
47 virtual void OnEvent(ui::Event* event) OVERRIDE;
48
49 scoped_ptr<AcceleratorManagerImpl> accelerator_manager_;
50
51 DISALLOW_COPY_AND_ASSIGN(InputManagerImpl);
52 };
53
54 InputManagerImpl::InputManagerImpl()
55 : accelerator_manager_(new AcceleratorManagerImpl) {
56 DCHECK(!instance);
57 instance = this;
58 }
59
60 InputManagerImpl::~InputManagerImpl() {
61 DCHECK_EQ(instance, this);
62 Shutdown();
63 instance = NULL;
64 }
65
66 void InputManagerImpl::Init() {
67 accelerator_manager_->Init();
68 }
69
70 void InputManagerImpl::Shutdown() {
71 accelerator_manager_.reset();
72 }
73
74 void InputManagerImpl::OnRootWindowCreated(aura::Window* root_window) {
75 aura::client::SetEventClient(root_window, this);
76 accelerator_manager_->OnRootWindowCreated(root_window);
77 }
78
79 bool InputManagerImpl::CanAcceptEvent(const ui::Event& event) {
80 return true;
81 }
82
83 ui::EventTarget* InputManagerImpl::GetParentTarget() {
84 return aura::Env::GetInstance();
85 }
86
87 scoped_ptr<ui::EventTargetIterator> InputManagerImpl::GetChildIterator() const {
88 return scoped_ptr<ui::EventTargetIterator>();
89 }
90
91 ui::EventTargeter* InputManagerImpl::GetEventTargeter() {
92 NOTREACHED();
93 return NULL;
94 }
95
96 void InputManagerImpl::OnEvent(ui::Event* event) {
97 }
98
99 } // namespace
100
101 // static
102 InputManager* InputManager::Create() {
103 (new InputManagerImpl)->Init();
104 DCHECK(instance);
105 return instance;
106 }
107
108 // static
109 InputManager* InputManager::Get() {
110 DCHECK(instance);
111 return instance;
112 }
113
114 // static
115 void InputManager::Shutdown() {
116 DCHECK(instance);
117 delete instance;
118 DCHECK(!instance);
119 }
120
121 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698