reading a window's content with Xlib's XGetImage reveals portions of overlapping windows even with the backing store attribute set to Always
Amos Tibaldi
amos.tibaldi at gmail.com
Thu Aug 20 12:27:05 PDT 2009
Hello,
I am trying to read the content of a portion of a window with the
function XGetImage:
XImage <http://tronche.com/gui/x/xlib/graphics/images.html#XImage>
*XGetImage(*display*, *d*, *x*, *y*, *width*, *height*, *plane_mask*,
*format*)
Display
<http://tronche.com/gui/x/xlib/display/opening.html#Display>
**display*;
Drawable *d*;
int *x*, *y*;
unsigned int *width*, *height*;
unsigned long *plane_mask*;
int *format*;
so from an already mapped window called desktopWin I successfully
obtain an image with the code:
anImage = XGetImage(dpy, desktopWin, 0, 0, 200, 200, AllPlanes, ZPixmap);
but when I read the pixels in anImage->Data, if there is a window that
overlaps the
region that I read (0, 0, 200, 200), the content of that window is returned
in
"anImage" instead of the original content of the window.
I have tried to set the backing store attribute of the window desktopWin to
"Always"
in order to see if that could help, in fact:
----------------------------------------
3.2.4 Backing Store Attribute Some implementations of the X server may
choose to maintain the contents of
*InputOutput<http://tronche.com/gui/x/xlib/window/create.html#InputClass>
* windows. If the X server maintains the contents of a window, the
off-screen saved pixels are known as backing store. The backing store
advises the X server on what to do with the contents of a window. The
backing-store attribute can be set to *NotUseful* (default), *WhenMapped*,
or *Always*.
A backing-store attribute of *NotUseful* advises the X server that
maintaining contents is unnecessary, although some X implementations may
still choose to maintain contents and, therefore, not generate
*Expose<http://tronche.com/gui/x/xlib/events/exposure/expose.html>
* events. A backing-store attribute of *WhenMapped* advises the X server
that maintaining contents of obscured regions when the window is mapped
would be beneficial. In this case, the server may generate an
*Expose<http://tronche.com/gui/x/xlib/events/exposure/expose.html>
* event when the window is created. A backing-store attribute of
*Always*advises the X server that maintaining contents even when the
window is
unmapped would be beneficial. Even if the window is larger than its parent,
this is a request to the X server to maintain complete contents, not just
the region within the parent window boundaries. While the X server maintains
the window's contents,
*Expose<http://tronche.com/gui/x/xlib/events/exposure/expose.html>
* events normally are not generated, but the X server may stop maintaining
contents at any time.
When the contents of obscured regions of a window are being maintained,
regions obscured by noninferior windows are included in the destination of
graphics requests (and source, when the window is the source). However,
regions obscured by inferior windows are not included.
----------------------------------------
So I have used the code:
attr.backing_store = Always;
valuemask |= CWBackingStore;
XChangeWindowAttributes(dpy, desktopWin, valuemask, &attr);
Unfortunately it has not helped, since overlapping portions of
other windows are still returned in anImage instead of the original
content of the window that I want to grab. What could I do to solve
this matter?
Thanks in advance,
--
Amos Tibaldi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20090820/9b0ee71a/attachment.html>
More information about the xorg
mailing list