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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 ui::GestureRecognizer::Gestures gestures) { | 302 ui::GestureRecognizer::Gestures gestures) { |
303 DispatchDetails details; | 303 DispatchDetails details; |
304 if (gestures.empty()) | 304 if (gestures.empty()) |
305 return details; | 305 return details; |
306 | 306 |
307 // If a window has been hidden between the touch event and now, the associated | 307 // If a window has been hidden between the touch event and now, the associated |
308 // gestures may not have a valid target. | 308 // gestures may not have a valid target. |
309 if (!target) | 309 if (!target) |
310 return details; | 310 return details; |
311 | 311 |
312 WindowEventDispatcher* dispatcher = this; | |
312 for (const auto& event : gestures) { | 313 for (const auto& event : gestures) { |
313 event->ConvertLocationToTarget(window(), target); | 314 event->ConvertLocationToTarget(dispatcher->window(), target); |
314 details = DispatchEvent(target, event.get()); | 315 details = dispatcher->DispatchEvent(target, event.get()); |
315 if (details.dispatcher_destroyed || details.target_destroyed) | 316 if (details.dispatcher_destroyed || details.target_destroyed) |
316 break; | 317 break; |
318 // If the target window has moved off to a different WindowTreeHost, then | |
319 // reroute them to the right place. | |
320 if (!dispatcher->window()->Contains(target)) | |
321 dispatcher = target->GetHost()->dispatcher(); | |
sadrul
2017/04/27 02:33:31
We should no longer need this change. If you want
weidongg
2017/04/27 03:07:32
Sure, I could leave this file untouched, as Window
| |
317 } | 322 } |
318 return details; | 323 return details; |
319 } | 324 } |
320 | 325 |
321 void WindowEventDispatcher::OnWindowHidden(Window* invisible, | 326 void WindowEventDispatcher::OnWindowHidden(Window* invisible, |
322 WindowHiddenReason reason) { | 327 WindowHiddenReason reason) { |
323 // If the window the mouse was pressed in becomes invisible, it should no | 328 // If the window the mouse was pressed in becomes invisible, it should no |
324 // longer receive mouse events. | 329 // longer receive mouse events. |
325 if (invisible->Contains(mouse_pressed_handler_)) | 330 if (invisible->Contains(mouse_pressed_handler_)) |
326 mouse_pressed_handler_ = NULL; | 331 mouse_pressed_handler_ = NULL; |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
921 } | 926 } |
922 | 927 |
923 // This flag is set depending on the gestures recognized in the call above, | 928 // This flag is set depending on the gestures recognized in the call above, |
924 // and needs to propagate with the forwarded event. | 929 // and needs to propagate with the forwarded event. |
925 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); | 930 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); |
926 | 931 |
927 return PreDispatchLocatedEvent(target, event); | 932 return PreDispatchLocatedEvent(target, event); |
928 } | 933 } |
929 | 934 |
930 } // namespace aura | 935 } // namespace aura |
OLD | NEW |