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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 if (!target) { | 304 if (!target) { |
305 target = static_cast<Window*>( | 305 target = static_cast<Window*>( |
306 gesture_recognizer_->GetTargetForLocation(event->GetLocation())); | 306 gesture_recognizer_->GetTargetForLocation(event->GetLocation())); |
307 } | 307 } |
308 | 308 |
309 if (!target && !bounds().Contains(event->location())) { | 309 if (!target && !bounds().Contains(event->location())) { |
310 // If the touch is outside the root window, set its target to the | 310 // If the touch is outside the root window, set its target to the |
311 // root window. | 311 // root window. |
312 target = this; | 312 target = this; |
313 } else { | 313 } else { |
| 314 // We only come here when the first contact was within the root window. |
314 if (!target) | 315 if (!target) |
315 target = GetEventHandlerForPoint(event->location()); | 316 target = GetEventHandlerForPoint(event->location()); |
316 if (!target) | 317 if (!target) |
317 return false; | 318 return false; |
318 | 319 |
319 TouchEvent translated_event(*event, this, target); | 320 TouchEvent translated_event(*event, this, target); |
320 status = ProcessTouchEvent(target, &translated_event); | 321 status = ProcessTouchEvent(target, &translated_event); |
321 handled = status != ui::TOUCH_STATUS_UNKNOWN; | 322 handled = status != ui::TOUCH_STATUS_UNKNOWN; |
322 | 323 |
323 if (status == ui::TOUCH_STATUS_QUEUED || | 324 if (status == ui::TOUCH_STATUS_QUEUED || |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 return false; | 653 return false; |
653 return target->delegate()->OnKeyEvent(event); | 654 return target->delegate()->OnKeyEvent(event); |
654 } | 655 } |
655 | 656 |
656 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, | 657 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, |
657 TouchEvent* event) { | 658 TouchEvent* event) { |
658 if (!target->IsVisible()) | 659 if (!target->IsVisible()) |
659 return ui::TOUCH_STATUS_UNKNOWN; | 660 return ui::TOUCH_STATUS_UNKNOWN; |
660 | 661 |
661 EventFilters filters; | 662 EventFilters filters; |
662 GetEventFiltersToNotify(target->parent(), &filters); | 663 if (target == this) |
| 664 GetEventFiltersToNotify(target, &filters); |
| 665 else |
| 666 GetEventFiltersToNotify(target->parent(), &filters); |
663 for (EventFilters::const_reverse_iterator it = filters.rbegin(), | 667 for (EventFilters::const_reverse_iterator it = filters.rbegin(), |
664 rend = filters.rend(); | 668 rend = filters.rend(); |
665 it != rend; ++it) { | 669 it != rend; ++it) { |
666 ui::TouchStatus status = (*it)->PreHandleTouchEvent(target, event); | 670 ui::TouchStatus status = (*it)->PreHandleTouchEvent(target, event); |
667 if (status != ui::TOUCH_STATUS_UNKNOWN) | 671 if (status != ui::TOUCH_STATUS_UNKNOWN) |
668 return status; | 672 return status; |
669 } | 673 } |
670 | 674 |
671 return target->delegate()->OnTouchEvent(event); | 675 if (target->delegate()) |
| 676 return target->delegate()->OnTouchEvent(event); |
| 677 |
| 678 return ui::TOUCH_STATUS_UNKNOWN; |
672 } | 679 } |
673 | 680 |
674 ui::GestureStatus RootWindow::ProcessGestureEvent(Window* target, | 681 ui::GestureStatus RootWindow::ProcessGestureEvent(Window* target, |
675 GestureEvent* event) { | 682 GestureEvent* event) { |
676 if (!target->IsVisible()) | 683 if (!target->IsVisible()) |
677 return ui::GESTURE_STATUS_UNKNOWN; | 684 return ui::GESTURE_STATUS_UNKNOWN; |
678 | 685 |
679 EventFilters filters; | 686 EventFilters filters; |
680 if (target == this) | 687 if (target == this) |
681 GetEventFiltersToNotify(target, &filters); | 688 GetEventFiltersToNotify(target, &filters); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 void RootWindow::UnlockCompositor() { | 993 void RootWindow::UnlockCompositor() { |
987 DCHECK(compositor_lock_); | 994 DCHECK(compositor_lock_); |
988 compositor_lock_ = NULL; | 995 compositor_lock_ = NULL; |
989 if (draw_on_compositor_unlock_) { | 996 if (draw_on_compositor_unlock_) { |
990 draw_on_compositor_unlock_ = false; | 997 draw_on_compositor_unlock_ = false; |
991 ScheduleDraw(); | 998 ScheduleDraw(); |
992 } | 999 } |
993 } | 1000 } |
994 | 1001 |
995 } // namespace aura | 1002 } // namespace aura |
OLD | NEW |