On 7/30/21 10:49 PM, Chuanlong Du wrote:
I was reading the source code of the file GetImage.c <https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/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 <https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c#L83>.
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 <https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/GetImage.c#L85>, 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.coopersm...@oracle.com Oracle Solaris Engineering - https://blogs.oracle.com/alanc