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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return false; | 68 return false; |
69 } | 69 } |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 //////////////////////////////////////////////////////////////////////////////// | 73 //////////////////////////////////////////////////////////////////////////////// |
74 // WindowEventDispatcher, public: | 74 // WindowEventDispatcher, public: |
75 | 75 |
76 WindowEventDispatcher::WindowEventDispatcher(WindowTreeHost* host) | 76 WindowEventDispatcher::WindowEventDispatcher(WindowTreeHost* host) |
77 : host_(host), | 77 : host_(host), |
78 touch_ids_down_(0), | |
79 mouse_pressed_handler_(NULL), | 78 mouse_pressed_handler_(NULL), |
80 mouse_moved_handler_(NULL), | 79 mouse_moved_handler_(NULL), |
81 event_dispatch_target_(NULL), | 80 event_dispatch_target_(NULL), |
82 old_dispatch_target_(NULL), | 81 old_dispatch_target_(NULL), |
83 synthesize_mouse_move_(false), | 82 synthesize_mouse_move_(false), |
84 move_hold_count_(0), | 83 move_hold_count_(0), |
85 dispatching_held_event_(nullptr), | 84 dispatching_held_event_(nullptr), |
86 observer_manager_(this), | 85 observer_manager_(this), |
87 repost_event_factory_(this), | 86 repost_event_factory_(this), |
88 held_event_factory_(this) { | 87 held_event_factory_(this) { |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 break; | 845 break; |
847 } | 846 } |
848 | 847 |
849 PreDispatchLocatedEvent(target, event); | 848 PreDispatchLocatedEvent(target, event); |
850 } | 849 } |
851 | 850 |
852 void WindowEventDispatcher::PreDispatchTouchEvent(Window* target, | 851 void WindowEventDispatcher::PreDispatchTouchEvent(Window* target, |
853 ui::TouchEvent* event) { | 852 ui::TouchEvent* event) { |
854 switch (event->type()) { | 853 switch (event->type()) { |
855 case ui::ET_TOUCH_PRESSED: | 854 case ui::ET_TOUCH_PRESSED: |
856 touch_ids_down_ |= (1 << event->touch_id()); | 855 touch_ids_down_.insert(event->touch_id()); |
857 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); | 856 Env::GetInstance()->set_touch_down(!touch_ids_down_.empty()); |
858 break; | 857 break; |
859 | 858 |
860 // Handle ET_TOUCH_CANCELLED only if it has a native event. | 859 // Handle ET_TOUCH_CANCELLED only if it has a native event. |
861 case ui::ET_TOUCH_CANCELLED: | 860 case ui::ET_TOUCH_CANCELLED: |
862 if (!event->HasNativeEvent()) | 861 if (!event->HasNativeEvent()) |
863 break; | 862 break; |
864 // fallthrough | 863 // fallthrough |
865 case ui::ET_TOUCH_RELEASED: | 864 case ui::ET_TOUCH_RELEASED: |
866 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^ | 865 touch_ids_down_.erase(event->touch_id()); |
867 (1 << event->touch_id()); | 866 Env::GetInstance()->set_touch_down(!touch_ids_down_.empty()); |
868 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); | |
869 break; | 867 break; |
870 | 868 |
871 case ui::ET_TOUCH_MOVED: | 869 case ui::ET_TOUCH_MOVED: |
872 if (move_hold_count_ && !dispatching_held_event_) { | 870 if (move_hold_count_ && !dispatching_held_event_) { |
873 held_move_event_.reset(new ui::TouchEvent(*event, target, window())); | 871 held_move_event_.reset(new ui::TouchEvent(*event, target, window())); |
874 event->SetHandled(); | 872 event->SetHandled(); |
875 return; | 873 return; |
876 } | 874 } |
877 break; | 875 break; |
878 | 876 |
(...skipping 12 matching lines...) Expand all Loading... |
891 } | 889 } |
892 | 890 |
893 // This flag is set depending on the gestures recognized in the call above, | 891 // This flag is set depending on the gestures recognized in the call above, |
894 // and needs to propagate with the forwarded event. | 892 // and needs to propagate with the forwarded event. |
895 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); | 893 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); |
896 | 894 |
897 PreDispatchLocatedEvent(target, event); | 895 PreDispatchLocatedEvent(target, event); |
898 } | 896 } |
899 | 897 |
900 } // namespace aura | 898 } // namespace aura |
OLD | NEW |