summaryrefslogtreecommitdiffstats
path: root/views/focus/accelerator_handler_touch.cc
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-12 01:17:35 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-12 01:17:35 +0000
commitf4f7dd072cb18b122edeca7992b1984759757962 (patch)
tree1e205be4073d2d19a08a6797718642e8c640a2d0 /views/focus/accelerator_handler_touch.cc
parent11dd68cd5c43ea76082eed94d7ffc2e887241005 (diff)
downloadchromium_src-f4f7dd072cb18b122edeca7992b1984759757962.zip
chromium_src-f4f7dd072cb18b122edeca7992b1984759757962.tar.gz
chromium_src-f4f7dd072cb18b122edeca7992b1984759757962.tar.bz2
touchui: First pass at XInput2 message pump.
Capture X events using XInput2. BUG=None TEST=None Review URL: http://codereview.chromium.org/4186004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus/accelerator_handler_touch.cc')
-rw-r--r--views/focus/accelerator_handler_touch.cc84
1 files changed, 83 insertions, 1 deletions
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc
index 9473600..a07b977 100644
--- a/views/focus/accelerator_handler_touch.cc
+++ b/views/focus/accelerator_handler_touch.cc
@@ -5,7 +5,11 @@
#include "views/focus/accelerator_handler.h"
#include <gtk/gtk.h>
+#if defined(HAVE_XINPUT2)
+#include <X11/extensions/XInput2.h>
+#else
#include <X11/Xlib.h>
+#endif
#include "views/accelerator.h"
#include "views/event.h"
@@ -34,11 +38,81 @@ RootView* FindRootViewForGdkWindow(GdkWindow* gdk_window) {
return widget_gtk->GetRootView();
}
+#if defined(HAVE_XINPUT2)
+bool X2EventIsTouchEvent(XEvent* xev) {
+ // TODO(sad): Determine if the captured event is a touch-event.
+ return false;
+}
+#endif // HAVE_XINPUT2
+
} // namespace
+#if defined(HAVE_XINPUT2)
+bool DispatchX2Event(RootView* root, XEvent* xev) {
+ if (X2EventIsTouchEvent(xev)) {
+ // TODO(sad): Create a TouchEvent, and send it off to |root|. If the event
+ // is processed by |root|, then return. Otherwise let it fall through so it
+ // can be used (if desired) as a mouse event.
+
+ // TouchEvent touch(xev);
+ // if (root->OnTouchEvent(touch))
+ // return true;
+ }
+
+ XGenericEventCookie* cookie = &xev->xcookie;
+
+ switch (cookie->evtype) {
+ case XI_KeyPress:
+ case XI_KeyRelease: {
+ // TODO(sad): We don't capture XInput2 events from keyboard yet.
+ break;
+ }
+ case XI_ButtonPress:
+ case XI_ButtonRelease: {
+ MouseEvent mouseev(xev);
+ if (cookie->evtype == XI_ButtonPress) {
+ return root->OnMousePressed(mouseev);
+ } else {
+ root->OnMouseReleased(mouseev, false);
+ return true;
+ }
+ }
+
+ case XI_Motion: {
+ MouseEvent mouseev(xev);
+ if (mouseev.GetType() == Event::ET_MOUSE_DRAGGED) {
+ return root->OnMouseDragged(mouseev);
+ } else {
+ root->OnMouseMoved(mouseev);
+ return true;
+ }
+ break;
+ }
+ }
+
+ return false;
+}
+
+#endif // HAVE_XINPUT2
+
bool DispatchXEvent(XEvent* xev) {
GdkDisplay* gdisp = gdk_display_get_default();
- GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xev->xany.window);
+ XID xwindow = xev->xany.window;
+
+#if defined(HAVE_XINPUT2)
+ if (xev->type == GenericEvent) {
+ if (XGetEventData(xev->xgeneric.display, &xev->xcookie)) {
+ XGenericEventCookie* cookie = &xev->xcookie;
+ XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(cookie->data);
+ xwindow = xiev->event;
+ } else {
+ DLOG(WARNING) << "Error fetching XGenericEventCookie for event.";
+ return false;
+ }
+ }
+#endif
+
+ GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xwindow);
if (RootView* root = FindRootViewForGdkWindow(gwind)) {
switch (xev->type) {
@@ -77,6 +151,14 @@ bool DispatchXEvent(XEvent* xev) {
return true;
}
}
+
+#if defined(HAVE_XINPUT2)
+ case GenericEvent: {
+ bool ret = DispatchX2Event(root, xev);
+ XFreeEventData(xev->xgeneric.display, &xev->xcookie);
+ return ret;
+ }
+#endif
}
}