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