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

Side by Side Diff: views/focus/accelerator_handler_touch.cc

Issue 6975045: touch: Always expect XInput2 availability. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 6 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
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/focus/accelerator_handler.h" 5 #include "views/focus/accelerator_handler.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #if defined(HAVE_XINPUT2)
10 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
11 #else
12 #include <X11/Xlib.h>
13 #endif
14 10
15 #include "views/accelerator.h" 11 #include "views/accelerator.h"
16 #include "views/events/event.h" 12 #include "views/events/event.h"
17 #include "views/focus/focus_manager.h" 13 #include "views/focus/focus_manager.h"
18 #include "views/ime/input_method.h" 14 #include "views/ime/input_method.h"
19 #include "views/touchui/touch_factory.h" 15 #include "views/touchui/touch_factory.h"
20 #include "views/view.h" 16 #include "views/view.h"
21 #include "views/widget/native_widget.h" 17 #include "views/widget/native_widget.h"
22 18
23 namespace views { 19 namespace views {
(...skipping 12 matching lines...) Expand all
36 32
37 if (!widget) { 33 if (!widget) {
38 DLOG(WARNING) << "no NativeWidgetGtk found for that GtkWidget"; 34 DLOG(WARNING) << "no NativeWidgetGtk found for that GtkWidget";
39 return NULL; 35 return NULL;
40 } 36 }
41 return widget->GetWidget(); 37 return widget->GetWidget();
42 } 38 }
43 39
44 } // namespace 40 } // namespace
45 41
46 #if defined(HAVE_XINPUT2)
47 bool DispatchX2Event(Widget* widget, XEvent* xev) { 42 bool DispatchX2Event(Widget* widget, XEvent* xev) {
48 XGenericEventCookie* cookie = &xev->xcookie; 43 XGenericEventCookie* cookie = &xev->xcookie;
49 switch (cookie->evtype) { 44 switch (cookie->evtype) {
50 case XI_KeyPress: 45 case XI_KeyPress:
51 case XI_KeyRelease: { 46 case XI_KeyRelease: {
52 // TODO(sad): We don't capture XInput2 events from keyboard yet. 47 // TODO(sad): We don't capture XInput2 events from keyboard yet.
53 break; 48 break;
54 } 49 }
55 case XI_ButtonPress: 50 case XI_ButtonPress:
56 case XI_ButtonRelease: 51 case XI_ButtonRelease:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 mouseev.IsOnlyRightMouseButton()); 95 mouseev.IsOnlyRightMouseButton());
101 TouchFactory::GetInstance()->SetCursorVisible(true, start_timer); 96 TouchFactory::GetInstance()->SetCursorVisible(true, start_timer);
102 97
103 return widget->OnMouseEvent(mouseev); 98 return widget->OnMouseEvent(mouseev);
104 } 99 }
105 } 100 }
106 } 101 }
107 return false; 102 return false;
108 } 103 }
109 104
110 #endif // HAVE_XINPUT2
111
112 bool DispatchXEvent(XEvent* xev) { 105 bool DispatchXEvent(XEvent* xev) {
113 GdkDisplay* gdisp = gdk_display_get_default(); 106 GdkDisplay* gdisp = gdk_display_get_default();
114 XID xwindow = xev->xany.window; 107 XID xwindow = xev->xany.window;
115 108
116 #if defined(HAVE_XINPUT2)
117 if (xev->type == GenericEvent) { 109 if (xev->type == GenericEvent) {
118 if (!TouchFactory::GetInstance()->ShouldProcessXI2Event(xev)) 110 if (!TouchFactory::GetInstance()->ShouldProcessXI2Event(xev))
119 return true; // Consume the event. 111 return true; // Consume the event.
120 112
121 XGenericEventCookie* cookie = &xev->xcookie; 113 XGenericEventCookie* cookie = &xev->xcookie;
122 if (cookie->evtype == XI_HierarchyChanged) { 114 if (cookie->evtype == XI_HierarchyChanged) {
123 TouchFactory::GetInstance()->UpdateDeviceList(cookie->display); 115 TouchFactory::GetInstance()->UpdateDeviceList(cookie->display);
124 return true; 116 return true;
125 } 117 }
126 118
127 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(cookie->data); 119 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(cookie->data);
128 xwindow = xiev->event; 120 xwindow = xiev->event;
129 } 121 }
130 #endif
131 122
132 GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xwindow); 123 GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xwindow);
133 Widget* widget = FindWidgetForGdkWindow(gwind); 124 Widget* widget = FindWidgetForGdkWindow(gwind);
134 if (widget) { 125 if (widget) {
135 Event::FromNativeEvent2 from_native; 126 Event::FromNativeEvent2 from_native;
136 switch (xev->type) { 127 switch (xev->type) {
137 case KeyPress: 128 case KeyPress:
138 case KeyRelease: { 129 case KeyRelease: {
139 KeyEvent keyev(xev, from_native); 130 KeyEvent keyev(xev, from_native);
140 InputMethod* ime = widget->GetInputMethod(); 131 InputMethod* ime = widget->GetInputMethod();
(...skipping 11 matching lines...) Expand all
152 // Scrolling the wheel triggers button press/release events. 143 // Scrolling the wheel triggers button press/release events.
153 MouseWheelEvent wheelev(xev, from_native); 144 MouseWheelEvent wheelev(xev, from_native);
154 return widget->OnMouseEvent(wheelev); 145 return widget->OnMouseEvent(wheelev);
155 } 146 }
156 // fallthrough 147 // fallthrough
157 case MotionNotify: { 148 case MotionNotify: {
158 MouseEvent mouseev(xev, from_native); 149 MouseEvent mouseev(xev, from_native);
159 return widget->OnMouseEvent(mouseev); 150 return widget->OnMouseEvent(mouseev);
160 } 151 }
161 152
162 #if defined(HAVE_XINPUT2)
163 case GenericEvent: { 153 case GenericEvent: {
164 return DispatchX2Event(widget, xev); 154 return DispatchX2Event(widget, xev);
165 } 155 }
166 #endif
167 } 156 }
168 } 157 }
169 158
170 return false; 159 return false;
171 } 160 }
172 161
173 #if defined(HAVE_XINPUT2)
174 void SetTouchDeviceList(std::vector<unsigned int>& devices) { 162 void SetTouchDeviceList(std::vector<unsigned int>& devices) {
175 TouchFactory::GetInstance()->SetTouchDeviceList(devices); 163 TouchFactory::GetInstance()->SetTouchDeviceList(devices);
176 } 164 }
177 #endif
178 165
179 AcceleratorHandler::AcceleratorHandler() {} 166 AcceleratorHandler::AcceleratorHandler() {}
180 167
181 bool AcceleratorHandler::Dispatch(GdkEvent* event) { 168 bool AcceleratorHandler::Dispatch(GdkEvent* event) {
182 gtk_main_do_event(event); 169 gtk_main_do_event(event);
183 return true; 170 return true;
184 } 171 }
185 172
186 base::MessagePumpGlibXDispatcher::DispatchStatus 173 base::MessagePumpGlibXDispatcher::DispatchStatus
187 AcceleratorHandler::DispatchX(XEvent* xev) { 174 AcceleratorHandler::DispatchX(XEvent* xev) {
188 return DispatchXEvent(xev) ? 175 return DispatchXEvent(xev) ?
189 base::MessagePumpGlibXDispatcher::EVENT_PROCESSED : 176 base::MessagePumpGlibXDispatcher::EVENT_PROCESSED :
190 base::MessagePumpGlibXDispatcher::EVENT_IGNORED; 177 base::MessagePumpGlibXDispatcher::EVENT_IGNORED;
191 } 178 }
192 179
193 } // namespace views 180 } // namespace views
OLDNEW
« build/linux/system.gyp ('K') | « views/focus/accelerator_handler.h ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698