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

Side by Side Diff: views/touchui/gesture_manager.cc

Issue 8364039: Initial views touchui GestureRecognizer support (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added ForwardGestureEvents()in RootView and incorporated comments Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/touchui/gesture_manager.h" 5 #include "views/touchui/gesture_manager.h"
6 #ifndef NDEBUG 6 #ifndef NDEBUG
7 #include <ostream> 7 #include <ostream>
8 #endif 8 #endif
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 10 matching lines...) Expand all
21 GestureManager* GestureManager::GetInstance() { 21 GestureManager* GestureManager::GetInstance() {
22 return Singleton<GestureManager>::get(); 22 return Singleton<GestureManager>::get();
23 } 23 }
24 24
25 bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event, 25 bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event,
26 View* source, 26 View* source,
27 ui::TouchStatus status) { 27 ui::TouchStatus status) {
28 if (status != ui::TOUCH_STATUS_UNKNOWN) 28 if (status != ui::TOUCH_STATUS_UNKNOWN)
29 return false; // The event was consumed by a touch sequence. 29 return false; // The event was consumed by a touch sequence.
30 30
31 // TODO(rjkroege): A realistic version of the GestureManager will 31 if (root_view_ == NULL || root_view_ == source->GetWidget()->GetRootView()) {
rjkroege 2011/10/27 23:10:07 This code is not really right. It needs to look mo
Gajen 2011/10/31 13:34:30 Now GM is restored to original stage, and GR is de
32 // appear in a subsequent CL. This interim version permits verifying that the 32 // Get the GestureEvent list processed from GestureManager.
33 // event distribution code works by turning all touch inputs into 33 scoped_ptr<Gestures> gestures;
34 // mouse approximations. 34 gestures.reset(gesture_recognizer_.ProcessTouchEventForGesture(event,
35 35 false));
36 // Conver the touch-event into a mouse-event. This mouse-event gets its 36 source->GetWidget()->GetRootView()->ForwardGestureEvents(
37 // location information from the native-event, so it needs to convert the 37 gestures.release());
38 // coordinate to the target widget. 38 return true;
39 MouseEvent mouseev(event);
40 if (ViewsDelegate::views_delegate->GetDefaultParentView()) {
41 // TODO(oshima): We may need to send the event back through
42 // window manager to handle mouse capture correctly.
43 Widget* desktop =
44 ViewsDelegate::views_delegate->GetDefaultParentView()->GetWidget();
45 Widget* source_widget = source->GetWidget();
46 MouseEvent converted(
47 mouseev, desktop->GetRootView(), source_widget->GetRootView());
48 source_widget->OnMouseEvent(converted);
49 } else { 39 } else {
50 Widget* source_widget = source->GetWidget(); 40 // Reset GestureRecognizer state.
51 Widget* top_widget = source_widget->GetTopLevelWidget(); 41 // TODO(Gajen): Do we need to support Gesture across different RootViews
52 if (source_widget != top_widget) { 42 // except where TYPE_CHILD widget is still NativeWidgetGtk.
53 // This is necessary as TYPE_CHILD widget is still NativeWidgetGtk. 43 gesture_recognizer_.Reset();
54 // Fix this once TYPE_CHILD is switched to NativeWidgetViews. 44 root_view_ = NULL;
55 MouseEvent converted(mouseev, 45 return false;
56 top_widget->GetRootView(),
57 source_widget->GetRootView());
58 source_widget->OnMouseEvent(mouseev);
59 } else {
60 source_widget->OnMouseEvent(mouseev);
61 }
62 } 46 }
63 return true;
64 } 47 }
65 48
66 GestureManager::GestureManager() { 49 GestureManager::GestureManager()
50 : root_view_(NULL) {
rjkroege 2011/10/27 23:10:07 Why do you have this code? I believe it is unnece
Gajen 2011/10/31 13:34:30 Done.
67 } 51 }
68 52
69 } // namespace views 53 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698