aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib
diff options
context:
space:
mode:
authorKusanagi Kouichi <slash@ac.auone-net.jp>2011-12-14 02:17:55 -0500
committerUlrich Sibiller <uli42@gmx.de>2016-10-19 21:40:25 +0200
commit5eb1147cc32d59c2f3490d38918e386676eac94b (patch)
treef64e81bd580de10f3baa9345dc63aecc4eb909f6 /nx-X11/lib
parent30d4454e350ac7c5558d79fd09dfd49ffd415dd5 (diff)
downloadnx-libs-5eb1147cc32d59c2f3490d38918e386676eac94b.tar.gz
nx-libs-5eb1147cc32d59c2f3490d38918e386676eac94b.tar.bz2
nx-libs-5eb1147cc32d59c2f3490d38918e386676eac94b.zip
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> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib')
-rw-r--r--nx-X11/lib/X11/QuColors.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/nx-X11/lib/X11/QuColors.c b/nx-X11/lib/X11/QuColors.c
index a8bc8837b..7937f5e5a 100644
--- a/nx-X11/lib/X11/QuColors.c
+++ b/nx-X11/lib/X11/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 */
@@ -40,11 +40,10 @@ XQueryColors(
xQueryColorsReply rep;
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,6 +69,30 @@ XQueryColors(
else
_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);
SyncHandle();
return 1;