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/views/widget/root_view.h" | 5 #include "ui/views/widget/root_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "ui/base/accessibility/accessible_view_state.h" | 11 #include "ui/base/accessibility/accessible_view_state.h" |
12 #include "ui/base/dragdrop/drag_drop_types.h" | 12 #include "ui/base/dragdrop/drag_drop_types.h" |
13 #include "ui/compositor/layer.h" | 13 #include "ui/compositor/layer.h" |
14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
15 #include "ui/events/keycodes/keyboard_codes.h" | 15 #include "ui/events/keycodes/keyboard_codes.h" |
16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
17 #include "ui/views/focus/view_storage.h" | 17 #include "ui/views/focus/view_storage.h" |
18 #include "ui/views/layout/fill_layout.h" | 18 #include "ui/views/layout/fill_layout.h" |
| 19 #include "ui/views/views_switches.h" |
19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
20 #include "ui/views/widget/widget_delegate.h" | 21 #include "ui/views/widget/widget_delegate.h" |
21 #include "ui/views/widget/widget_deletion_observer.h" | 22 #include "ui/views/widget/widget_deletion_observer.h" |
22 | 23 |
23 #if defined(USE_AURA) | 24 #if defined(USE_AURA) |
24 #include "ui/base/cursor/cursor.h" | 25 #include "ui/base/cursor/cursor.h" |
25 #endif | 26 #endif |
26 | 27 |
27 namespace views { | 28 namespace views { |
28 namespace internal { | 29 namespace internal { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // events are not dispatched to any views. | 280 // events are not dispatched to any views. |
280 switch (event->type()) { | 281 switch (event->type()) { |
281 case ui::ET_GESTURE_SCROLL_UPDATE: | 282 case ui::ET_GESTURE_SCROLL_UPDATE: |
282 case ui::ET_GESTURE_SCROLL_END: | 283 case ui::ET_GESTURE_SCROLL_END: |
283 case ui::ET_SCROLL_FLING_START: | 284 case ui::ET_SCROLL_FLING_START: |
284 return; | 285 return; |
285 default: | 286 default: |
286 break; | 287 break; |
287 } | 288 } |
288 | 289 |
| 290 View* gesture_handler = NULL; |
| 291 if (views::switches::UseRectBasedTargeting()) { |
| 292 gfx::Rect touch_rect(event->details().bounding_box()); |
| 293 gfx::Point origin(touch_rect.origin()); |
| 294 View::ConvertPointFromScreen(this, &origin); |
| 295 touch_rect.set_origin(origin); |
| 296 gesture_handler = GetEventHandlerForRect(touch_rect); |
| 297 } else { |
| 298 gesture_handler = GetEventHandlerForPoint(event->location()); |
| 299 } |
| 300 |
289 // Walk up the tree until we find a view that wants the gesture event. | 301 // Walk up the tree until we find a view that wants the gesture event. |
290 for (gesture_handler_ = GetEventHandlerForPoint(event->location()); | 302 for (gesture_handler_ = gesture_handler; |
291 gesture_handler_ && (gesture_handler_ != this); | 303 gesture_handler_ && (gesture_handler_ != this); |
292 gesture_handler_ = gesture_handler_->parent()) { | 304 gesture_handler_ = gesture_handler_->parent()) { |
293 if (!gesture_handler_->enabled()) { | 305 if (!gesture_handler_->enabled()) { |
294 // Disabled views eat events but are treated as not handled. | 306 // Disabled views eat events but are treated as not handled. |
295 return; | 307 return; |
296 } | 308 } |
297 | 309 |
298 // See if this view wants to handle the Gesture. | 310 // See if this view wants to handle the Gesture. |
299 ui::GestureEvent gesture_event(*event, static_cast<View*>(this), | 311 ui::GestureEvent gesture_event(*event, static_cast<View*>(this), |
300 gesture_handler_); | 312 gesture_handler_); |
301 DispatchEventToTarget(gesture_handler_, &gesture_event); | 313 DispatchEventToTarget(gesture_handler_, &gesture_event); |
302 | 314 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 return; | 734 return; |
723 } | 735 } |
724 } | 736 } |
725 | 737 |
726 bool RootView::CanDispatchToTarget(ui::EventTarget* target) { | 738 bool RootView::CanDispatchToTarget(ui::EventTarget* target) { |
727 return event_dispatch_target_ == target; | 739 return event_dispatch_target_ == target; |
728 } | 740 } |
729 | 741 |
730 } // namespace internal | 742 } // namespace internal |
731 } // namespace views | 743 } // namespace views |
OLD | NEW |