Results 1 to 2 of 2

Thread: Qt + XRenderComposite

  1. #1
    Join Date
    Jun 2010
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Maemo/MeeGo

    Default Qt + XRenderComposite

    Hi all.

    I am trying to render the contents of the window in to QWidget or QPixmap using XComposite and XRender. The Issue I'm facing is that I can't get the picture be rendered in the QWidget. The code below has been written using the following tutorial: http://ktown.kde.org/~fredrik/composite_howto.html The window ID is hardcoded, so there can be any other window ID used. QWidget window which opens does not display the contents of the original window, but just shows the blank gray rectangle. The same thing is if I use the QPixmap, it contains just black rectangle and nothing else. XRender support is enabled.

    What I'm missing here ?

    Qt Code:
    1. int main( int argc, char *argv[] ) {
    2.  
    3. QApplication app( argc, argv );
    4.  
    5. Display *dpy = XOpenDisplay( getenv("DISPLAY") );
    6.  
    7. Window window = 2097154;
    8.  
    9. XCompositeRedirectWindow( dpy, window, CompositeRedirectManual );
    10.  
    11. XWindowAttributes attr;
    12.  
    13. XGetWindowAttributes( dpy, window, &attr );
    14.  
    15. XRenderPictFormat *format = XRenderFindVisualFormat( dpy, attr.visual );
    16. bool hasAlpha = ( format->type == PictTypeDirect && format->direct.alphaMask );
    17. int x = attr.x;
    18. int y = attr.y;
    19. int width = attr.width;
    20. int height = attr.height;
    21.  
    22. qDebug() << hasAlpha << x << y << width << height;
    23.  
    24. XRenderPictureAttributes pa;
    25. pa.subwindow_mode = IncludeInferiors; // Don't clip child widgets
    26.  
    27.  
    28. QWidget widget;
    29. widget.setGeometry( 100, 100, 500, 500 );
    30. widget.show();
    31. Picture picture = XRenderCreatePicture( dpy, window, format, CPSubwindowMode, &pa );
    32.  
    33. XRenderComposite( dpy, PictOpSrc, picture, None,
    34. widget.x11PictureHandle(), 0, 0, 0, 0, 0, 0, 500, 500 );
    35.  
    36. XRenderFreePicture( dpy, picture );
    37.  
    38. return app.exec();
    39. }
    To copy to clipboard, switch view to plain text mode 

    I would be also grateful if someone could provide the sources of the qx11mirror class from Graphics-dojo ( http://labs.trolltech.com/page/Graph...ples/Examples2 ) As the SVN link doesn't seem to work

  2. #2
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qt + XRenderComposite

    I wrote a demo, hope it help you.x11MirrorWidget.tar.bz2

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.