Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: ui/views/mouse_watcher.cc

Issue 137993009: Remove more non-aura windows code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: renable the disabled tests Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/focus/focus_manager.cc ('k') | ui/views/test/widget_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mouse_watcher.cc
===================================================================
--- ui/views/mouse_watcher.cc (revision 244775)
+++ ui/views/mouse_watcher.cc (working copy)
@@ -26,90 +26,6 @@
// the listener is notified.
const int kNotifyListenerTimeMs = 300;
-#if defined(OS_WIN) && !defined(USE_AURA)
-class MouseWatcher::Observer : public base::MessageLoopForUI::Observer {
- public:
- explicit Observer(MouseWatcher* mouse_watcher)
- : mouse_watcher_(mouse_watcher),
- notify_listener_factory_(this) {
- base::MessageLoopForUI::current()->AddObserver(this);
- }
-
- virtual ~Observer() {
- base::MessageLoopForUI::current()->RemoveObserver(this);
- }
-
- // MessageLoop::Observer implementation:
- virtual base::EventStatus WillProcessEvent(
- const base::NativeEvent& event) OVERRIDE {
- return base::EVENT_CONTINUE;
- }
-
- virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE {
- // We spy on three different Windows messages here to see if the mouse has
- // moved out of the bounds of the current view. The messages are:
- //
- // WM_MOUSEMOVE:
- // For when the mouse moves from the view into the rest of the browser UI,
- // i.e. within the bounds of the same windows HWND.
- // WM_MOUSELEAVE:
- // For when the mouse moves out of the bounds of the view's HWND.
- // WM_NCMOUSELEAVE:
- // For notification when the mouse leaves the _non-client_ area.
- //
- switch (event.message) {
- case WM_MOUSEMOVE:
- HandleGlobalMouseMoveEvent(MouseWatcherHost::MOUSE_MOVE);
- break;
- case WM_MOUSELEAVE:
- case WM_NCMOUSELEAVE:
- HandleGlobalMouseMoveEvent(MouseWatcherHost::MOUSE_EXIT);
- break;
- }
- }
-
- private:
- MouseWatcherHost* host() const { return mouse_watcher_->host_.get(); }
-
- // Called from the message loop observer when a mouse movement has occurred.
- void HandleGlobalMouseMoveEvent(MouseWatcherHost::MouseEventType event_type) {
- bool contained = host()->Contains(
- // TODO(scottmg): Native is wrong http://crbug.com/133312
- gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(),
- event_type);
- if (!contained) {
- // Mouse moved outside the host's zone, start a timer to notify the
- // listener.
- if (!notify_listener_factory_.HasWeakPtrs()) {
- base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&Observer::NotifyListener,
- notify_listener_factory_.GetWeakPtr()),
- event_type == MouseWatcherHost::MOUSE_MOVE
- ? base::TimeDelta::FromMilliseconds(kNotifyListenerTimeMs)
- : mouse_watcher_->notify_on_exit_time_);
- }
- } else {
- // Mouse moved quickly out of the host and then into it again, so cancel
- // the timer.
- notify_listener_factory_.InvalidateWeakPtrs();
- }
- }
-
- void NotifyListener() {
- mouse_watcher_->NotifyListener();
- // WARNING: we've been deleted.
- }
-
- private:
- MouseWatcher* mouse_watcher_;
-
- // A factory that is used to construct a delayed callback to the listener.
- base::WeakPtrFactory<Observer> notify_listener_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(Observer);
-};
-#else
class MouseWatcher::Observer : public ui::EventHandler {
public:
explicit Observer(MouseWatcher* mouse_watcher)
@@ -177,7 +93,6 @@
DISALLOW_COPY_AND_ASSIGN(Observer);
};
-#endif
MouseWatcherListener::~MouseWatcherListener() {
}
« no previous file with comments | « ui/views/focus/focus_manager.cc ('k') | ui/views/test/widget_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698