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.
5 #include "athena/input/input_manager_impl.h"
7 #include "athena/input/power_button_controller.h"
8 #include "base/logging.h"
9 #include "ui/aura/env.h"
10 #include "ui/aura/window.h"
15 InputManager
* instance
= nullptr;
19 InputManagerImpl::InputManagerImpl()
20 : accelerator_manager_(
21 AcceleratorManagerImpl::CreateGlobalAcceleratorManager()),
22 power_button_controller_(new PowerButtonController
) {
27 InputManagerImpl::~InputManagerImpl() {
28 DCHECK_EQ(instance
, this);
33 void InputManagerImpl::Init() {
34 accelerator_manager_
->Init();
35 power_button_controller_
->InstallAccelerators();
38 void InputManagerImpl::Shutdown() {
39 accelerator_manager_
.reset();
42 void InputManagerImpl::OnRootWindowCreated(aura::Window
* root_window
) {
43 aura::client::SetEventClient(root_window
, this);
44 accelerator_manager_
->OnRootWindowCreated(root_window
);
47 ui::EventTarget
* InputManagerImpl::GetTopmostEventTarget() {
51 AcceleratorManager
* InputManagerImpl::GetAcceleratorManager() {
52 return accelerator_manager_
.get();
55 void InputManagerImpl::AddPowerButtonObserver(PowerButtonObserver
* observer
) {
56 power_button_controller_
->AddPowerButtonObserver(observer
);
58 void InputManagerImpl::RemovePowerButtonObserver(
59 PowerButtonObserver
* observer
) {
60 power_button_controller_
->RemovePowerButtonObserver(observer
);
63 bool InputManagerImpl::CanProcessEventsWithinSubtree(
64 const aura::Window
* window
) const {
65 return window
&& !window
->ignore_events();
68 ui::EventTarget
* InputManagerImpl::GetToplevelEventTarget() {
72 bool InputManagerImpl::CanAcceptEvent(const ui::Event
& event
) {
76 ui::EventTarget
* InputManagerImpl::GetParentTarget() {
77 return aura::Env::GetInstance();
80 scoped_ptr
<ui::EventTargetIterator
> InputManagerImpl::GetChildIterator() const {
81 return scoped_ptr
<ui::EventTargetIterator
>();
84 ui::EventTargeter
* InputManagerImpl::GetEventTargeter() {
89 void InputManagerImpl::OnEvent(ui::Event
* event
) {
92 int InputManagerImpl::SetPowerButtonTimeoutMsForTest(int timeout
) {
93 return power_button_controller_
->SetPowerButtonTimeoutMsForTest(timeout
);
97 InputManager
* InputManager::Create() {
98 (new InputManagerImpl
)->Init();
104 InputManager
* InputManager::Get() {
110 void InputManager::Shutdown() {
116 } // namespace athena