| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/root_window.h" | 5 #include "ui/aura/root_window.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 DispatchDetails details; | 618 DispatchDetails details; |
| 619 if (target != event_dispatch_target_) | 619 if (target != event_dispatch_target_) |
| 620 details.target_destroyed = true; | 620 details.target_destroyed = true; |
| 621 event_dispatch_target_ = old_dispatch_target_; | 621 event_dispatch_target_ = old_dispatch_target_; |
| 622 old_dispatch_target_ = NULL; | 622 old_dispatch_target_ = NULL; |
| 623 #ifndef NDEBUG | 623 #ifndef NDEBUG |
| 624 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); | 624 DCHECK(!event_dispatch_target_ || window()->Contains(event_dispatch_target_)); |
| 625 #endif | 625 #endif |
| 626 | 626 |
| 627 if (event.IsTouchEvent() && !details.target_destroyed) { | 627 if (event.IsTouchEvent() && !details.target_destroyed) { |
| 628 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), | 628 // Do not let 'held' touch events contribute to any gestures. |
| 629 static_cast<Window*>(event.target()), window()); | 629 if (!held_move_event_ || !held_move_event_->IsTouchEvent()) { |
| 630 // Get the list of GestureEvents from GestureRecognizer. | 630 ui::TouchEvent orig_event(static_cast<const ui::TouchEvent&>(event), |
| 631 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; | 631 static_cast<Window*>(event.target()), window()); |
| 632 gestures.reset(ui::GestureRecognizer::Get()-> | 632 // Get the list of GestureEvents from GestureRecognizer. |
| 633 ProcessTouchEventForGesture(orig_event, event.result(), | 633 scoped_ptr<ui::GestureRecognizer::Gestures> gestures; |
| 634 static_cast<Window*>(target))); | 634 gestures.reset(ui::GestureRecognizer::Get()-> |
| 635 return ProcessGestures(gestures.get()); | 635 ProcessTouchEventForGesture(orig_event, event.result(), |
| 636 static_cast<Window*>(target))); |
| 637 return ProcessGestures(gestures.get()); |
| 638 } |
| 636 } | 639 } |
| 637 | 640 |
| 638 return details; | 641 return details; |
| 639 } | 642 } |
| 640 | 643 |
| 641 //////////////////////////////////////////////////////////////////////////////// | 644 //////////////////////////////////////////////////////////////////////////////// |
| 642 // RootWindow, ui::GestureEventHelper implementation: | 645 // RootWindow, ui::GestureEventHelper implementation: |
| 643 | 646 |
| 644 bool RootWindow::CanDispatchToConsumer(ui::GestureConsumer* consumer) { | 647 bool RootWindow::CanDispatchToConsumer(ui::GestureConsumer* consumer) { |
| 645 Window* consumer_window = ConsumerToWindow(consumer);; | 648 Window* consumer_window = ConsumerToWindow(consumer);; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 return this; | 757 return this; |
| 755 } | 758 } |
| 756 | 759 |
| 757 //////////////////////////////////////////////////////////////////////////////// | 760 //////////////////////////////////////////////////////////////////////////////// |
| 758 // RootWindow, private: | 761 // RootWindow, private: |
| 759 | 762 |
| 760 ui::EventDispatchDetails RootWindow::OnHostMouseEventImpl( | 763 ui::EventDispatchDetails RootWindow::OnHostMouseEventImpl( |
| 761 ui::MouseEvent* event) { | 764 ui::MouseEvent* event) { |
| 762 if (IsEventCandidateForHold(*event)) { | 765 if (IsEventCandidateForHold(*event)) { |
| 763 if (move_hold_count_) { | 766 if (move_hold_count_) { |
| 764 Window* null_window = static_cast<Window*>(NULL); | 767 held_move_event_.reset(new ui::MouseEvent(*event)); |
| 765 held_move_event_.reset( | |
| 766 new ui::MouseEvent(*event, null_window, null_window)); | |
| 767 event->SetHandled(); | 768 event->SetHandled(); |
| 768 return DispatchDetails(); | 769 return DispatchDetails(); |
| 769 } else { | 770 } else { |
| 770 // We may have a held event for a period between the time move_hold_count_ | 771 // We may have a held event for a period between the time move_hold_count_ |
| 771 // fell to 0 and the DispatchHeldEvents executes. Since we're going to | 772 // fell to 0 and the DispatchHeldEvents executes. Since we're going to |
| 772 // dispatch the new event directly below, we can reset the old one. | 773 // dispatch the new event directly below, we can reset the old one. |
| 773 held_move_event_.reset(); | 774 held_move_event_.reset(); |
| 774 } | 775 } |
| 775 } | 776 } |
| 776 DispatchDetails details = DispatchHeldEvents(); | 777 DispatchDetails details = DispatchHeldEvents(); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 break; | 994 break; |
| 994 // fallthrough | 995 // fallthrough |
| 995 case ui::ET_TOUCH_RELEASED: | 996 case ui::ET_TOUCH_RELEASED: |
| 996 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^ | 997 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^ |
| 997 (1 << event->touch_id()); | 998 (1 << event->touch_id()); |
| 998 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); | 999 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); |
| 999 break; | 1000 break; |
| 1000 | 1001 |
| 1001 case ui::ET_TOUCH_MOVED: | 1002 case ui::ET_TOUCH_MOVED: |
| 1002 if (move_hold_count_) { | 1003 if (move_hold_count_) { |
| 1003 held_move_event_.reset(new ui::TouchEvent(*event)); | 1004 held_move_event_.reset(new ui::TouchEvent(*event, target, window())); |
| 1004 event->SetHandled(); | 1005 event->SetHandled(); |
| 1005 return; | 1006 return; |
| 1006 } | 1007 } |
| 1007 break; | 1008 break; |
| 1008 | 1009 |
| 1009 default: | 1010 default: |
| 1010 NOTREACHED(); | 1011 NOTREACHED(); |
| 1011 break; | 1012 break; |
| 1012 } | 1013 } |
| 1013 PreDispatchLocatedEvent(target, event); | 1014 PreDispatchLocatedEvent(target, event); |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1016 } // namespace aura | 1017 } // namespace aura |
| OLD | NEW |