Newsgroups: comp.windows.x
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines
From: tomt@maui.coral.COM (Tom Tulinsky)
Subject: how to XDrawLines > MaxRequestSize
Message-ID: <9106121938.AA23986@maui.coral.com>
Sender: daemon@athena.mit.edu (Mr Background)
Organization: The Internet
Date: 12 Jun 91 19:38:09 GMT
Lines: 32

I hadn't realized that there was a limit to the size of the lists that
the X poly requests like XDrawLines can handle until recently, when I
read Kenton Lee's article 'Behind Curtain X' in June's Unix Review.
Here's some code which will draw lines with an arbitrary length array
of points.  

A couple of pointed questions:
- If it's so simple, why can't the Xlib do it for you?
- Xlib should at least tell you the exact number of points you can
  give to each request, instead of making you divide by the size of the
  array element and subtract the header size...

/* allow for X protocol request header; 3 is supposed to be enough for now, 
 * but there's no guarantee this will not change...this is pretty sleazy 
 * anyhow
 */
#define FUDGE 10

int chunksize, ii, reqsize;

chunksize = XMaxRequestSize(gDisplay) - FUDGE;

for (ii=0; ii<numpts; ii+=chunksize-1)
{
   /* last chunk is short */
   reqsize = min(chunksize, numpts-ii);

   XDrawLines (dis, win, gc, Xpts[ii], reqsize, mode);

   printf("drawing points %d to %d\n", ii,ii+reqsize-1);
}

