| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 #endif | 81 #endif |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 MouseWatcherHost* host() const { return mouse_watcher_->host_.get(); } | 84 MouseWatcherHost* host() const { return mouse_watcher_->host_.get(); } |
| 85 | 85 |
| 86 // Called from the message loop observer when a mouse movement has occurred. | 86 // Called from the message loop observer when a mouse movement has occurred. |
| 87 void HandleGlobalMouseMoveEvent(MouseWatcherHost::MouseEventType event_type) { | 87 void HandleGlobalMouseMoveEvent(MouseWatcherHost::MouseEventType event_type) { |
| 88 bool contained = host()->Contains( | 88 bool contained = host()->Contains( |
| 89 gfx::Screen::GetCursorScreenPoint(), event_type); | 89 // TODO(scottmg): Native is wrong http://crbug.com/133312 |
| 90 gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(), |
| 91 event_type); |
| 90 if (!contained) { | 92 if (!contained) { |
| 91 // Mouse moved outside the host's zone, start a timer to notify the | 93 // Mouse moved outside the host's zone, start a timer to notify the |
| 92 // listener. | 94 // listener. |
| 93 if (!notify_listener_factory_.HasWeakPtrs()) { | 95 if (!notify_listener_factory_.HasWeakPtrs()) { |
| 94 MessageLoop::current()->PostDelayedTask( | 96 MessageLoop::current()->PostDelayedTask( |
| 95 FROM_HERE, | 97 FROM_HERE, |
| 96 base::Bind(&Observer::NotifyListener, | 98 base::Bind(&Observer::NotifyListener, |
| 97 notify_listener_factory_.GetWeakPtr()), | 99 notify_listener_factory_.GetWeakPtr()), |
| 98 event_type == MouseWatcherHost::MOUSE_MOVE ? | 100 event_type == MouseWatcherHost::MOUSE_MOVE ? |
| 99 base::TimeDelta::FromMilliseconds(kNotifyListenerTimeMs) : | 101 base::TimeDelta::FromMilliseconds(kNotifyListenerTimeMs) : |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 void MouseWatcher::Stop() { | 147 void MouseWatcher::Stop() { |
| 146 observer_.reset(NULL); | 148 observer_.reset(NULL); |
| 147 } | 149 } |
| 148 | 150 |
| 149 void MouseWatcher::NotifyListener() { | 151 void MouseWatcher::NotifyListener() { |
| 150 observer_.reset(NULL); | 152 observer_.reset(NULL); |
| 151 listener_->MouseMovedOutOfHost(); | 153 listener_->MouseMovedOutOfHost(); |
| 152 } | 154 } |
| 153 | 155 |
| 154 } // namespace views | 156 } // namespace views |
| OLD | NEW |