Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/event_monitor_aura.h" | 5 #include "ui/views/event_monitor_aura.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/aura/env.h" | 8 #include "ui/aura/env.h" |
| 9 #include "ui/aura/window.h" | |
| 10 #include "ui/events/event_target.h" | |
| 9 | 11 |
| 10 namespace views { | 12 namespace views { |
| 11 | 13 |
| 12 // static | 14 // static |
| 13 EventMonitor* EventMonitor::Create(ui::EventHandler* event_handler) { | 15 EventMonitor* EventMonitor::Create(ui::EventHandler* event_handler) { |
| 14 return new EventMonitorAura(event_handler); | 16 return new EventMonitorAura(event_handler, aura::Env::GetInstance()); |
|
tapted
2014/11/20 22:39:02
Seems almost odd that aura::Env::GetInstance() wor
Andre
2014/11/21 00:28:28
It seems to be the current pattern to use aura::En
tapted
2014/11/21 00:57:34
Ah, I poked around in http://crrev.com/678823002 .
Andre
2014/12/10 00:18:13
Done.
| |
| 15 } | 17 } |
| 16 | 18 |
| 17 // static | 19 // static |
| 20 EventMonitor* EventMonitor::Create(ui::EventHandler* event_handler, | |
| 21 gfx::NativeWindow target_window) { | |
| 22 return new EventMonitorAura(event_handler, target_window); | |
| 23 } | |
| 24 | |
| 25 // static | |
| 18 gfx::Point EventMonitor::GetLastMouseLocation() { | 26 gfx::Point EventMonitor::GetLastMouseLocation() { |
| 19 return aura::Env::GetInstance()->last_mouse_location(); | 27 return aura::Env::GetInstance()->last_mouse_location(); |
| 20 } | 28 } |
| 21 | 29 |
| 22 EventMonitorAura::EventMonitorAura(ui::EventHandler* event_handler) | 30 EventMonitorAura::EventMonitorAura(ui::EventHandler* event_handler, |
| 23 : event_handler_(event_handler) { | 31 ui::EventTarget* event_target) |
| 32 : event_handler_(event_handler), | |
| 33 event_target_(event_target) { | |
| 24 DCHECK(event_handler_); | 34 DCHECK(event_handler_); |
| 25 aura::Env::GetInstance()->AddPreTargetHandler(event_handler_); | 35 DCHECK(event_target_); |
| 36 event_target_->AddPreTargetHandler(event_handler_); | |
| 26 } | 37 } |
| 27 | 38 |
| 28 EventMonitorAura::~EventMonitorAura() { | 39 EventMonitorAura::~EventMonitorAura() { |
| 29 aura::Env::GetInstance()->RemovePreTargetHandler(event_handler_); | 40 event_target_->RemovePreTargetHandler(event_handler_); |
| 30 } | 41 } |
| 31 | 42 |
| 32 } // namespace views | 43 } // namespace views |
| OLD | NEW |