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

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: Event injection as per Robert 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()) {
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(converted,
35 35 false));
rjkroege 2011/10/24 17:41:09 indent 1 more
Gajen 2011/10/25 14:32:29 Done.
36 // Conver the touch-event into a mouse-event. This mouse-event gets its 36 Widget* source_widget = NULL;
37 // location information from the native-event, so it needs to convert the 37 RootView* source_root_view = NULL;
38 // coordinate to the target widget. 38 RootView* target_root_view = NULL;
39 MouseEvent mouseev(event); 39 if (ViewsDelegate::views_delegate->GetDefaultParentView()) {
40 if (ViewsDelegate::views_delegate->GetDefaultParentView()) { 40 // TODO(oshima): We may need to send the event back through
41 // TODO(oshima): We may need to send the event back through 41 // window manager to handle mouse capture correctly.
42 // window manager to handle mouse capture correctly. 42 Widget* desktop =
43 Widget* desktop = 43 ViewsDelegate::views_delegate->GetDefaultParentView()->GetWidget();
44 ViewsDelegate::views_delegate->GetDefaultParentView()->GetWidget(); 44 Widget* source_widget = source->GetWidget();
45 Widget* source_widget = source->GetWidget(); 45 TouchEvent converted(
46 MouseEvent converted( 46 event, desktop->GetRootView(), source_widget->GetRootView());
47 mouseev, desktop->GetRootView(), source_widget->GetRootView()); 47 source_root_view = desktop->GetRootView();
48 source_widget->OnMouseEvent(converted); 48 target_root_view = source_widget->GetRootView();
49 } else {
50 Widget* source_widget = source->GetWidget();
51 Widget* top_widget = source_widget->GetTopLevelWidget();
52 if (source_widget != top_widget) {
53 // This is necessary as TYPE_CHILD widget is still NativeWidgetGtk.
54 // Fix this once TYPE_CHILD is switched to NativeWidgetViews.
55 source_root_view = top_widget->GetRootView();
56 target_root_view = source_widget->GetRootView();
57 }
58 }
59 for (int i = 0; i < gestures->size(); i++) {
60 // Convert GestureEvent w.r.t new source and target.
61 GestureEvent converted(*(gestures->at(i).GestureEvent()),
62 source_root_view, target_root_view);
63 source_widget->OnGestureEvent(converted);
rjkroege 2011/10/24 17:41:09 you can modify the code in RootView to contain the
Gajen 2011/10/25 14:32:29 Done temporarily, but would required changes when
64 }
65 return true;
49 } else { 66 } else {
50 Widget* source_widget = source->GetWidget(); 67 // Reset GestureRecognizer state.
51 Widget* top_widget = source_widget->GetTopLevelWidget(); 68 // TODO(Gajen): Do we need to support Gesture across different RootViews
rjkroege 2011/10/24 17:41:09 no. you'll see that the RootView owns a private GM
Gajen 2011/10/25 14:32:29 But, GM is singleton, so would be same across all
52 if (source_widget != top_widget) { 69 // except where TYPE_CHILD widget is still NativeWidgetGtk.
53 // This is necessary as TYPE_CHILD widget is still NativeWidgetGtk. 70 gesture_recognizer.Reset();
54 // Fix this once TYPE_CHILD is switched to NativeWidgetViews. 71 root_view_ = NULL;
55 MouseEvent converted(mouseev, 72 return false;
56 top_widget->GetRootView(),
57 source_widget->GetRootView());
58 source_widget->OnMouseEvent(mouseev);
59 } else {
60 source_widget->OnMouseEvent(mouseev);
61 }
62 } 73 }
63 return true;
64 } 74 }
65 75
66 GestureManager::GestureManager() { 76 GestureManager::GestureManager()
77 : root_view_(NULL) {
67 } 78 }
68 79
69 } // namespace views 80 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698