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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 if ((*it)->PreHandleKeyEvent(target, event)) | 628 if ((*it)->PreHandleKeyEvent(target, event)) |
629 return true; | 629 return true; |
630 } | 630 } |
631 | 631 |
632 if (!target->delegate()) | 632 if (!target->delegate()) |
633 return false; | 633 return false; |
634 return target->delegate()->OnKeyEvent(event); | 634 return target->delegate()->OnKeyEvent(event); |
635 } | 635 } |
636 | 636 |
637 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, | 637 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, |
638 ui::TouchEventImpl* event) { | 638 ui::TouchEvent* event) { |
639 if (!target->IsVisible()) | 639 if (!target->IsVisible()) |
640 return ui::TOUCH_STATUS_UNKNOWN; | 640 return ui::TOUCH_STATUS_UNKNOWN; |
641 | 641 |
642 EventFilters filters; | 642 EventFilters filters; |
643 if (target == this) | 643 if (target == this) |
644 GetEventFiltersToNotify(target, &filters); | 644 GetEventFiltersToNotify(target, &filters); |
645 else | 645 else |
646 GetEventFiltersToNotify(target->parent(), &filters); | 646 GetEventFiltersToNotify(target->parent(), &filters); |
647 for (EventFilters::const_reverse_iterator it = filters.rbegin(), | 647 for (EventFilters::const_reverse_iterator it = filters.rbegin(), |
648 rend = filters.rend(); | 648 rend = filters.rend(); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 if (attached->IsVisible() && | 752 if (attached->IsVisible() && |
753 attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) | 753 attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) |
754 PostMouseMoveEventAfterWindowChange(); | 754 PostMouseMoveEventAfterWindowChange(); |
755 } | 755 } |
756 | 756 |
757 bool RootWindow::DispatchLongPressGestureEvent(ui::GestureEvent* event) { | 757 bool RootWindow::DispatchLongPressGestureEvent(ui::GestureEvent* event) { |
758 return DispatchGestureEvent(static_cast<ui::GestureEventImpl*>(event)); | 758 return DispatchGestureEvent(static_cast<ui::GestureEventImpl*>(event)); |
759 } | 759 } |
760 | 760 |
761 bool RootWindow::DispatchCancelTouchEvent(ui::TouchEvent* event) { | 761 bool RootWindow::DispatchCancelTouchEvent(ui::TouchEvent* event) { |
762 return OnHostTouchEvent(static_cast<ui::TouchEventImpl*>(event)); | 762 return OnHostTouchEvent(event); |
763 } | 763 } |
764 | 764 |
765 ui::GestureEvent* RootWindow::CreateGestureEvent( | 765 ui::GestureEvent* RootWindow::CreateGestureEvent( |
766 const ui::GestureEventDetails& details, | 766 const ui::GestureEventDetails& details, |
767 const gfx::Point& location, | 767 const gfx::Point& location, |
768 int flags, | 768 int flags, |
769 base::Time time, | 769 base::Time time, |
770 unsigned int touch_id_bitfield) { | 770 unsigned int touch_id_bitfield) { |
771 return new ui::GestureEventImpl(details.type(), location.x(), location.y(), | 771 return new ui::GestureEventImpl(details.type(), location.x(), location.y(), |
772 flags, time, details, touch_id_bitfield); | 772 flags, time, details, touch_id_bitfield); |
773 } | 773 } |
774 | 774 |
775 ui::TouchEvent* RootWindow::CreateTouchEvent(ui::EventType type, | 775 ui::TouchEvent* RootWindow::CreateTouchEvent(ui::EventType type, |
776 const gfx::Point& location, | 776 const gfx::Point& location, |
777 int touch_id, | 777 int touch_id, |
778 base::TimeDelta time_stamp) { | 778 base::TimeDelta time_stamp) { |
779 return new ui::TouchEventImpl(type, location, touch_id, time_stamp); | 779 return new ui::TouchEvent(type, location, touch_id, time_stamp); |
780 } | 780 } |
781 | 781 |
782 void RootWindow::OnLayerAnimationEnded( | 782 void RootWindow::OnLayerAnimationEnded( |
783 ui::LayerAnimationSequence* animation) { | 783 ui::LayerAnimationSequence* animation) { |
784 OnHostResized(host_->GetBounds().size()); | 784 OnHostResized(host_->GetBounds().size()); |
785 } | 785 } |
786 | 786 |
787 void RootWindow::OnLayerAnimationScheduled( | 787 void RootWindow::OnLayerAnimationScheduled( |
788 ui::LayerAnimationSequence* animation) { | 788 ui::LayerAnimationSequence* animation) { |
789 } | 789 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 Window::ConvertPointToTarget(this, target, &location_in_window); | 849 Window::ConvertPointToTarget(this, target, &location_in_window); |
850 if (IsNonClientLocation(target, location_in_window)) | 850 if (IsNonClientLocation(target, location_in_window)) |
851 flags |= ui::EF_IS_NON_CLIENT; | 851 flags |= ui::EF_IS_NON_CLIENT; |
852 ui::ScrollEvent translated_event( | 852 ui::ScrollEvent translated_event( |
853 *event, static_cast<Window*>(this), target, event->type(), flags); | 853 *event, static_cast<Window*>(this), target, event->type(), flags); |
854 return ProcessMouseEvent(target, &translated_event); | 854 return ProcessMouseEvent(target, &translated_event); |
855 } | 855 } |
856 return false; | 856 return false; |
857 } | 857 } |
858 | 858 |
859 bool RootWindow::OnHostTouchEvent(ui::TouchEventImpl* event) { | 859 bool RootWindow::OnHostTouchEvent(ui::TouchEvent* event) { |
860 DispatchHeldMouseMove(); | 860 DispatchHeldMouseMove(); |
861 switch (event->type()) { | 861 switch (event->type()) { |
862 case ui::ET_TOUCH_PRESSED: | 862 case ui::ET_TOUCH_PRESSED: |
863 touch_ids_down_ |= (1 << event->touch_id()); | 863 touch_ids_down_ |= (1 << event->touch_id()); |
864 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); | 864 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); |
865 break; | 865 break; |
866 | 866 |
867 // Don't handle ET_TOUCH_CANCELLED since we always get a ET_TOUCH_RELEASED. | 867 // Don't handle ET_TOUCH_CANCELLED since we always get a ET_TOUCH_RELEASED. |
868 case ui::ET_TOUCH_RELEASED: | 868 case ui::ET_TOUCH_RELEASED: |
869 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^ | 869 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^ |
870 (1 << event->touch_id()); | 870 (1 << event->touch_id()); |
871 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); | 871 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); |
872 break; | 872 break; |
873 | 873 |
874 default: | 874 default: |
875 break; | 875 break; |
876 } | 876 } |
877 float scale = ui::GetDeviceScaleFactor(layer()); | 877 float scale = ui::GetDeviceScaleFactor(layer()); |
878 ui::Transform transform = layer()->transform(); | 878 ui::Transform transform = layer()->transform(); |
879 transform.ConcatScale(scale, scale); | 879 transform.ConcatScale(scale, scale); |
880 event->UpdateForRootTransform(transform); | 880 event->UpdateForRootTransform(transform); |
881 bool handled = false; | 881 bool handled = false; |
882 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; | 882 ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN; |
883 Window* target = client::GetCaptureWindow(this); | 883 Window* target = client::GetCaptureWindow(this); |
884 if (!target) { | 884 if (!target) { |
885 target = ConsumerToWindow( | 885 target = ConsumerToWindow( |
886 gesture_recognizer_->GetTouchLockedTarget(event)); | 886 gesture_recognizer_->GetTouchLockedTarget(event)); |
887 if (!target) { | 887 if (!target) { |
888 target = ConsumerToWindow( | 888 target = ConsumerToWindow( |
889 gesture_recognizer_->GetTargetForLocation(event->GetLocation())); | 889 gesture_recognizer_->GetTargetForLocation(event->location())); |
890 } | 890 } |
891 } | 891 } |
892 | 892 |
893 if (!target && !bounds().Contains(event->location())) { | 893 if (!target && !bounds().Contains(event->location())) { |
894 // If the initial touch is outside the root window, target the root. | 894 // If the initial touch is outside the root window, target the root. |
895 target = this; | 895 target = this; |
896 } else { | 896 } else { |
897 // We only come here when the first contact was within the root window. | 897 // We only come here when the first contact was within the root window. |
898 if (!target) { | 898 if (!target) { |
899 target = GetEventHandlerForPoint(event->location()); | 899 target = GetEventHandlerForPoint(event->location()); |
900 if (!target) | 900 if (!target) |
901 return false; | 901 return false; |
902 } | 902 } |
903 | 903 |
904 ui::TouchEventImpl translated_event( | 904 ui::TouchEvent translated_event( |
905 *event, static_cast<Window*>(this), target); | 905 *event, static_cast<Window*>(this), target); |
906 status = ProcessTouchEvent(target, &translated_event); | 906 status = ProcessTouchEvent(target, &translated_event); |
907 handled = status != ui::TOUCH_STATUS_UNKNOWN; | 907 handled = status != ui::TOUCH_STATUS_UNKNOWN; |
908 | 908 |
909 if (status == ui::TOUCH_STATUS_QUEUED || | 909 if (status == ui::TOUCH_STATUS_QUEUED || |
910 status == ui::TOUCH_STATUS_QUEUED_END) | 910 status == ui::TOUCH_STATUS_QUEUED_END) |
911 gesture_recognizer_->QueueTouchEventForGesture(target, *event); | 911 gesture_recognizer_->QueueTouchEventForGesture(target, *event); |
912 } | 912 } |
913 | 913 |
914 // Get the list of GestureEvents from GestureRecognizer. | 914 // Get the list of GestureEvents from GestureRecognizer. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 void RootWindow::UnlockCompositor() { | 1053 void RootWindow::UnlockCompositor() { |
1054 DCHECK(compositor_lock_); | 1054 DCHECK(compositor_lock_); |
1055 compositor_lock_ = NULL; | 1055 compositor_lock_ = NULL; |
1056 if (draw_on_compositor_unlock_) { | 1056 if (draw_on_compositor_unlock_) { |
1057 draw_on_compositor_unlock_ = false; | 1057 draw_on_compositor_unlock_ = false; |
1058 ScheduleDraw(); | 1058 ScheduleDraw(); |
1059 } | 1059 } |
1060 } | 1060 } |
1061 | 1061 |
1062 } // namespace aura | 1062 } // namespace aura |
OLD | NEW |