Commit 5eb1147c authored by Kusanagi Kouichi's avatar Kusanagi Kouichi Committed by Ulrich Sibiller

XQueryColors: Split a request into multiple requests if necessary

parent 30d4454e
...@@ -29,8 +29,8 @@ in this Software without prior written authorization from The Open Group. ...@@ -29,8 +29,8 @@ in this Software without prior written authorization from The Open Group.
#endif #endif
#include "Xlibint.h" #include "Xlibint.h"
int static void
XQueryColors( _XQueryColors(
register Display *dpy, register Display *dpy,
Colormap cmap, Colormap cmap,
XColor *defs, /* RETURN */ XColor *defs, /* RETURN */
...@@ -40,11 +40,10 @@ XQueryColors( ...@@ -40,11 +40,10 @@ XQueryColors(
xQueryColorsReply rep; xQueryColorsReply rep;
register xQueryColorsReq *req; register xQueryColorsReq *req;
LockDisplay(dpy);
GetReq(QueryColors, req); GetReq(QueryColors, req);
req->cmap = cmap; 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++) for (i = 0; i < ncolors; i++)
Data32 (dpy, (long *)&defs[i].pixel, 4L); Data32 (dpy, (long *)&defs[i].pixel, 4L);
...@@ -70,6 +69,30 @@ XQueryColors( ...@@ -70,6 +69,30 @@ XQueryColors(
else else
_XEatDataWords(dpy, rep.length); _XEatDataWords(dpy, rep.length);
} }
}
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); UnlockDisplay(dpy);
SyncHandle(); SyncHandle();
return 1; return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment