diff options
author | Kusanagi Kouichi <slash@ac.auone-net.jp> | 2011-12-14 02:17:55 -0500 |
---|---|---|
committer | James Cloos <cloos@jhcloos.com> | 2011-12-14 12:19:27 -0500 |
commit | 87e10a7b9a97c951ab4d477f61177779ac0a6a66 (patch) | |
tree | 1ea2904519feb9353caabfe5acf5d54d563abb85 | |
parent | d3b3570592e9b9e57f270a0bd86762fd205a2833 (diff) |
XQueryColors: Split a request into multiple requests if necessary
https://bugs.freedesktop.org/show_bug.cgi?id=9160
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: James Cloos <cloos@jhcloos.com>
-rw-r--r-- | src/QuColors.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/QuColors.c b/src/QuColors.c index e51375fa..237b8bf0 100644 --- a/src/QuColors.c +++ b/src/QuColors.c @@ -29,8 +29,8 @@ in this Software without prior written authorization from The Open Group. #endif #include "Xlibint.h" -int -XQueryColors( +static void +_XQueryColors( register Display *dpy, Colormap cmap, XColor *defs, /* RETURN */ @@ -42,11 +42,10 @@ XQueryColors( long nbytes; register xQueryColorsReq *req; - LockDisplay(dpy); GetReq(QueryColors, req); req->cmap = cmap; - req->length += ncolors; /* each pixel is a CARD32 */ + SetReqLen(req, ncolors, ncolors); /* each pixel is a CARD32 */ for (i = 0; i < ncolors; i++) Data32 (dpy, (long *)&defs[i].pixel, 4L); @@ -70,8 +69,31 @@ XQueryColors( } else _XEatData(dpy, (unsigned long) nbytes); } +} + +int +XQueryColors( + register Display * const dpy, + const Colormap cmap, + XColor *defs, /* RETURN */ + int ncolors) +{ + int n; + + if (dpy->bigreq_size > 0) + n = dpy->bigreq_size - (sizeof (xQueryColorsReq) >> 2) - 1; + else + n = dpy->max_request_size - (sizeof (xQueryColorsReq) >> 2); + + LockDisplay(dpy); + while (ncolors >= n) { + _XQueryColors(dpy, cmap, defs, n); + defs += n; + ncolors -= n; + } + if (ncolors > 0) + _XQueryColors(dpy, cmap, defs, ncolors); UnlockDisplay(dpy); SyncHandle(); return 1; } - |