OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "views/touchui/gesture_manager.h" | |
6 #ifndef NDEBUG | |
7 #include <ostream> | |
8 #endif | |
9 | |
10 #include "base/logging.h" | |
11 #include "views/events/event.h" | |
12 #include "views/view.h" | |
13 #include "views/views_delegate.h" | |
14 #include "views/widget/widget.h" | |
15 | |
16 namespace views { | |
17 | |
18 GestureManager::~GestureManager() { | |
19 } | |
20 | |
21 GestureManager* GestureManager::GetInstance() { | |
22 return Singleton<GestureManager>::get(); | |
23 } | |
24 | |
25 bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event, | |
26 View* source, | |
27 ui::TouchStatus status) { | |
28 if (status != ui::TOUCH_STATUS_UNKNOWN) | |
29 return false; // The event was consumed by a touch sequence. | |
30 | |
31 // TODO(rjkroege): A realistic version of the GestureManager will | |
32 // appear in a subsequent CL. This interim version permits verifying that the | |
33 // event distribution code works by turning all touch inputs into | |
34 // mouse approximations. | |
35 | |
36 // Conver the touch-event into a mouse-event. This mouse-event gets its | |
37 // location information from the native-event, so it needs to convert the | |
38 // coordinate to the target widget. | |
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 { | |
50 Widget* source_widget = source->GetWidget(); | |
51 Widget* top_widget = source_widget->GetTopLevelWidget(); | |
52 if (source_widget != top_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 MouseEvent converted(mouseev, | |
56 top_widget->GetRootView(), | |
57 source_widget->GetRootView()); | |
58 source_widget->OnMouseEvent(mouseev); | |
59 } else { | |
60 source_widget->OnMouseEvent(mouseev); | |
61 } | |
62 } | |
63 return true; | |
64 } | |
65 | |
66 GestureManager::GestureManager() { | |
67 } | |
68 | |
69 } // namespace views | |
OLD | NEW |