Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Side by Side Diff: ui/views/widget/root_view.cc

Issue 22891016: Add support for rect-based event targeting in views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/views_switches.cc ('k') | ui/views/window/non_client_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // TODO(tdanderson): Pass in the bounding box to GetEventHandlerForRect()
293 // once crbug.com/313392 is resolved.
294 gfx::Rect touch_rect(event->details().bounding_box());
295 touch_rect.set_origin(event->location());
296 touch_rect.Offset(-touch_rect.width() / 2, -touch_rect.height() / 2);
297 gesture_handler = GetEventHandlerForRect(touch_rect);
298 } else {
299 gesture_handler = GetEventHandlerForPoint(event->location());
300 }
301
289 // Walk up the tree until we find a view that wants the gesture event. 302 // Walk up the tree until we find a view that wants the gesture event.
290 for (gesture_handler_ = GetEventHandlerForPoint(event->location()); 303 for (gesture_handler_ = gesture_handler;
291 gesture_handler_ && (gesture_handler_ != this); 304 gesture_handler_ && (gesture_handler_ != this);
292 gesture_handler_ = gesture_handler_->parent()) { 305 gesture_handler_ = gesture_handler_->parent()) {
293 if (!gesture_handler_->enabled()) { 306 if (!gesture_handler_->enabled()) {
294 // Disabled views eat events but are treated as not handled. 307 // Disabled views eat events but are treated as not handled.
295 return; 308 return;
296 } 309 }
297 310
298 // See if this view wants to handle the Gesture. 311 // See if this view wants to handle the Gesture.
299 ui::GestureEvent gesture_event(*event, static_cast<View*>(this), 312 ui::GestureEvent gesture_event(*event, static_cast<View*>(this),
300 gesture_handler_); 313 gesture_handler_);
301 DispatchEventToTarget(gesture_handler_, &gesture_event); 314 DispatchEventToTarget(gesture_handler_, &gesture_event);
302 315
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 return; 736 return;
724 } 737 }
725 } 738 }
726 739
727 bool RootView::CanDispatchToTarget(ui::EventTarget* target) { 740 bool RootView::CanDispatchToTarget(ui::EventTarget* target) {
728 return event_dispatch_target_ == target; 741 return event_dispatch_target_ == target;
729 } 742 }
730 743
731 } // namespace internal 744 } // namespace internal
732 } // namespace views 745 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/views_switches.cc ('k') | ui/views/window/non_client_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698