diff options
author | Danny Koernig <[email protected]> | 2016-11-17 14:38:52 +0100 |
---|---|---|
committer | Danny Koernig <[email protected]> | 2016-11-17 14:38:52 +0100 |
commit | ec6d2ca98674804c9e9162dddefda2962b91bf12 (patch) | |
tree | a82aa279df735b66f9d5d793c465ec9f2b678371 /src/newt/native/X11Window.c | |
parent | 45cc13c4d68fb3137b741cbc39ea653c15db2f66 (diff) |
add touch event support for x11 server
Diffstat (limited to 'src/newt/native/X11Window.c')
-rw-r--r-- | src/newt/native/X11Window.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index de2bddc86..7208b205a 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -952,6 +952,50 @@ JNIEXPORT jlongArray JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWind NewtWindows_setMinMaxSize(dpy, javaWindow, width, height, width, height); } } + + { + XIDeviceInfo *di; + XIDeviceInfo *dev; + XITouchClassInfo *class; + int devid = -1; + + int cnt; + int i, j; + + di = XIQueryDevice(dpy, XIAllDevices, &cnt); + for (i = 0; i < cnt; i ++) + { + dev = &di[i]; + for (j = 0; j < dev->num_classes; j ++) + { + class = (XITouchClassInfo*)(dev->classes[j]); + if (class->type != XITouchClass) + { + devid = dev->deviceid; + break; + } + } + if(devid != -1) + { + break; + } + } + + XIEventMask mask = { + .deviceid = devid, //XIAllDevices, + .mask_len = XIMaskLen(XI_TouchEnd) + }; + + mask.mask = (unsigned char*)calloc(3, sizeof(char)); + XISetMask(mask.mask, XI_TouchBegin); + XISetMask(mask.mask, XI_TouchUpdate); + XISetMask(mask.mask, XI_TouchEnd); + + XISelectEvents(dpy, window, &mask, 1); + + free(mask.mask); + } + XFlush(dpy); handles[0] = (jlong)(intptr_t)window; handles[1] = (jlong)(intptr_t)javaWindow; |