<div dir="ltr"><div class="gmail_quote"><div dir="ltr"><div>Dear All</div><div><br></div><div>I try get screenshots for all opened applications, but i have problem with NameWindowPixmap. I shared my simple example application: <a href="http://pastebin.com/Qw8ZZ2i8" target="_blank">http://pastebin.com/Qw8ZZ2i8</a>.</div><div><br></div><div>I make screenshots using method below</div><div><br></div><div>QPixmap makeScreenshot(XID xid, Display *display){</div><div> QPixmap qpxmp;</div><div> XCompositeRedirectWindow (display, xid, CompositeRedirectAutomatic);</div><div> XFlush(display);</div><div> Pixmap pixmap = XCompositeNameWindowPixmap (display, xid);</div><div> XSync(display, false);</div><div> qpxmp = QPixmap::fromX11Pixmap(pixmap).copy();</div><div> XFreePixmap (display, pixmap);</div><div> XCompositeUnredirectWindow (display, xid, CompositeRedirectAutomatic);</div><div> return qpxmp;</div><div>}</div><div><br></div><div>Usually it works, but sometimes I face with problems: pixmap exists, but it wrong, it could be black, empty or corrupted image. This cases generates same log entries:</div><div>X Error: BadDrawable (invalid Pixmap or Window parameter) 9</div><div> Extension: 139 (RENDER)</div><div> Minor opcode: 4 (RenderCreatePicture)</div><div> Resource id: 0x4a0006d</div><div>X Error: RenderBadPicture (invalid Picture parameter) 143</div><div> Extension: 139 (RENDER)</div><div> Minor opcode: 8 (RenderComposite)</div><div> Resource id: 0x24001b4</div><div>X Error: RenderBadPicture (invalid Picture parameter) 143</div><div> Extension: 139 (RENDER)</div><div> Minor opcode: 7 (RenderFreePicture)</div><div> Resource id: 0x24001b4</div><div><br></div><div>In my example I try get screenshot twice:</div><div>QPixmap p = makeScreenshot(wid, display);</div><div>p = makeScreenshot(wid, display);</div><div><br></div><div>And I have same errors in log, but images usually correct. Also if I remove line "XFreePixmap (display, pixmap);" then errors disappears.</div><div><br></div><div>Actually, I'm nub. What did I do wrong? How I can know moment when pixmap is ready to use?</div><div><br></div><div>Kind regards</div></div>
</div><br></div>