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

Side by Side Diff: ui/views/mouse_watcher.cc

Issue 793003004: MacViews: Implement event monitoring for a specific window (Reland) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Created 6 years 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 unified diff | Download patch
« no previous file with comments | « ui/views/event_monitor_unittest.cc ('k') | ui/views/test/event_generator_delegate_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "ui/events/event.h" 12 #include "ui/events/event.h"
13 #include "ui/events/event_constants.h" 13 #include "ui/events/event_constants.h"
14 #include "ui/events/event_handler.h" 14 #include "ui/events/event_handler.h"
15 #include "ui/events/event_utils.h" 15 #include "ui/events/event_utils.h"
16 #include "ui/views/event_monitor.h" 16 #include "ui/views/event_monitor.h"
17 17
18 namespace views { 18 namespace views {
19 19
20 // Amount of time between when the mouse moves outside the Host's zone and when 20 // Amount of time between when the mouse moves outside the Host's zone and when
21 // the listener is notified. 21 // the listener is notified.
22 const int kNotifyListenerTimeMs = 300; 22 const int kNotifyListenerTimeMs = 300;
23 23
24 class MouseWatcher::Observer : public ui::EventHandler { 24 class MouseWatcher::Observer : public ui::EventHandler {
25 public: 25 public:
26 explicit Observer(MouseWatcher* mouse_watcher) 26 explicit Observer(MouseWatcher* mouse_watcher)
27 : mouse_watcher_(mouse_watcher), 27 : mouse_watcher_(mouse_watcher),
28 event_monitor_(views::EventMonitor::Create(this)), 28 event_monitor_(EventMonitor::CreateApplicationMonitor(this)),
29 notify_listener_factory_(this) { 29 notify_listener_factory_(this) {
30 } 30 }
31 31
32 // ui::EventHandler implementation: 32 // ui::EventHandler implementation:
33 virtual void OnMouseEvent(ui::MouseEvent* event) override { 33 virtual void OnMouseEvent(ui::MouseEvent* event) override {
34 switch (event->type()) { 34 switch (event->type()) {
35 case ui::ET_MOUSE_MOVED: 35 case ui::ET_MOUSE_MOVED:
36 case ui::ET_MOUSE_DRAGGED: 36 case ui::ET_MOUSE_DRAGGED:
37 HandleMouseEvent(MouseWatcherHost::MOUSE_MOVE); 37 HandleMouseEvent(MouseWatcherHost::MOUSE_MOVE);
38 break; 38 break;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void MouseWatcher::Stop() { 110 void MouseWatcher::Stop() {
111 observer_.reset(NULL); 111 observer_.reset(NULL);
112 } 112 }
113 113
114 void MouseWatcher::NotifyListener() { 114 void MouseWatcher::NotifyListener() {
115 observer_.reset(NULL); 115 observer_.reset(NULL);
116 listener_->MouseMovedOutOfHost(); 116 listener_->MouseMovedOutOfHost();
117 } 117 }
118 118
119 } // namespace views 119 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/event_monitor_unittest.cc ('k') | ui/views/test/event_generator_delegate_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698