[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg-devel
Subject:    Fwd: NameWindowPixmap problem
From:       Petr Zalyautdinov <ya.betmen () gmail ! com>
Date:       2015-02-28 7:01:44
Message-ID: CANNseYKoc7F8pcaeVBSMBb0uFiyzxSKaAxRA__v1hdmwB+Qf5Q () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Dear All

I try get screenshots for all opened applications, but i have problem with
NameWindowPixmap. I shared my simple example application:
http://pastebin.com/Qw8ZZ2i8.

I make screenshots using method below

QPixmap makeScreenshot(XID xid, Display *display){
    QPixmap qpxmp;
    XCompositeRedirectWindow (display, xid, CompositeRedirectAutomatic);
    XFlush(display);
    Pixmap pixmap = XCompositeNameWindowPixmap (display, xid);
    XSync(display, false);
    qpxmp = QPixmap::fromX11Pixmap(pixmap).copy();
    XFreePixmap (display, pixmap);
    XCompositeUnredirectWindow (display, xid, CompositeRedirectAutomatic);
    return qpxmp;
}

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:
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Extension:    139 (RENDER)
  Minor opcode: 4 (RenderCreatePicture)
  Resource id:  0x4a0006d
X Error: RenderBadPicture (invalid Picture parameter) 143
  Extension:    139 (RENDER)
  Minor opcode: 8 (RenderComposite)
  Resource id:  0x24001b4
X Error: RenderBadPicture (invalid Picture parameter) 143
  Extension:    139 (RENDER)
  Minor opcode: 7 (RenderFreePicture)
  Resource id:  0x24001b4

In my example I try get screenshot twice:
QPixmap p = makeScreenshot(wid, display);
p = makeScreenshot(wid, display);

And I have same errors in log, but images usually correct. Also if I remove
line "XFreePixmap (display, pixmap);" then errors disappears.

Actually, I'm nub. What did I do wrong? How I can know moment when pixmap
is ready to use?

Kind regards

[Attachment #5 (text/html)]

<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 &quot;XFreePixmap (display, \
pixmap);&quot; then errors disappears.</div><div><br></div><div>Actually, I&#39;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>


[Attachment #6 (text/plain)]

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic