diff options
-rw-r--r-- | src/XGetDCtl.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/XGetDCtl.c b/src/XGetDCtl.c index 2e06b65..7689059 100644 --- a/src/XGetDCtl.c +++ b/src/XGetDCtl.c @@ -104,6 +104,12 @@ XGetDeviceControl(dpy, dev, control) sav = d; _XRead(dpy, (char *)d, nbytes); + /* In theory, we should just be able to use d->length to get the size. + * Turns out that a number of X servers (up to and including server + * 1.4) sent the wrong length value down the wire. So to not break + * apps that run against older servers, we have to calculate the size + * manually. + */ switch (d->control) { case DEVICE_RESOLUTION: { @@ -170,7 +176,7 @@ XGetDeviceControl(dpy, dev, control) XDeviceAbsCalibState *C = (XDeviceAbsCalibState *) Device; C->control = DEVICE_ABS_CALIB; - C->length = sizeof(C); + C->length = sizeof(XDeviceAbsCalibState); C->min_x = c->min_x; C->max_x = c->max_x; C->min_y = c->min_y; @@ -188,7 +194,7 @@ XGetDeviceControl(dpy, dev, control) XDeviceAbsAreaState *A = (XDeviceAbsAreaState *) Device; A->control = DEVICE_ABS_AREA; - A->length = sizeof(A); + A->length = sizeof(XDeviceAbsAreaState); A->offset_x = a->offset_x; A->offset_y = a->offset_y; A->width = a->width; @@ -204,7 +210,7 @@ XGetDeviceControl(dpy, dev, control) XDeviceCoreState *C = (XDeviceCoreState *) Device; C->control = DEVICE_CORE; - C->length = sizeof(C); + C->length = sizeof(XDeviceCoreState); C->status = c->status; C->iscore = c->iscore; |