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

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

Issue 6253005: touch: Gesture manager receives the touch-sequence status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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
« no previous file with comments | « views/touchui/gesture_manager.cc ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/widget/root_view.h" 5 #include "views/widget/root_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/drag_drop_types.h" 9 #include "app/drag_drop_types.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 #if defined(TOUCH_UI) 308 #if defined(TOUCH_UI)
309 View::TouchStatus RootView::OnTouchEvent(const TouchEvent& e) { 309 View::TouchStatus RootView::OnTouchEvent(const TouchEvent& e) {
310 // If touch_pressed_handler_ is non null, we are currently processing 310 // If touch_pressed_handler_ is non null, we are currently processing
311 // a touch down on the screen situation. In that case we send the 311 // a touch down on the screen situation. In that case we send the
312 // event to touch_pressed_handler_ 312 // event to touch_pressed_handler_
313 View::TouchStatus status = TOUCH_STATUS_UNKNOWN; 313 View::TouchStatus status = TOUCH_STATUS_UNKNOWN;
314 314
315 if (touch_pressed_handler_) { 315 if (touch_pressed_handler_) {
316 TouchEvent touch_event(e, this, touch_pressed_handler_); 316 TouchEvent touch_event(e, this, touch_pressed_handler_);
317 status = touch_pressed_handler_->ProcessTouchEvent(touch_event); 317 status = touch_pressed_handler_->ProcessTouchEvent(touch_event);
318 gesture_manager_->ProcessTouchEventForGesture(e, this, true); 318 gesture_manager_->ProcessTouchEventForGesture(e, this, status);
sadrul 2011/01/18 19:33:30 Should the status fall through, or do we always wa
rjkroege 2011/01/18 20:01:28 the true was a bug. This is correct. (famous last
319 if (status == TOUCH_STATUS_END) 319 if (status == TOUCH_STATUS_END)
320 touch_pressed_handler_ = NULL; 320 touch_pressed_handler_ = NULL;
321 return status; 321 return status;
322 } 322 }
323 323
324 bool handled = false;
325 // Walk up the tree until we find a view that wants the touch event. 324 // Walk up the tree until we find a view that wants the touch event.
326 for (touch_pressed_handler_ = GetViewForPoint(e.location()); 325 for (touch_pressed_handler_ = GetViewForPoint(e.location());
327 touch_pressed_handler_ && (touch_pressed_handler_ != this); 326 touch_pressed_handler_ && (touch_pressed_handler_ != this);
328 touch_pressed_handler_ = touch_pressed_handler_->GetParent()) { 327 touch_pressed_handler_ = touch_pressed_handler_->GetParent()) {
329 if (!touch_pressed_handler_->IsEnabled()) { 328 if (!touch_pressed_handler_->IsEnabled()) {
330 // Disabled views eat events but are treated as not handled by the 329 // Disabled views eat events but are treated as not handled by the
331 // the GestureManager. 330 // the GestureManager.
332 handled = false;
333 status = TOUCH_STATUS_UNKNOWN; 331 status = TOUCH_STATUS_UNKNOWN;
334 break; 332 break;
335 } 333 }
336 334
337 // See if this view wants to handle the touch 335 // See if this view wants to handle the touch
338 TouchEvent touch_event(e, this, touch_pressed_handler_); 336 TouchEvent touch_event(e, this, touch_pressed_handler_);
339 status = touch_pressed_handler_->ProcessTouchEvent(touch_event); 337 status = touch_pressed_handler_->ProcessTouchEvent(touch_event);
340 338
341 // If the touch didn't initiate a touch-sequence, then reset the touch event 339 // If the touch didn't initiate a touch-sequence, then reset the touch event
342 // handler. 340 // handler.
343 if (status != TOUCH_STATUS_START) 341 if (status != TOUCH_STATUS_START)
344 touch_pressed_handler_ = NULL; 342 touch_pressed_handler_ = NULL;
345 343
346 handled = status != TOUCH_STATUS_UNKNOWN;
347
348 // The view could have removed itself from the tree when handling 344 // The view could have removed itself from the tree when handling
349 // OnTouchEvent(). So handle as per OnMousePressed. NB: we 345 // OnTouchEvent(). So handle as per OnMousePressed. NB: we
350 // assume that the RootView itself cannot be so removed. 346 // assume that the RootView itself cannot be so removed.
351 // 347 //
352 // NOTE: Don't return true here, because we don't want the frame to 348 // NOTE: Don't return true here, because we don't want the frame to
353 // forward future events to us when there's no handler. 349 // forward future events to us when there's no handler.
354 if (!touch_pressed_handler_) 350 if (!touch_pressed_handler_)
355 break; 351 break;
356 352
357 // If the view handled the event, leave touch_pressed_handler_ set and 353 // If the view handled the event, leave touch_pressed_handler_ set and
358 // return true, which will cause subsequent drag/release events to get 354 // return true, which will cause subsequent drag/release events to get
359 // forwarded to that view. 355 // forwarded to that view.
360 if (handled) { 356 if (status != TOUCH_STATUS_UNKNOWN) {
361 gesture_manager_->ProcessTouchEventForGesture(e, this, handled); 357 gesture_manager_->ProcessTouchEventForGesture(e, this, status);
362 return status; 358 return status;
363 } 359 }
364 } 360 }
365 361
366 // Reset touch_pressed_handler_ to indicate that no processing is occurring. 362 // Reset touch_pressed_handler_ to indicate that no processing is occurring.
367 touch_pressed_handler_ = NULL; 363 touch_pressed_handler_ = NULL;
368 364
369 // Give the touch event to the gesture manager. 365 // Give the touch event to the gesture manager.
370 gesture_manager_->ProcessTouchEventForGesture(e, this, handled); 366 gesture_manager_->ProcessTouchEventForGesture(e, this, status);
371 return status; 367 return status;
372 } 368 }
373 #endif 369 #endif
374 370
375 bool RootView::OnMousePressed(const MouseEvent& e) { 371 bool RootView::OnMousePressed(const MouseEvent& e) {
376 // This function does not normally handle non-client messages except for 372 // This function does not normally handle non-client messages except for
377 // non-client double-clicks. Actually, all double-clicks are special as the 373 // non-client double-clicks. Actually, all double-clicks are special as the
378 // are formed from a single-click followed by a double-click event. When the 374 // are formed from a single-click followed by a double-click event. When the
379 // double-click event lands on a different view than its single-click part, 375 // double-click event lands on a different view than its single-click part,
380 // we transform it into a single-click which prevents odd things. 376 // we transform it into a single-click which prevents odd things.
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 #elif defined(OS_LINUX) 792 #elif defined(OS_LINUX)
797 gfx::NativeView native_view = 793 gfx::NativeView native_view =
798 static_cast<WidgetGtk*>(GetWidget())->window_contents(); 794 static_cast<WidgetGtk*>(GetWidget())->window_contents();
799 if (!native_view) 795 if (!native_view)
800 return; 796 return;
801 gdk_window_set_cursor(native_view->window, cursor); 797 gdk_window_set_cursor(native_view->window, cursor);
802 #endif 798 #endif
803 } 799 }
804 800
805 } // namespace views 801 } // namespace views
OLDNEW
« no previous file with comments | « views/touchui/gesture_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698