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

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: WIP Created 7 years, 3 months 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
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"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // events are not dispatched to any views. 267 // events are not dispatched to any views.
268 switch (event->type()) { 268 switch (event->type()) {
269 case ui::ET_GESTURE_SCROLL_UPDATE: 269 case ui::ET_GESTURE_SCROLL_UPDATE:
270 case ui::ET_GESTURE_SCROLL_END: 270 case ui::ET_GESTURE_SCROLL_END:
271 case ui::ET_SCROLL_FLING_START: 271 case ui::ET_SCROLL_FLING_START:
272 return; 272 return;
273 default: 273 default:
274 break; 274 break;
275 } 275 }
276 276
277 // Terry: A runtime flag will specify whether or not fuzzing should be
278 // used here (and will possibly also specify an overlap percentage).
279 bool use_fuzzing = true;
280
281 View* gesture_handler = NULL;
282 if (use_fuzzing) {
283 // Terry: account for any possible transformations on rect?
284 gfx::Rect touch_rect(event->details().bounding_box());
285 gfx::Point origin(touch_rect.origin());
286 View::ConvertPointFromScreen(this, &origin);
287 touch_rect.set_origin(origin);
288 gesture_handler = GetEventHandlerForRect(touch_rect);
289 } else {
290 gesture_handler = GetEventHandlerForPoint(event->location());
291 }
292
277 // Walk up the tree until we find a view that wants the gesture event. 293 // Walk up the tree until we find a view that wants the gesture event.
278 for (gesture_handler_ = GetEventHandlerForPoint(event->location()); 294 for (gesture_handler_ = gesture_handler;
279 gesture_handler_ && (gesture_handler_ != this); 295 gesture_handler_ && (gesture_handler_ != this);
280 gesture_handler_ = gesture_handler_->parent()) { 296 gesture_handler_ = gesture_handler_->parent()) {
281 if (!gesture_handler_->enabled()) { 297 if (!gesture_handler_->enabled()) {
282 // Disabled views eat events but are treated as not handled. 298 // Disabled views eat events but are treated as not handled.
283 return; 299 return;
284 } 300 }
285 301
286 // See if this view wants to handle the Gesture. 302 // See if this view wants to handle the Gesture.
287 ui::GestureEvent gesture_event(*event, static_cast<View*>(this), 303 ui::GestureEvent gesture_event(*event, static_cast<View*>(this),
288 gesture_handler_); 304 gesture_handler_);
289 DispatchEventToTarget(gesture_handler_, &gesture_event); 305 DispatchEventToTarget(gesture_handler_, &gesture_event);
290 306
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 return; 725 return;
710 } 726 }
711 } 727 }
712 728
713 bool RootView::CanDispatchToTarget(ui::EventTarget* target) { 729 bool RootView::CanDispatchToTarget(ui::EventTarget* target) {
714 return event_dispatch_target_ == target; 730 return event_dispatch_target_ == target;
715 } 731 }
716 732
717 } // namespace internal 733 } // namespace internal
718 } // namespace views 734 } // namespace views
OLDNEW
« ui/views/view.cc ('K') | « ui/views/view.cc ('k') | ui/views/window/non_client_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698