diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-11-27 10:47:56 +1030 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-11-27 13:20:47 +1030 |
commit | ddcc71df2a273a410cb5a933aef5501fa56d84cf (patch) | |
tree | c64d31e9fe3da70ee8f2d8211f19e49df35813e5 | |
parent | a9191fcf42a4f5ef5022450b327afe2562c9a0e2 (diff) |
GetDeviceControl: calculate the length field correctly.
Length field should indicate the length of the struct in bytes. Not the length
of the pointer to the struct...
-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; |