From 878d9e76764d27f5af861817b46b2caf2d89d7c4 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 18 Jul 2006 11:43:24 -0400 Subject: add sensible DEVICE_TOUCHSCREEN and DEVICE_CORE controls Add a more sensible DEVICE_TOUCHSCREEN control, which allows you to clip the x and y values. Add a DEVICE_CORE control, which toggles the sending of core events by extended devices. --- src/XChgDCtl.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- src/XGetDCtl.c | 47 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 87 insertions(+), 8 deletions(-) diff --git a/src/XChgDCtl.c b/src/XChgDCtl.c index be5d941..a196523 100644 --- a/src/XChgDCtl.c +++ b/src/XChgDCtl.c @@ -92,7 +92,7 @@ XChangeDeviceControl(dpy, dev, control, d) R = (XDeviceResolutionControl *) d; r.control = DEVICE_RESOLUTION; r.length = sizeof(xDeviceResolutionCtl) + - R->num_valuators * sizeof(int); + R->num_valuators * sizeof(int); r.first_valuator = R->first_valuator; r.num_valuators = R->num_valuators; req->length += ((unsigned)(r.length + 3) >> 2); @@ -107,6 +107,52 @@ XChangeDeviceControl(dpy, dev, control, d) } else return (rep.status); } + case DEVICE_TOUCHSCREEN: + { + XDeviceTSControl *T = (XDeviceTSControl *) d; + xDeviceTSCtl t; + + t.control = DEVICE_TOUCHSCREEN; + t.length = sizeof(t); + t.min_x = T->min_x; + t.max_x = T->max_x; + t.min_y = T->min_y; + t.max_y = T->max_y; + t.button_threshold = T->button_threshold; + + req->length += (sizeof(t) + 3) >> 2; + Data(dpy, (char *) &t, sizeof(t)); + + if (!_XReply(dpy, (xReply *) &rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); + return NoSuchExtension; + } + else { + return rep.status; + } + } + case DEVICE_CORE: + { + XDeviceCoreControl *C = (XDeviceCoreControl *) d; + xDeviceCoreCtl c; + + c.control = DEVICE_CORE; + c.length = sizeof(c); + c.status = C->status; + + req->length += (sizeof(c) + 3) >> 2; + Data (dpy, (char *) &c, sizeof(c)); + + if (!_XReply(dpy, (xReply *) &rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); + return NoSuchExtension; + } + else { + return rep.status; + } + } default: { xDeviceCtl u; diff --git a/src/XGetDCtl.c b/src/XGetDCtl.c index 9862dcc..139f7e7 100644 --- a/src/XGetDCtl.c +++ b/src/XGetDCtl.c @@ -61,13 +61,11 @@ SOFTWARE. #include #include "XIint.h" -XDeviceControl * XGetDeviceControl(dpy, dev, control) - register Display * - dpy; - XDevice * - dev; - int - control; +XDeviceControl * +XGetDeviceControl(dpy, dev, control) + register Display *dpy; + XDevice *dev; + int control; { int size = 0; int nbytes, i; @@ -116,6 +114,15 @@ XDeviceControl * XGetDeviceControl(dpy, dev, control) (3 * sizeof(int) * r->num_valuators); break; } + case DEVICE_TOUCHSCREEN: + { + size += sizeof(xDeviceTSState); + break; + } + case DEVICE_CORE: + { + size += sizeof(xDeviceCoreState); + } default: size += d->length; break; @@ -152,6 +159,32 @@ XDeviceControl * XGetDeviceControl(dpy, dev, control) *iptr++ = *iptr2++; break; } + case DEVICE_TOUCHSCREEN: + { + xDeviceTSState *t = (xDeviceTSState *) d; + XDeviceTSState *T = (XDeviceTSState *) Device; + + T->control = DEVICE_TOUCHSCREEN; + T->length = sizeof(T); + T->min_x = t->min_x; + T->max_x = t->max_x; + T->min_y = t->min_y; + T->max_y = t->max_y; + T->button_threshold = t->button_threshold; + + break; + } + case DEVICE_CORE: + { + xDeviceCoreState *c = (xDeviceCoreState *) d; + XDeviceCoreState *C = (XDeviceCoreState *) Device; + + C->control = DEVICE_CORE; + C->length = sizeof(C); + C->status = c->status; + + break; + } default: break; } -- cgit v1.2.3