| 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/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 typedef std::vector<EventFilter*> EventFilters; | 59 typedef std::vector<EventFilter*> EventFilters; |
| 60 | 60 |
| 61 void GetEventFiltersToNotify(Window* target, EventFilters* filters) { | 61 void GetEventFiltersToNotify(Window* target, EventFilters* filters) { |
| 62 while (target) { | 62 while (target) { |
| 63 if (target->event_filter()) | 63 if (target->event_filter()) |
| 64 filters->push_back(target->event_filter()); | 64 filters->push_back(target->event_filter()); |
| 65 target = target->parent(); | 65 target = target->parent(); |
| 66 } | 66 } |
| 67 if (Env::GetInstance()->event_filter()) | |
| 68 filters->push_back(Env::GetInstance()->event_filter()); | |
| 69 } | 67 } |
| 70 | 68 |
| 71 float GetDeviceScaleFactorFromDisplay(const Window* window) { | 69 float GetDeviceScaleFactorFromDisplay(const Window* window) { |
| 72 DisplayManager* display_manager = Env::GetInstance()->display_manager(); | 70 DisplayManager* display_manager = Env::GetInstance()->display_manager(); |
| 73 return display_manager->GetDisplayNearestWindow(window).device_scale_factor(); | 71 return display_manager->GetDisplayNearestWindow(window).device_scale_factor(); |
| 74 } | 72 } |
| 75 | 73 |
| 76 Window* ConsumerToWindow(ui::GestureConsumer* consumer) { | 74 Window* ConsumerToWindow(ui::GestureConsumer* consumer) { |
| 77 return consumer && !consumer->ignores_events() ? | 75 return consumer && !consumer->ignores_events() ? |
| 78 static_cast<Window*>(consumer) : NULL; | 76 static_cast<Window*>(consumer) : NULL; |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 } | 655 } |
| 658 | 656 |
| 659 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, | 657 ui::TouchStatus RootWindow::ProcessTouchEvent(Window* target, |
| 660 ui::TouchEvent* event) { | 658 ui::TouchEvent* event) { |
| 661 if (ProcessEvent(NULL, event) != ui::ER_UNHANDLED) | 659 if (ProcessEvent(NULL, event) != ui::ER_UNHANDLED) |
| 662 return ui::TOUCH_STATUS_CONTINUE; | 660 return ui::TOUCH_STATUS_CONTINUE; |
| 663 | 661 |
| 664 if (!target->IsVisible()) | 662 if (!target->IsVisible()) |
| 665 return ui::TOUCH_STATUS_UNKNOWN; | 663 return ui::TOUCH_STATUS_UNKNOWN; |
| 666 | 664 |
| 665 ui::Event::DispatcherApi dispatch_helper(event); |
| 666 dispatch_helper.set_target(target); |
| 667 |
| 668 const ui::EventHandlerList& pre_target = |
| 669 Env::GetInstance()->pre_target_handlers(); |
| 670 for (ui::EventHandlerList::const_iterator iter = pre_target.begin(); |
| 671 iter != pre_target.end(); ++iter) { |
| 672 ui::TouchStatus status = (*iter)->OnTouchEvent(event); |
| 673 if (status != ui::TOUCH_STATUS_UNKNOWN) |
| 674 return status; |
| 675 } |
| 676 |
| 667 EventFilters filters; | 677 EventFilters filters; |
| 668 if (target == this) | 678 if (target == this) |
| 669 GetEventFiltersToNotify(target, &filters); | 679 GetEventFiltersToNotify(target, &filters); |
| 670 else | 680 else |
| 671 GetEventFiltersToNotify(target->parent(), &filters); | 681 GetEventFiltersToNotify(target->parent(), &filters); |
| 672 | 682 |
| 673 // |target| can be deleted by any of the handlers below. | 683 // |target| can be deleted by any of the handlers below. |
| 674 WindowTracker tracker; | 684 WindowTracker tracker; |
| 675 tracker.Add(target); | 685 tracker.Add(target); |
| 676 | 686 |
| 677 ui::Event::DispatcherApi dispatcher(event); | |
| 678 dispatcher.set_target(target); | |
| 679 for (EventFilters::const_reverse_iterator it = filters.rbegin(), | 687 for (EventFilters::const_reverse_iterator it = filters.rbegin(), |
| 680 rend = filters.rend(); | 688 rend = filters.rend(); |
| 681 it != rend; ++it) { | 689 it != rend; ++it) { |
| 682 ui::TouchStatus status = (*it)->PreHandleTouchEvent(target, event); | 690 ui::TouchStatus status = (*it)->PreHandleTouchEvent(target, event); |
| 683 if (status != ui::TOUCH_STATUS_UNKNOWN) | 691 if (status != ui::TOUCH_STATUS_UNKNOWN) |
| 684 return status; | 692 return status; |
| 685 } | 693 } |
| 686 | 694 |
| 687 if (tracker.Contains(target) && target->delegate()) { | 695 if (tracker.Contains(target) && target->delegate()) { |
| 688 ui::TouchStatus status = target->delegate()->OnTouchEvent(event); | 696 ui::TouchStatus status = target->delegate()->OnTouchEvent(event); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 if (attached->IsVisible() && | 792 if (attached->IsVisible() && |
| 785 attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) | 793 attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) |
| 786 PostMouseMoveEventAfterWindowChange(); | 794 PostMouseMoveEventAfterWindowChange(); |
| 787 } | 795 } |
| 788 | 796 |
| 789 bool RootWindow::CanDispatchToTarget(ui::EventTarget* target) { | 797 bool RootWindow::CanDispatchToTarget(ui::EventTarget* target) { |
| 790 return event_dispatch_target_ == target; | 798 return event_dispatch_target_ == target; |
| 791 } | 799 } |
| 792 | 800 |
| 793 void RootWindow::ProcessPreTargetList(ui::EventHandlerList* list) { | 801 void RootWindow::ProcessPreTargetList(ui::EventHandlerList* list) { |
| 794 if (Env::GetInstance()->event_filter()) | 802 const ui::EventHandlerList& pre_target = |
| 795 list->insert(list->begin(), Env::GetInstance()->event_filter()); | 803 Env::GetInstance()->pre_target_handlers(); |
| 804 if (pre_target.size() > 0) |
| 805 list->insert(list->begin(), pre_target.begin(), pre_target.end()); |
| 796 } | 806 } |
| 797 | 807 |
| 798 void RootWindow::ProcessPostTargetList(ui::EventHandlerList* list) { | 808 void RootWindow::ProcessPostTargetList(ui::EventHandlerList* list) { |
| 799 // TODO(sad): | 809 // TODO(sad): |
| 800 } | 810 } |
| 801 | 811 |
| 802 bool RootWindow::DispatchLongPressGestureEvent(ui::GestureEvent* event) { | 812 bool RootWindow::DispatchLongPressGestureEvent(ui::GestureEvent* event) { |
| 803 return DispatchGestureEvent(event); | 813 return DispatchGestureEvent(event); |
| 804 } | 814 } |
| 805 | 815 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 void RootWindow::UnlockCompositor() { | 1102 void RootWindow::UnlockCompositor() { |
| 1093 DCHECK(compositor_lock_); | 1103 DCHECK(compositor_lock_); |
| 1094 compositor_lock_ = NULL; | 1104 compositor_lock_ = NULL; |
| 1095 if (draw_on_compositor_unlock_) { | 1105 if (draw_on_compositor_unlock_) { |
| 1096 draw_on_compositor_unlock_ = false; | 1106 draw_on_compositor_unlock_ = false; |
| 1097 ScheduleDraw(); | 1107 ScheduleDraw(); |
| 1098 } | 1108 } |
| 1099 } | 1109 } |
| 1100 | 1110 |
| 1101 } // namespace aura | 1111 } // namespace aura |
| OLD | NEW |