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

Side by Side Diff: ui/views/event_monitor_aura.cc

Issue 793003004: MacViews: Implement event monitoring for a specific window (Reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Created 6 years 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
« no previous file with comments | « ui/views/event_monitor_aura.h ('k') | ui/views/event_monitor_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 scoped_ptr<EventMonitor> EventMonitor::CreateApplicationMonitor(
14 return new EventMonitorAura(event_handler); 16 ui::EventHandler* event_handler) {
17 return scoped_ptr<EventMonitor>(
18 new EventMonitorAura(event_handler, aura::Env::GetInstance()));
15 } 19 }
16 20
17 // static 21 // static
22 scoped_ptr<EventMonitor> EventMonitor::CreateWindowMonitor(
23 ui::EventHandler* event_handler,
24 gfx::NativeWindow target_window) {
25 return scoped_ptr<EventMonitor>(
26 new EventMonitorAura(event_handler, target_window));
27 }
28
29 // static
18 gfx::Point EventMonitor::GetLastMouseLocation() { 30 gfx::Point EventMonitor::GetLastMouseLocation() {
19 return aura::Env::GetInstance()->last_mouse_location(); 31 return aura::Env::GetInstance()->last_mouse_location();
20 } 32 }
21 33
22 EventMonitorAura::EventMonitorAura(ui::EventHandler* event_handler) 34 EventMonitorAura::EventMonitorAura(ui::EventHandler* event_handler,
23 : event_handler_(event_handler) { 35 ui::EventTarget* event_target)
36 : event_handler_(event_handler), event_target_(event_target) {
24 DCHECK(event_handler_); 37 DCHECK(event_handler_);
25 aura::Env::GetInstance()->AddPreTargetHandler(event_handler_); 38 DCHECK(event_target_);
39 event_target_->AddPreTargetHandler(event_handler_);
26 } 40 }
27 41
28 EventMonitorAura::~EventMonitorAura() { 42 EventMonitorAura::~EventMonitorAura() {
29 aura::Env::GetInstance()->RemovePreTargetHandler(event_handler_); 43 event_target_->RemovePreTargetHandler(event_handler_);
30 } 44 }
31 45
32 } // namespace views 46 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/event_monitor_aura.h ('k') | ui/views/event_monitor_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698