xfreerdp-client: Xinput2 hacks

This commit is contained in:
corey 2013-04-24 17:59:53 -04:00
parent d404c0dab0
commit a39faa3405
2 changed files with 102 additions and 10 deletions

View File

@ -23,6 +23,7 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XInput2.h>
#include <freerdp/locale/keyboard.h>
@ -975,8 +976,18 @@ BOOL xf_event_process(freerdp* instance, XEvent* event)
case PropertyNotify:
status = xf_event_PropertyNotify(xfi, event, xfi->remote_app);
break;
/*
case XI_TouchBegin:
case XI_TouchUpdate:
case XI_TouchEnd:
printf("TouchEvent!\n");
break;
*/
}
XSync(xfi->display, FALSE);
return status;

View File

@ -159,6 +159,9 @@ void testXI(rdpContext* context)
XIDeviceInfo *info;
int ndevices, i, j;
XIEventMask eventmask;
unsigned char mask[1] = { 0 };
xfi = ((xfContext*) context)->xfi;
@ -178,7 +181,7 @@ void testXI(rdpContext* context)
for (i = 0; i < ndevices; i++)
{
XIDeviceInfo *dev = &info[i];
printf("Device name %s\n", dev->name);
printf("Device name [id] %s [%d]\n", dev->name, dev->deviceid);
for (j = 0; j < dev->num_classes; j++)
{
XIAnyClassInfo *class = dev->classes[j];
@ -193,6 +196,20 @@ void testXI(rdpContext* context)
}
}
////////////////////
eventmask.deviceid = 13;
eventmask.mask_len = sizeof(mask); /* always in bytes */
eventmask.mask = mask;
/* now set the mask */
XISetMask(mask, XI_TouchBegin);
XISetMask(mask, XI_TouchUpdate);
XISetMask(mask, XI_TouchEnd);
XISelectEvents(xfi->display, xfi->window, &eventmask, 1);
printf("Should now be able to get touch events\n");
}
void testXV(rdpContext* context)
@ -501,16 +518,8 @@ void xf_hw_end_paint(rdpContext* context)
w = cinvalid[i].w;
h = cinvalid[i].h;
//here
//XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, w/2, h/2, x, y);
if (run == 0)
{
run++;
//testXV(context);
testXI(context);
XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, x, y, w/2, h/2, x, y);
}
}
XFlush(xfi->display);
@ -1082,6 +1091,78 @@ BOOL xf_post_connect(freerdp* instance)
xf_cliprdr_init(xfi, channels);
//begin init touch input
{
int opcode, event, error;
int major = 2, minor = 2;
XIDeviceInfo *info;
int ndevices, i, j;
XIEventMask eventmask;
unsigned char mask[1] = { 0 };
if (XQueryExtension(xfi->display, "XInputExtension", &opcode, &event, &error))
{
printf("X Input extension available.\n");
XIQueryVersion(xfi->display, &major, &minor);
if (!(major * 1000 + minor < 2002))
{
printf("XI 2.2 supported\n");
info = XIQueryDevice(xfi->display, XIAllDevices, &ndevices);
for (i = 0; i < ndevices; i++)
{
XIDeviceInfo *dev = &info[i];
printf("Device name [id] %s [%d]\n", dev->name, dev->deviceid);
for (j = 0; j < dev->num_classes; j++)
{
XIAnyClassInfo *class = dev->classes[j];
XITouchClassInfo *t = (XITouchClassInfo*)class;
if (class->type != XITouchClass)
continue;
printf("%s touch device, supporting %d touches.\n",
(t->mode == XIDirectTouch) ? "direct" : "dependent",
t->num_touches);
}
}
////////////////////
eventmask.deviceid = 13;
eventmask.mask_len = sizeof(mask); /* always in bytes */
eventmask.mask = mask;
/* now set the mask */
XISetMask(mask, XI_TouchBegin);
XISetMask(mask, XI_TouchUpdate);
XISetMask(mask, XI_TouchEnd);
XISelectEvents(xfi->display, xfi->window->handle, &eventmask, 1);
printf("Should now be able to get touch events\n");
}
else
{
printf("Server does not support XI 2.2\n");
}
}
else
{
printf("X Input extension not available!!!\n");
}
}
//end init touch input
IFCALL(xfi->client->OnResizeWindow, instance, settings->DesktopWidth, settings->DesktopHeight);
return TRUE;