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/mouse_watcher.h" | 5 #include "ui/views/mouse_watcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/event_types.h" | 9 #include "base/event_types.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
13 #include "ui/events/event_constants.h" | 13 #include "ui/events/event_constants.h" |
14 #include "ui/events/event_handler.h" | 14 #include "ui/events/event_handler.h" |
15 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
16 #include "ui/views/event_monitor.h" | 16 #include "ui/views/event_monitor.h" |
17 | 17 |
18 namespace views { | 18 namespace views { |
19 | 19 |
20 // Amount of time between when the mouse moves outside the Host's zone and when | 20 // Amount of time between when the mouse moves outside the Host's zone and when |
21 // the listener is notified. | 21 // the listener is notified. |
22 const int kNotifyListenerTimeMs = 300; | 22 const int kNotifyListenerTimeMs = 300; |
23 | 23 |
24 class MouseWatcher::Observer : public ui::EventHandler { | 24 class MouseWatcher::Observer : public ui::EventHandler { |
25 public: | 25 public: |
26 explicit Observer(MouseWatcher* mouse_watcher) | 26 explicit Observer(MouseWatcher* mouse_watcher) |
27 : mouse_watcher_(mouse_watcher), | 27 : mouse_watcher_(mouse_watcher), |
28 event_monitor_(views::EventMonitor::Create(this)), | 28 event_monitor_(EventMonitor::CreateApplicationMonitor(this)), |
29 notify_listener_factory_(this) { | 29 notify_listener_factory_(this) { |
30 } | 30 } |
31 | 31 |
32 // ui::EventHandler implementation: | 32 // ui::EventHandler implementation: |
33 virtual void OnMouseEvent(ui::MouseEvent* event) override { | 33 virtual void OnMouseEvent(ui::MouseEvent* event) override { |
34 switch (event->type()) { | 34 switch (event->type()) { |
35 case ui::ET_MOUSE_MOVED: | 35 case ui::ET_MOUSE_MOVED: |
36 case ui::ET_MOUSE_DRAGGED: | 36 case ui::ET_MOUSE_DRAGGED: |
37 HandleMouseEvent(MouseWatcherHost::MOUSE_MOVE); | 37 HandleMouseEvent(MouseWatcherHost::MOUSE_MOVE); |
38 break; | 38 break; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 void MouseWatcher::Stop() { | 110 void MouseWatcher::Stop() { |
111 observer_.reset(NULL); | 111 observer_.reset(NULL); |
112 } | 112 } |
113 | 113 |
114 void MouseWatcher::NotifyListener() { | 114 void MouseWatcher::NotifyListener() { |
115 observer_.reset(NULL); | 115 observer_.reset(NULL); |
116 listener_->MouseMovedOutOfHost(); | 116 listener_->MouseMovedOutOfHost(); |
117 } | 117 } |
118 | 118 |
119 } // namespace views | 119 } // namespace views |
OLD | NEW |