OLD | NEW |
---|---|
1 // Copyright (c) 2010 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "ui/gfx/screen.h" | 10 #include "ui/gfx/screen.h" |
11 #include "ui/wayland/events/wayland_event.h" | |
sadrul
2011/08/15 14:50:23
conditional include
| |
11 #include "views/view.h" | 12 #include "views/view.h" |
12 #include "views/widget/widget.h" | 13 #include "views/widget/widget.h" |
13 | 14 |
14 namespace views { | 15 namespace views { |
15 | 16 |
16 // Amount of time between when the mouse moves outside the view's zone and when | 17 // Amount of time between when the mouse moves outside the view's zone and when |
17 // the listener is notified. | 18 // the listener is notified. |
18 static const int kNotifyListenerTimeMs = 300; | 19 static const int kNotifyListenerTimeMs = 300; |
19 | 20 |
20 class MouseWatcher::Observer : public MessageLoopForUI::Observer { | 21 class MouseWatcher::Observer : public MessageLoopForUI::Observer { |
(...skipping 28 matching lines...) Expand all Loading... | |
49 switch (msg.message) { | 50 switch (msg.message) { |
50 case WM_MOUSEMOVE: | 51 case WM_MOUSEMOVE: |
51 HandleGlobalMouseMoveEvent(false); | 52 HandleGlobalMouseMoveEvent(false); |
52 break; | 53 break; |
53 case WM_MOUSELEAVE: | 54 case WM_MOUSELEAVE: |
54 case WM_NCMOUSELEAVE: | 55 case WM_NCMOUSELEAVE: |
55 HandleGlobalMouseMoveEvent(true); | 56 HandleGlobalMouseMoveEvent(true); |
56 break; | 57 break; |
57 } | 58 } |
58 } | 59 } |
60 #elif defined(USE_WAYLAND) | |
61 MessageLoopForUI::Observer::EventStatus | |
62 WillProcessEvent(ui::WaylandEvent* event) { | |
sadrul
2011/08/15 14:50:23
Indent 4 space.
| |
63 switch (event->type) { | |
64 case ui::WAYLAND_MOTION: | |
65 HandleGlobalMouseMoveEvent(false); | |
66 break; | |
67 case ui::WAYLAND_POINTER_FOCUS: | |
68 if (!event->pointer_focus.state) | |
69 HandleGlobalMouseMoveEvent(true); | |
70 break; | |
71 default: | |
72 break; | |
73 } | |
74 return EVENT_CONTINUE; | |
75 } | |
59 #else | 76 #else |
60 void WillProcessEvent(GdkEvent* event) { | 77 void WillProcessEvent(GdkEvent* event) { |
61 } | 78 } |
62 | 79 |
63 void DidProcessEvent(GdkEvent* event) { | 80 void DidProcessEvent(GdkEvent* event) { |
64 switch (event->type) { | 81 switch (event->type) { |
65 case GDK_MOTION_NOTIFY: | 82 case GDK_MOTION_NOTIFY: |
66 HandleGlobalMouseMoveEvent(false); | 83 HandleGlobalMouseMoveEvent(false); |
67 break; | 84 break; |
68 case GDK_LEAVE_NOTIFY: | 85 case GDK_LEAVE_NOTIFY: |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 void MouseWatcher::Stop() { | 179 void MouseWatcher::Stop() { |
163 observer_.reset(NULL); | 180 observer_.reset(NULL); |
164 } | 181 } |
165 | 182 |
166 void MouseWatcher::NotifyListener() { | 183 void MouseWatcher::NotifyListener() { |
167 observer_.reset(NULL); | 184 observer_.reset(NULL); |
168 listener_->MouseMovedOutOfView(); | 185 listener_->MouseMovedOutOfView(); |
169 } | 186 } |
170 | 187 |
171 } // namespace views | 188 } // namespace views |
OLD | NEW |