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:21:11 +1030 |
commit | 5ac8f5dcfb2cf5f695c903179a5a95ac6bd4303e (patch) | |
tree | 4a8deec9c9767da7eb03ff48debdc232c0e38bdb | |
parent | 0239ef13d66113024066b7db8ade3942af563656 (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...
(cherry picked from commit ddcc71df2a273a410cb5a933aef5501fa56d84cf)
-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; |