summaryrefslogtreecommitdiffstats
path: root/src/newt/native/X11Window.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-03-27 00:13:06 +0100
committerGitHub <[email protected]>2019-03-27 00:13:06 +0100
commit92006e4baef57f1f3fb647dd307aed5989fd4c8d (patch)
tree401b140df18dd1870122be63724bc7b850509104 /src/newt/native/X11Window.c
parent67620bac176666b7f4c2f7a572ba175b68415141 (diff)
parentec6d2ca98674804c9e9162dddefda2962b91bf12 (diff)
Merge pull request #102 from Yodoga/feature_multitouch_x11_1348
add touch event support for x11 server
Diffstat (limited to 'src/newt/native/X11Window.c')
-rw-r--r--src/newt/native/X11Window.c44
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;