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

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

Issue 6347002: touch: Return an enum from OnTouchEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments 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/widget/root_view.h ('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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 299
300 ViewStorage::GetInstance()->ViewRemoved(parent, child); 300 ViewStorage::GetInstance()->ViewRemoved(parent, child);
301 } 301 }
302 } 302 }
303 303
304 void RootView::SetFocusOnMousePressed(bool f) { 304 void RootView::SetFocusOnMousePressed(bool f) {
305 focus_on_mouse_pressed_ = f; 305 focus_on_mouse_pressed_ = f;
306 } 306 }
307 307
308 #if defined(TOUCH_UI) 308 #if defined(TOUCH_UI)
309 bool 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 314
314 if (touch_pressed_handler_) { 315 if (touch_pressed_handler_) {
315 TouchEvent touch_event(e, this, touch_pressed_handler_); 316 TouchEvent touch_event(e, this, touch_pressed_handler_);
316 touch_pressed_handler_->ProcessTouchEvent(touch_event); 317 status = touch_pressed_handler_->ProcessTouchEvent(touch_event);
317 gesture_manager_->ProcessTouchEventForGesture(e, this, true); 318 gesture_manager_->ProcessTouchEventForGesture(e, this, true);
318 return true; 319 if (status == TOUCH_STATUS_END)
320 touch_pressed_handler_ = NULL;
321 return status;
319 } 322 }
320 323
321 bool handled = false; 324 bool handled = false;
322 // Walk up the tree until we find a view that wants the touch event. 325 // Walk up the tree until we find a view that wants the touch event.
323 for (touch_pressed_handler_ = GetViewForPoint(e.location()); 326 for (touch_pressed_handler_ = GetViewForPoint(e.location());
324 touch_pressed_handler_ && (touch_pressed_handler_ != this); 327 touch_pressed_handler_ && (touch_pressed_handler_ != this);
325 touch_pressed_handler_ = touch_pressed_handler_->GetParent()) { 328 touch_pressed_handler_ = touch_pressed_handler_->GetParent()) {
326 if (!touch_pressed_handler_->IsEnabled()) { 329 if (!touch_pressed_handler_->IsEnabled()) {
327 // Disabled views eat events but are treated as not handled by the 330 // Disabled views eat events but are treated as not handled by the
328 // the GestureManager. 331 // the GestureManager.
329 handled = false; 332 handled = false;
333 status = TOUCH_STATUS_UNKNOWN;
330 break; 334 break;
331 } 335 }
332 336
333 // See if this view wants to handle the touch 337 // See if this view wants to handle the touch
334 TouchEvent touch_event(e, this, touch_pressed_handler_); 338 TouchEvent touch_event(e, this, touch_pressed_handler_);
335 handled = touch_pressed_handler_->ProcessTouchEvent(touch_event); 339 status = touch_pressed_handler_->ProcessTouchEvent(touch_event);
340
341 // If the touch didn't initiate a touch-sequence, then reset the touch event
342 // handler.
343 if (status != TOUCH_STATUS_START)
344 touch_pressed_handler_ = NULL;
345
346 handled = status != TOUCH_STATUS_UNKNOWN;
336 347
337 // The view could have removed itself from the tree when handling 348 // The view could have removed itself from the tree when handling
338 // OnTouchEvent(). So handle as per OnMousePressed. NB: we 349 // OnTouchEvent(). So handle as per OnMousePressed. NB: we
339 // assume that the RootView itself cannot be so removed. 350 // assume that the RootView itself cannot be so removed.
340 // 351 //
341 // NOTE: Don't return true here, because we don't want the frame to 352 // NOTE: Don't return true here, because we don't want the frame to
342 // forward future events to us when there's no handler. 353 // forward future events to us when there's no handler.
343 if (!touch_pressed_handler_) 354 if (!touch_pressed_handler_)
344 break; 355 break;
345 356
346 // If the view handled the event, leave touch_pressed_handler_ set and 357 // If the view handled the event, leave touch_pressed_handler_ set and
347 // return true, which will cause subsequent drag/release events to get 358 // return true, which will cause subsequent drag/release events to get
348 // forwarded to that view. 359 // forwarded to that view.
349 if (handled) { 360 if (handled) {
350 gesture_manager_->ProcessTouchEventForGesture(e, this, handled); 361 gesture_manager_->ProcessTouchEventForGesture(e, this, handled);
351 return true; 362 return status;
352 } 363 }
353 } 364 }
354 365
355 // Reset touch_pressed_handler_ to indicate that no processing is occurring. 366 // Reset touch_pressed_handler_ to indicate that no processing is occurring.
356 touch_pressed_handler_ = NULL; 367 touch_pressed_handler_ = NULL;
357 368
358 // Give the touch event to the gesture manager. 369 // Give the touch event to the gesture manager.
359 gesture_manager_->ProcessTouchEventForGesture(e, this, handled); 370 gesture_manager_->ProcessTouchEventForGesture(e, this, handled);
360 return handled; 371 return status;
361 } 372 }
362 #endif 373 #endif
363 374
364 bool RootView::OnMousePressed(const MouseEvent& e) { 375 bool RootView::OnMousePressed(const MouseEvent& e) {
365 // This function does not normally handle non-client messages except for 376 // This function does not normally handle non-client messages except for
366 // non-client double-clicks. Actually, all double-clicks are special as the 377 // non-client double-clicks. Actually, all double-clicks are special as the
367 // are formed from a single-click followed by a double-click event. When the 378 // are formed from a single-click followed by a double-click event. When the
368 // double-click event lands on a different view than its single-click part, 379 // double-click event lands on a different view than its single-click part,
369 // we transform it into a single-click which prevents odd things. 380 // we transform it into a single-click which prevents odd things.
370 if ((e.GetFlags() & MouseEvent::EF_IS_NON_CLIENT) && 381 if ((e.GetFlags() & MouseEvent::EF_IS_NON_CLIENT) &&
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 #elif defined(OS_LINUX) 796 #elif defined(OS_LINUX)
786 gfx::NativeView native_view = 797 gfx::NativeView native_view =
787 static_cast<WidgetGtk*>(GetWidget())->window_contents(); 798 static_cast<WidgetGtk*>(GetWidget())->window_contents();
788 if (!native_view) 799 if (!native_view)
789 return; 800 return;
790 gdk_window_set_cursor(native_view->window, cursor); 801 gdk_window_set_cursor(native_view->window, cursor);
791 #endif 802 #endif
792 } 803 }
793 804
794 } // namespace views 805 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/root_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698