Question regarding XGetImage in libx11

Chuanlong Du longendu at
Sun Aug 1 00:40:47 UTC 2021

 Thank you very much for the explanation, Alan!

    On Saturday, July 31, 2021, 9:36:07 AM PDT, Alan Coopersmith <alan.coopersmith at> wrote:  
 On 7/30/21 10:49 PM, Chuanlong Du wrote:
> I was reading the source code of the file GetImage.c 
> <> and got 
> confused about the function XGetImage. Specifically, I'm confused about where 
> the defined variable registerxGetImageReq*req; is used. The function never uses 
> it again after setting values for req at line 83 
> <>. 

The GetReq() call at line 73 sets up req to be in the Xlib buffer of requests to
send to the X server.  The _XReply call at line 85 causes everything in that
buffer, including req, to be sent to the X server for processing, so it
implicitly processes the contents of req.

> At line 85 
> <>, 
> does the function _XReply copy the whole display/screen's data to rep or just 
> the specified rectangle defined by req? If _XReply copies the whole 
> display/screen's data, where does the function XGetImage crop the image to keep 
> the specified rectangle only?

The function _XReply simply sends the message to the X server, who does all the
processing and returns the reply.  The X server is responsible for copying just
the specified area, not the whole screen, so Xlib does not need to do any
cropping on its own.

    -Alan Coopersmith-              alan.coopersmith at
    Oracle Solaris Engineering -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the xorg mailing list