OLD | NEW |
---|---|
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/aura/window_event_dispatcher.h" | 5 #include "ui/aura/window_event_dispatcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 | 143 |
144 Window* target = GetGestureTarget(event); | 144 Window* target = GetGestureTarget(event); |
145 if (target) { | 145 if (target) { |
146 event->ConvertLocationToTarget(window(), target); | 146 event->ConvertLocationToTarget(window(), target); |
147 DispatchDetails details = DispatchEvent(target, event); | 147 DispatchDetails details = DispatchEvent(target, event); |
148 if (details.dispatcher_destroyed) | 148 if (details.dispatcher_destroyed) |
149 return; | 149 return; |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 void WindowEventDispatcher::DispatchMouseExitAtPoint(const gfx::Point& point) { | 153 DispatchDetails WindowEventDispatcher::DispatchMouseExitAtPoint( |
154 const gfx::Point& point) { | |
154 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE, | 155 ui::MouseEvent event(ui::ET_MOUSE_EXITED, point, point, ui::EF_NONE, |
155 ui::EF_NONE); | 156 ui::EF_NONE); |
156 DispatchDetails details = | 157 return DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); |
157 DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); | |
158 if (details.dispatcher_destroyed) | |
159 return; | |
160 } | 158 } |
161 | 159 |
162 void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event, | 160 void WindowEventDispatcher::ProcessedTouchEvent(ui::TouchEvent* event, |
163 Window* window, | 161 Window* window, |
164 ui::EventResult result) { | 162 ui::EventResult result) { |
165 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 163 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
166 gestures.reset(ui::GestureRecognizer::Get()-> | 164 gestures.reset(ui::GestureRecognizer::Get()-> |
167 ProcessTouchEventForGesture(*event, result, window)); | 165 ProcessTouchEventForGesture(*event, result, window)); |
168 DispatchDetails details = ProcessGestures(gestures.get()); | 166 DispatchDetails details = ProcessGestures(gestures.get()); |
169 if (details.dispatcher_destroyed) | 167 if (details.dispatcher_destroyed) |
(...skipping 27 matching lines...) Expand all Loading... | |
197 gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const { | 195 gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const { |
198 gfx::Point location = Env::GetInstance()->last_mouse_location(); | 196 gfx::Point location = Env::GetInstance()->last_mouse_location(); |
199 client::ScreenPositionClient* client = | 197 client::ScreenPositionClient* client = |
200 client::GetScreenPositionClient(window()); | 198 client::GetScreenPositionClient(window()); |
201 if (client) | 199 if (client) |
202 client->ConvertPointFromScreen(window(), &location); | 200 client->ConvertPointFromScreen(window(), &location); |
203 return location; | 201 return location; |
204 } | 202 } |
205 | 203 |
206 void WindowEventDispatcher::OnHostLostMouseGrab() { | 204 void WindowEventDispatcher::OnHostLostMouseGrab() { |
207 mouse_pressed_handler_ = NULL; | 205 mouse_pressed_handler_ = NULL; |
sadrul
2014/06/26 12:59:35
Is it necessary to make the same changes in here?
pkotwicz
2014/06/26 14:45:17
I need to investigate why OnHostLostMouseGrab() is
| |
208 mouse_moved_handler_ = NULL; | 206 mouse_moved_handler_ = NULL; |
209 } | 207 } |
210 | 208 |
211 void WindowEventDispatcher::OnCursorMovedToRootLocation( | 209 void WindowEventDispatcher::OnCursorMovedToRootLocation( |
212 const gfx::Point& root_location) { | 210 const gfx::Point& root_location) { |
213 SetLastMouseLocation(window(), root_location); | 211 SetLastMouseLocation(window(), root_location); |
214 synthesize_mouse_move_ = false; | 212 synthesize_mouse_move_ = false; |
215 } | 213 } |
216 | 214 |
217 void WindowEventDispatcher::OnPostNotifiedWindowDestroying(Window* window) { | 215 void WindowEventDispatcher::OnPostNotifiedWindowDestroying(Window* window) { |
(...skipping 17 matching lines...) Expand all Loading... | |
235 } | 233 } |
236 | 234 |
237 void WindowEventDispatcher::DispatchMouseExitToHidingWindow(Window* window) { | 235 void WindowEventDispatcher::DispatchMouseExitToHidingWindow(Window* window) { |
238 // The mouse capture is intentionally ignored. Think that a mouse enters | 236 // The mouse capture is intentionally ignored. Think that a mouse enters |
239 // to a window, the window sets the capture, the mouse exits the window, | 237 // to a window, the window sets the capture, the mouse exits the window, |
240 // and then it releases the capture. In that case OnMouseExited won't | 238 // and then it releases the capture. In that case OnMouseExited won't |
241 // be called. So it is natural not to emit OnMouseExited even though | 239 // be called. So it is natural not to emit OnMouseExited even though |
242 // |window| is the capture window. | 240 // |window| is the capture window. |
243 gfx::Point last_mouse_location = GetLastMouseLocationInRoot(); | 241 gfx::Point last_mouse_location = GetLastMouseLocationInRoot(); |
244 if (window->Contains(mouse_moved_handler_) && | 242 if (window->Contains(mouse_moved_handler_) && |
245 window->ContainsPointInRoot(last_mouse_location)) | 243 window->ContainsPointInRoot(last_mouse_location)) { |
246 DispatchMouseExitAtPoint(last_mouse_location); | 244 DispatchDetails details = DispatchMouseExitAtPoint(last_mouse_location); |
245 if (details.dispatcher_destroyed) | |
246 return; | |
247 } | |
247 } | 248 } |
248 | 249 |
249 ui::EventDispatchDetails WindowEventDispatcher::DispatchMouseEnterOrExit( | 250 ui::EventDispatchDetails WindowEventDispatcher::DispatchMouseEnterOrExit( |
250 const ui::MouseEvent& event, | 251 const ui::MouseEvent& event, |
251 ui::EventType type) { | 252 ui::EventType type) { |
252 if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED && | 253 if (event.type() != ui::ET_MOUSE_CAPTURE_CHANGED && |
253 !(event.flags() & ui::EF_IS_SYNTHESIZED)) { | 254 !(event.flags() & ui::EF_IS_SYNTHESIZED)) { |
254 SetLastMouseLocation(window(), event.root_location()); | 255 SetLastMouseLocation(window(), event.root_location()); |
255 } | 256 } |
256 | 257 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 } else { | 381 } else { |
381 // Make sure mouse_moved_handler gets updated. | 382 // Make sure mouse_moved_handler gets updated. |
382 DispatchDetails details = SynthesizeMouseMoveEvent(); | 383 DispatchDetails details = SynthesizeMouseMoveEvent(); |
383 if (details.dispatcher_destroyed) | 384 if (details.dispatcher_destroyed) |
384 return; | 385 return; |
385 } | 386 } |
386 mouse_pressed_handler_ = NULL; | 387 mouse_pressed_handler_ = NULL; |
387 } | 388 } |
388 | 389 |
389 void WindowEventDispatcher::OnOtherRootGotCapture() { | 390 void WindowEventDispatcher::OnOtherRootGotCapture() { |
391 if (mouse_moved_handler_) { | |
392 // Dispatch a mouse exit to reset any state associated with hover. This is | |
393 // important when going from no window having capture to a window having | |
394 // capture because we do not dispatch ET_MOUSE_CAPTURE_CHANGED in this case. | |
395 DispatchDetails details = DispatchMouseExitAtPoint( | |
396 GetLastMouseLocationInRoot()); | |
397 if (details.dispatcher_destroyed) | |
398 return; | |
399 } | |
400 | |
390 mouse_moved_handler_ = NULL; | 401 mouse_moved_handler_ = NULL; |
391 mouse_pressed_handler_ = NULL; | 402 mouse_pressed_handler_ = NULL; |
392 } | 403 } |
393 | 404 |
394 void WindowEventDispatcher::SetNativeCapture() { | 405 void WindowEventDispatcher::SetNativeCapture() { |
395 host_->SetCapture(); | 406 host_->SetCapture(); |
396 } | 407 } |
397 | 408 |
398 void WindowEventDispatcher::ReleaseNativeCapture() { | 409 void WindowEventDispatcher::ReleaseNativeCapture() { |
399 host_->ReleaseCapture(); | 410 host_->ReleaseCapture(); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
843 break; | 854 break; |
844 | 855 |
845 default: | 856 default: |
846 NOTREACHED(); | 857 NOTREACHED(); |
847 break; | 858 break; |
848 } | 859 } |
849 PreDispatchLocatedEvent(target, event); | 860 PreDispatchLocatedEvent(target, event); |
850 } | 861 } |
851 | 862 |
852 } // namespace aura | 863 } // namespace aura |
OLD | NEW |