OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/mouse_watcher.h" | 5 #include "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/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "ui/base/events.h" | 12 #include "ui/base/events.h" |
12 #include "ui/gfx/screen.h" | 13 #include "ui/gfx/screen.h" |
13 #include "views/view.h" | 14 #include "views/view.h" |
14 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
15 | 16 |
16 #if defined(USE_WAYLAND) | |
17 #include "ui/wayland/events/wayland_event.h" | |
18 #endif | |
19 | |
20 namespace views { | 17 namespace views { |
21 | 18 |
22 // Amount of time between when the mouse moves outside the view's zone and when | 19 // Amount of time between when the mouse moves outside the view's zone and when |
23 // the listener is notified. | 20 // the listener is notified. |
24 const int kNotifyListenerTimeMs = 300; | 21 const int kNotifyListenerTimeMs = 300; |
25 | 22 |
26 class MouseWatcher::Observer : public MessageLoopForUI::Observer { | 23 class MouseWatcher::Observer : public MessageLoopForUI::Observer { |
27 public: | 24 public: |
28 explicit Observer(MouseWatcher* mouse_watcher) | 25 explicit Observer(MouseWatcher* mouse_watcher) |
29 : mouse_watcher_(mouse_watcher), | 26 : mouse_watcher_(mouse_watcher), |
(...skipping 29 matching lines...) Expand all Loading... |
59 HandleGlobalMouseMoveEvent(false); | 56 HandleGlobalMouseMoveEvent(false); |
60 break; | 57 break; |
61 case WM_MOUSELEAVE: | 58 case WM_MOUSELEAVE: |
62 case WM_NCMOUSELEAVE: | 59 case WM_NCMOUSELEAVE: |
63 HandleGlobalMouseMoveEvent(true); | 60 HandleGlobalMouseMoveEvent(true); |
64 break; | 61 break; |
65 } | 62 } |
66 } | 63 } |
67 #elif defined(USE_WAYLAND) | 64 #elif defined(USE_WAYLAND) |
68 virtual MessageLoopForUI::Observer::EventStatus WillProcessEvent( | 65 virtual MessageLoopForUI::Observer::EventStatus WillProcessEvent( |
69 ui::WaylandEvent* event) OVERRIDE { | 66 base::wayland::WaylandEvent* event) OVERRIDE { |
70 switch (event->type) { | 67 switch (event->type) { |
71 case ui::WAYLAND_MOTION: | 68 case base::wayland::WAYLAND_MOTION: |
72 HandleGlobalMouseMoveEvent(false); | 69 HandleGlobalMouseMoveEvent(false); |
73 break; | 70 break; |
74 case ui::WAYLAND_POINTER_FOCUS: | 71 case base::wayland::WAYLAND_POINTER_FOCUS: |
75 if (!event->pointer_focus.state) | 72 if (!event->pointer_focus.state) |
76 HandleGlobalMouseMoveEvent(true); | 73 HandleGlobalMouseMoveEvent(true); |
77 break; | 74 break; |
78 default: | 75 default: |
79 break; | 76 break; |
80 } | 77 } |
81 return EVENT_CONTINUE; | 78 return EVENT_CONTINUE; |
82 } | 79 } |
83 #elif defined(TOUCH_UI) || defined(USE_AURA) | 80 #elif defined(TOUCH_UI) || defined(USE_AURA) |
84 virtual base::EventStatus WillProcessEvent( | 81 virtual base::EventStatus WillProcessEvent( |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 void MouseWatcher::Stop() { | 202 void MouseWatcher::Stop() { |
206 observer_.reset(NULL); | 203 observer_.reset(NULL); |
207 } | 204 } |
208 | 205 |
209 void MouseWatcher::NotifyListener() { | 206 void MouseWatcher::NotifyListener() { |
210 observer_.reset(NULL); | 207 observer_.reset(NULL); |
211 listener_->MouseMovedOutOfView(); | 208 listener_->MouseMovedOutOfView(); |
212 } | 209 } |
213 | 210 |
214 } // namespace views | 211 } // namespace views |
OLD | NEW |