aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native/X11Window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/native/X11Window.c')
-rw-r--r--src/newt/native/X11Window.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index de2bddc86..8fb3ecbb9 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -952,6 +952,62 @@ JNIEXPORT jlongArray JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWind
NewtWindows_setMinMaxSize(dpy, javaWindow, width, height, width, height);
}
}
+
+ // Register X11 Multitouch Events for new Window
+ // https://www.x.org/wiki/Development/Documentation/Multitouch/
+ {
+ int xi_opcode, event, error;
+
+ javaWindow->xiTouchDeviceId = -1;
+
+ if( XQueryExtension(dpy, "XInputExtension", &xi_opcode, &event, &error) ) {
+ XIDeviceInfo *di;
+ int devid = -1;
+ int cnt = 0;
+
+ javaWindow->xiOpcode = xi_opcode;
+ di = XIQueryDevice(dpy, XIAllDevices, &cnt);
+
+ if( NULL != di && 0 < cnt ) {
+ XIDeviceInfo *dev;
+ int i, j;
+
+ // find the 1st XITouchClass device available
+ for (i = 0; i < cnt && -1 == devid; i ++) {
+ dev = &di[i];
+ for (j = 0; j < dev->num_classes; j ++) {
+ XITouchClassInfo *class = (XITouchClassInfo*)(dev->classes[j]);
+ if ( XITouchClass == class->type ) {
+ devid = dev->deviceid;
+ break;
+ }
+ }
+ }
+ XIFreeDeviceInfo(di);
+ di = NULL;
+
+ if( -1 != devid ) {
+ // register 1st XITouchClass device if available
+ XIEventMask mask = {
+ .deviceid = devid,
+ .mask_len = XIMaskLen(XI_TouchEnd) // in bytes
+ };
+
+ mask.mask = (unsigned char*)calloc(mask.mask_len, sizeof(unsigned char));
+ XISetMask(mask.mask, XI_TouchBegin);
+ XISetMask(mask.mask, XI_TouchUpdate);
+ XISetMask(mask.mask, XI_TouchEnd);
+
+ XISelectEvents(dpy, window, &mask, 1);
+
+ free(mask.mask);
+
+ javaWindow->xiTouchDeviceId = devid;
+ }
+ }
+ }
+ }
+
XFlush(dpy);
handles[0] = (jlong)(intptr_t)window;
handles[1] = (jlong)(intptr_t)javaWindow;