summaryrefslogtreecommitdiffstats
path: root/views/event_x.cc
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 19:35:18 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 19:35:18 +0000
commit194bf38fe616b10b0d3c551292db6832567186d9 (patch)
treebacebff474c08a2531c2464024afbb72a90dac22 /views/event_x.cc
parent909116fdb8f7eaaf225bdf3314fdf4e46d42f115 (diff)
downloadchromium_src-194bf38fe616b10b0d3c551292db6832567186d9.zip
chromium_src-194bf38fe616b10b0d3c551292db6832567186d9.tar.gz
chromium_src-194bf38fe616b10b0d3c551292db6832567186d9.tar.bz2
touchui: Create touch-events.
Create and process touch-events. The touch-events are created from pointer-events. The way to decide whether a 'pointer event' originated from a touch-device is not yet well-defined. So for now, use the --touch-devices command line parameter to specify which pointer devices should be treated as touch-device. For example, you can run: ./out/Debug/chrome --touch-devices=7,8 to treat the events coming in from devices with id 7 and 8 as touch events. (these are the slave ids you get from 'xinput list') BUG=None TEST=None Review URL: http://codereview.chromium.org/4738001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67133 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/event_x.cc')
-rw-r--r--views/event_x.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/views/event_x.cc b/views/event_x.cc
index 60b0d2f..774aa7f 100644
--- a/views/event_x.cc
+++ b/views/event_x.cc
@@ -71,6 +71,46 @@ int GetButtonMaskForX2Event(XIDeviceEvent* xievent) {
return buttonflags;
}
+
+Event::EventType GetTouchEventType(XEvent* xev) {
+ XGenericEventCookie* cookie = &xev->xcookie;
+ switch (cookie->evtype) {
+ case XI_ButtonPress:
+ return Event::ET_TOUCH_PRESSED;
+ case XI_ButtonRelease:
+ return Event::ET_TOUCH_RELEASED;
+ case XI_Motion:
+ return Event::ET_TOUCH_MOVED;
+
+ // Note: We will not generate a _STATIONARY event here. It will be created,
+ // when necessary, by a RWHVV.
+
+ // TODO(sad): When do we trigger a _CANCELLED event? Maybe that will also be
+ // done by a RWHVV, e.g. when it gets destroyed in the middle of a
+ // touch-sequence?
+ }
+
+ return Event::ET_UNKNOWN;
+}
+
+gfx::Point GetTouchEventLocation(XEvent* xev) {
+ XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data);
+ return gfx::Point(xiev->event_x, xiev->event_y);
+}
+
+int GetTouchEventFlags(XEvent* xev) {
+ XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data);
+ return GetButtonMaskForX2Event(xiev) |
+ GetEventFlagsFromXState(xiev->mods.effective);
+}
+
+int GetTouchIDFromXEvent(XEvent* xev) {
+ // TODO(sad): How we determine the touch-id from the event is as yet
+ // undecided.
+ XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data);
+ return xiev->sourceid;
+}
+
#endif // HAVE_XINPUT2
Event::EventType GetMouseEventType(XEvent* xev) {
@@ -182,4 +222,13 @@ MouseWheelEvent::MouseWheelEvent(XEvent* xev)
// used for GTK+.
}
+#if defined(HAVE_XINPUT2)
+TouchEvent::TouchEvent(XEvent* xev)
+ : LocatedEvent(GetTouchEventType(xev),
+ GetTouchEventLocation(xev),
+ GetTouchEventFlags(xev)),
+ touch_id_(GetTouchIDFromXEvent(xev)) {
+}
+#endif
+
} // namespace views