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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 TRACE_EVENT_ASYNC_BEGIN0("ui", "RootWindow::Draw", | 265 TRACE_EVENT_ASYNC_BEGIN0("ui", "RootWindow::Draw", |
266 compositor_->last_started_frame() + 1); | 266 compositor_->last_started_frame() + 1); |
267 | 267 |
268 compositor_->Draw(false); | 268 compositor_->Draw(false); |
269 } | 269 } |
270 | 270 |
271 void RootWindow::ScheduleFullDraw() { | 271 void RootWindow::ScheduleFullDraw() { |
272 compositor_->ScheduleFullDraw(); | 272 compositor_->ScheduleFullDraw(); |
273 } | 273 } |
274 | 274 |
275 bool RootWindow::DispatchGestureEvent(ui::GestureEventImpl* event) { | 275 bool RootWindow::DispatchGestureEvent(ui::GestureEvent* event) { |
276 DispatchHeldMouseMove(); | 276 DispatchHeldMouseMove(); |
277 | 277 |
278 Window* target = client::GetCaptureWindow(this); | 278 Window* target = client::GetCaptureWindow(this); |
279 if (!target) { | 279 if (!target) { |
280 target = ConsumerToWindow( | 280 target = ConsumerToWindow( |
281 gesture_recognizer_->GetTargetForGestureEvent(event)); | 281 gesture_recognizer_->GetTargetForGestureEvent(event)); |
282 if (!target) | 282 if (!target) |
283 return false; | 283 return false; |
284 } | 284 } |
285 | 285 |
286 if (target) { | 286 if (target) { |
287 ui::GestureEventImpl translated_event( | 287 ui::GestureEvent translated_event( |
288 *event, static_cast<Window*>(this), target); | 288 *event, static_cast<Window*>(this), target); |
289 ui::GestureStatus status = ProcessGestureEvent(target, &translated_event); | 289 ui::GestureStatus status = ProcessGestureEvent(target, &translated_event); |
290 return status != ui::GESTURE_STATUS_UNKNOWN; | 290 return status != ui::GESTURE_STATUS_UNKNOWN; |
291 } | 291 } |
292 | 292 |
293 return false; | 293 return false; |
294 } | 294 } |
295 | 295 |
296 void RootWindow::OnWindowDestroying(Window* window) { | 296 void RootWindow::OnWindowDestroying(Window* window) { |
297 OnWindowHidden(window, true); | 297 OnWindowHidden(window, true); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 return status; | 652 return status; |
653 } | 653 } |
654 | 654 |
655 if (target->delegate()) | 655 if (target->delegate()) |
656 return target->delegate()->OnTouchEvent(event); | 656 return target->delegate()->OnTouchEvent(event); |
657 | 657 |
658 return ui::TOUCH_STATUS_UNKNOWN; | 658 return ui::TOUCH_STATUS_UNKNOWN; |
659 } | 659 } |
660 | 660 |
661 ui::GestureStatus RootWindow::ProcessGestureEvent(Window* target, | 661 ui::GestureStatus RootWindow::ProcessGestureEvent(Window* target, |
662 ui::GestureEventImpl* event) { | 662 ui::GestureEvent* event) { |
663 if (!target->IsVisible()) | 663 if (!target->IsVisible()) |
664 return ui::GESTURE_STATUS_UNKNOWN; | 664 return ui::GESTURE_STATUS_UNKNOWN; |
665 | 665 |
666 EventFilters filters; | 666 EventFilters filters; |
667 if (target == this) | 667 if (target == this) |
668 GetEventFiltersToNotify(target, &filters); | 668 GetEventFiltersToNotify(target, &filters); |
669 else | 669 else |
670 GetEventFiltersToNotify(target->parent(), &filters); | 670 GetEventFiltersToNotify(target->parent(), &filters); |
671 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; | 671 ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; |
672 for (EventFilters::const_reverse_iterator it = filters.rbegin(), | 672 for (EventFilters::const_reverse_iterator it = filters.rbegin(), |
673 rend = filters.rend(); | 673 rend = filters.rend(); |
674 it != rend; ++it) { | 674 it != rend; ++it) { |
675 status = (*it)->PreHandleGestureEvent(target, event); | 675 status = (*it)->PreHandleGestureEvent(target, event); |
676 if (status != ui::GESTURE_STATUS_UNKNOWN) | 676 if (status != ui::GESTURE_STATUS_UNKNOWN) |
677 return status; | 677 return status; |
678 } | 678 } |
679 | 679 |
680 if (target->delegate()) | 680 if (target->delegate()) |
681 status = target->delegate()->OnGestureEvent(event); | 681 status = target->delegate()->OnGestureEvent(event); |
682 | 682 |
683 return status; | 683 return status; |
684 } | 684 } |
685 | 685 |
686 bool RootWindow::ProcessGestures(ui::GestureRecognizer::Gestures* gestures) { | 686 bool RootWindow::ProcessGestures(ui::GestureRecognizer::Gestures* gestures) { |
687 if (!gestures) | 687 if (!gestures) |
688 return false; | 688 return false; |
689 bool handled = false; | 689 bool handled = false; |
690 for (unsigned int i = 0; i < gestures->size(); i++) { | 690 for (unsigned int i = 0; i < gestures->size(); i++) { |
691 ui::GestureEventImpl* gesture = | 691 ui::GestureEvent* gesture = |
692 static_cast<ui::GestureEventImpl*>(gestures->get().at(i)); | 692 static_cast<ui::GestureEvent*>(gestures->get().at(i)); |
693 if (DispatchGestureEvent(gesture) != ui::GESTURE_STATUS_UNKNOWN) | 693 if (DispatchGestureEvent(gesture) != ui::GESTURE_STATUS_UNKNOWN) |
694 handled = true; | 694 handled = true; |
695 } | 695 } |
696 return handled; | 696 return handled; |
697 } | 697 } |
698 | 698 |
699 void RootWindow::OnWindowRemovedFromRootWindow(Window* detached) { | 699 void RootWindow::OnWindowRemovedFromRootWindow(Window* detached) { |
700 DCHECK(aura::client::GetCaptureWindow(this) != this); | 700 DCHECK(aura::client::GetCaptureWindow(this) != this); |
701 | 701 |
702 OnWindowHidden(detached, false); | 702 OnWindowHidden(detached, false); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 gesture_recognizer_->FlushTouchQueue(invisible); | 748 gesture_recognizer_->FlushTouchQueue(invisible); |
749 } | 749 } |
750 | 750 |
751 void RootWindow::OnWindowAddedToRootWindow(Window* attached) { | 751 void RootWindow::OnWindowAddedToRootWindow(Window* attached) { |
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::GestureEvent*>(event)); |
759 } | 759 } |
760 | 760 |
761 bool RootWindow::DispatchCancelTouchEvent(ui::TouchEvent* event) { | 761 bool RootWindow::DispatchCancelTouchEvent(ui::TouchEvent* event) { |
762 return OnHostTouchEvent(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::GestureEvent(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::TouchEvent(type, location, touch_id, time_stamp); | 779 return new ui::TouchEvent(type, location, touch_id, time_stamp); |
780 } | 780 } |
781 | 781 |
(...skipping 271 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 |