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

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

Issue 7792094: touchui: support XInput2 MT (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Update patch set according to comment #33 Created 9 years, 3 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/events/event_x.cc ('k') | views/touchui/touch_factory.h » ('j') | 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) 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 #include <X11/extensions/XInput2.h> 9 #include <X11/extensions/XInput2.h>
10 10
(...skipping 29 matching lines...) Expand all
40 } // namespace 40 } // namespace
41 41
42 bool DispatchX2Event(Widget* widget, XEvent* xev) { 42 bool DispatchX2Event(Widget* widget, XEvent* xev) {
43 XGenericEventCookie* cookie = &xev->xcookie; 43 XGenericEventCookie* cookie = &xev->xcookie;
44 switch (cookie->evtype) { 44 switch (cookie->evtype) {
45 case XI_KeyPress: 45 case XI_KeyPress:
46 case XI_KeyRelease: { 46 case XI_KeyRelease: {
47 // TODO(sad): We don't capture XInput2 events from keyboard yet. 47 // TODO(sad): We don't capture XInput2 events from keyboard yet.
48 break; 48 break;
49 } 49 }
50 #if defined(USE_XI2_MT)
51 case XI_TouchBegin:
52 case XI_TouchEnd:
53 case XI_TouchUpdate: {
54 Event::FromNativeEvent2 from_native;
55
56 // Hide the cursor when a touch event comes in.
57 TouchFactory::GetInstance()->SetCursorVisible(false, false);
58
59 // If the TouchEvent is processed by |widget|, then return.
60 TouchEvent touch(xev, from_native);
61 if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN)
62 return true;
63
64 // We do not want to generate a mouse event for an unprocessed touch
65 // event here. That is already done by the gesture manager in
66 // RootView::OnTouchEvent.
67 return false;
68 }
69 #endif
50 case XI_ButtonPress: 70 case XI_ButtonPress:
51 case XI_ButtonRelease: 71 case XI_ButtonRelease:
52 case XI_Motion: { 72 case XI_Motion: {
53 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data); 73 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(cookie->data);
54 Event::FromNativeEvent2 from_native; 74 Event::FromNativeEvent2 from_native;
55 75
56 // Scrolling the wheel generates press/release events with button id's 4 76 // Scrolling the wheel generates press/release events with button id's 4
57 // and 5. In case of a wheelscroll, we do not want to show the cursor. 77 // and 5. In case of a wheelscroll, we do not want to show the cursor.
58 if (xievent->detail == 4 || xievent->detail == 5) { 78 if (xievent->detail == 4 || xievent->detail == 5) {
59 MouseWheelEvent wheelev(xev, from_native); 79 MouseWheelEvent wheelev(xev, from_native);
60 return widget->OnMouseEvent(wheelev); 80 return widget->OnMouseEvent(wheelev);
61 } 81 }
62 82
63 // Is the event coming from a touch device? 83 // Is the event coming from a touch device?
64 if (TouchFactory::GetInstance()->IsTouchDevice(xievent->sourceid)) { 84 if (TouchFactory::GetInstance()->IsTouchDevice(xievent->sourceid)) {
65 // Hide the cursor when a touch event comes in. 85 // Hide the cursor when a touch event comes in.
66 TouchFactory::GetInstance()->SetCursorVisible(false, false); 86 TouchFactory::GetInstance()->SetCursorVisible(false, false);
67 87
68 // With XInput 2.0, XI_ButtonPress and XI_ButtonRelease events are 88 // With XInput 2.0, XI_ButtonPress and XI_ButtonRelease events are
69 // ignored, as XI_Motion events contain enough data to detect finger 89 // ignored, as XI_Motion events contain enough data to detect finger
70 // press and release. See more notes in TouchFactory::TouchParam. 90 // press and release. See more notes in TouchFactory::TouchParam.
71 if (cookie->evtype == XI_ButtonPress || 91 if (cookie->evtype == XI_ButtonPress ||
72 cookie->evtype == XI_ButtonRelease) 92 cookie->evtype == XI_ButtonRelease)
73 return false; 93 return false;
74 94
75 // If the TouchEvent is processed by |root|, then return. Otherwise let 95 // If the TouchEvent is processed by |widget|, then return. Otherwise
76 // it fall through so it can be used as a MouseEvent, if desired. 96 // let it fall through so it can be used as a MouseEvent, if desired.
77 TouchEvent touch(xev, from_native); 97 TouchEvent touch(xev, from_native);
78 if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN) 98 if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN)
79 return true; 99 return true;
80 100
81 // We do not want to generate a mouse event for an unprocessed touch 101 // We do not want to generate a mouse event for an unprocessed touch
82 // event here. That is already done by the gesture manager in 102 // event here. That is already done by the gesture manager in
83 // RootView::OnTouchEvent. 103 // RootView::OnTouchEvent.
84 return false; 104 return false;
85 } else { 105 } else {
86 MouseEvent mouseev(xev, from_native); 106 MouseEvent mouseev(xev, from_native);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 AcceleratorHandler::AcceleratorHandler() {} 185 AcceleratorHandler::AcceleratorHandler() {}
166 186
167 base::MessagePumpDispatcher::DispatchStatus 187 base::MessagePumpDispatcher::DispatchStatus
168 AcceleratorHandler::Dispatch(XEvent* xev) { 188 AcceleratorHandler::Dispatch(XEvent* xev) {
169 return DispatchXEvent(xev) ? 189 return DispatchXEvent(xev) ?
170 base::MessagePumpDispatcher::EVENT_PROCESSED : 190 base::MessagePumpDispatcher::EVENT_PROCESSED :
171 base::MessagePumpDispatcher::EVENT_IGNORED; 191 base::MessagePumpDispatcher::EVENT_IGNORED;
172 } 192 }
173 193
174 } // namespace views 194 } // namespace views
OLDNEW
« no previous file with comments | « views/events/event_x.cc ('k') | views/touchui/touch_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698