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

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: rebase 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
« no previous file with comments | « athena/input/accelerator_manager_unittest.cc ('k') | athena/input/public/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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* GetTopmostEventTarget() OVERRIDE { return this; }
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 virtual ui::EventTarget* GetToplevelEventTarget() OVERRIDE { return this; }
42
43 // ui::EventTarget:
44 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
45 virtual ui::EventTarget* GetParentTarget() OVERRIDE;
46 virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const OVERRIDE;
47 virtual ui::EventTargeter* GetEventTargeter() OVERRIDE;
48 virtual void OnEvent(ui::Event* event) OVERRIDE;
49
50 scoped_ptr<AcceleratorManagerImpl> accelerator_manager_;
51
52 DISALLOW_COPY_AND_ASSIGN(InputManagerImpl);
53 };
54
55 InputManagerImpl::InputManagerImpl()
56 : accelerator_manager_(new AcceleratorManagerImpl) {
57 DCHECK(!instance);
58 instance = this;
59 }
60
61 InputManagerImpl::~InputManagerImpl() {
62 DCHECK_EQ(instance, this);
63 Shutdown();
64 instance = NULL;
65 }
66
67 void InputManagerImpl::Init() {
68 accelerator_manager_->Init();
69 }
70
71 void InputManagerImpl::Shutdown() {
72 accelerator_manager_.reset();
73 }
74
75 void InputManagerImpl::OnRootWindowCreated(aura::Window* root_window) {
76 aura::client::SetEventClient(root_window, this);
77 accelerator_manager_->OnRootWindowCreated(root_window);
78 }
79
80 bool InputManagerImpl::CanAcceptEvent(const ui::Event& event) {
81 return true;
82 }
83
84 ui::EventTarget* InputManagerImpl::GetParentTarget() {
85 return aura::Env::GetInstance();
86 }
87
88 scoped_ptr<ui::EventTargetIterator> InputManagerImpl::GetChildIterator() const {
89 return scoped_ptr<ui::EventTargetIterator>();
90 }
91
92 ui::EventTargeter* InputManagerImpl::GetEventTargeter() {
93 NOTREACHED();
94 return NULL;
95 }
96
97 void InputManagerImpl::OnEvent(ui::Event* event) {
98 }
99
100 } // namespace
101
102 // static
103 InputManager* InputManager::Create() {
104 (new InputManagerImpl)->Init();
105 DCHECK(instance);
106 return instance;
107 }
108
109 // static
110 InputManager* InputManager::Get() {
111 DCHECK(instance);
112 return instance;
113 }
114
115 // static
116 void InputManager::Shutdown() {
117 DCHECK(instance);
118 delete instance;
119 DCHECK(!instance);
120 }
121
122 } // namespace athena
OLDNEW
« no previous file with comments | « athena/input/accelerator_manager_unittest.cc ('k') | athena/input/public/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698