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

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

Issue 753933003: Dismiss the multi window resizer when the user clicks outside of the resizer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@toplevel_consume_press
Patch Set: 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/mouse_watcher.h ('k') | no next file » | 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"
(...skipping 21 matching lines...) Expand all
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;
39 case ui::ET_MOUSE_EXITED: 39 case ui::ET_MOUSE_EXITED:
40 HandleMouseEvent(MouseWatcherHost::MOUSE_EXIT); 40 HandleMouseEvent(MouseWatcherHost::MOUSE_EXIT);
41 break; 41 break;
42 case ui::ET_MOUSE_PRESSED:
43 HandleMouseEvent(MouseWatcherHost::MOUSE_PRESS);
44 break;
42 default: 45 default:
43 break; 46 break;
44 } 47 }
45 } 48 }
46 49
47 private: 50 private:
48 MouseWatcherHost* host() const { return mouse_watcher_->host_.get(); } 51 MouseWatcherHost* host() const { return mouse_watcher_->host_.get(); }
49 52
50 // Called when a mouse event we're interested is seen. 53 // Called when a mouse event we're interested is seen.
51 void HandleMouseEvent(MouseWatcherHost::MouseEventType event_type) { 54 void HandleMouseEvent(MouseWatcherHost::MouseEventType event_type) {
52 // It's safe to use last_mouse_location() here as this function is invoked 55 // It's safe to use last_mouse_location() here as this function is invoked
53 // during event dispatching. 56 // during event dispatching.
54 if (!host()->Contains(EventMonitor::GetLastMouseLocation(), event_type)) { 57 if (!host()->Contains(EventMonitor::GetLastMouseLocation(), event_type)) {
55 // Mouse moved outside the host's zone, start a timer to notify the 58 // Mouse moved outside the host's zone, start a timer to notify the
sky 2014/12/10 15:51:36 Update comment.
pkotwicz 2014/12/10 18:38:27 I have moved the comment into the else statement
56 // listener. 59 // listener.
57 if (!notify_listener_factory_.HasWeakPtrs()) { 60 if (event_type == MouseWatcherHost::MOUSE_PRESS) {
61 NotifyListener();
sky 2014/12/10 15:51:36 Did you look at all listeners and make sure they r
pkotwicz 2014/12/10 18:38:28 I have not found any cases where notifying the lis
62 } else {
58 base::MessageLoop::current()->PostDelayedTask( 63 base::MessageLoop::current()->PostDelayedTask(
59 FROM_HERE, 64 FROM_HERE, base::Bind(&Observer::NotifyListener,
60 base::Bind(&Observer::NotifyListener, 65 notify_listener_factory_.GetWeakPtr()),
61 notify_listener_factory_.GetWeakPtr()),
62 event_type == MouseWatcherHost::MOUSE_MOVE 66 event_type == MouseWatcherHost::MOUSE_MOVE
63 ? base::TimeDelta::FromMilliseconds(kNotifyListenerTimeMs) 67 ? base::TimeDelta::FromMilliseconds(kNotifyListenerTimeMs)
64 : mouse_watcher_->notify_on_exit_time_); 68 : mouse_watcher_->notify_on_exit_time_);
65 } 69 }
66 } else { 70 } else {
67 // Mouse moved quickly out of the host and then into it again, so cancel 71 // Mouse moved quickly out of the host and then into it again, so cancel
68 // the timer. 72 // the timer.
69 notify_listener_factory_.InvalidateWeakPtrs(); 73 notify_listener_factory_.InvalidateWeakPtrs();
70 } 74 }
71 } 75 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void MouseWatcher::Stop() { 114 void MouseWatcher::Stop() {
111 observer_.reset(NULL); 115 observer_.reset(NULL);
112 } 116 }
113 117
114 void MouseWatcher::NotifyListener() { 118 void MouseWatcher::NotifyListener() {
115 observer_.reset(NULL); 119 observer_.reset(NULL);
116 listener_->MouseMovedOutOfHost(); 120 listener_->MouseMovedOutOfHost();
117 } 121 }
118 122
119 } // namespace views 123 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mouse_watcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698