Qt 与 XComposite 问题 [英] Qt with XComposite problem

查看:54
本文介绍了Qt 与 XComposite 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个简单的程序,它将所有窗口重定向到后台缓冲区(就像复合管理器那样),然后将它们写入像素图并保存到磁盘.但是我收到了这个错误:

I'm trying to write a simple program, which redirects all the windows to the backbuffer( as the composite manager does ), then write them to pixmap and save to disk. But I got this error:

(.text.startup+0x5e):-1: error: undefined reference to `XCompositeRedirectSubwindows'
(.text.startup+0x171):-1: error: undefined reference to `XCompositeNameWindowPixmap'
:-1: error: collect2: ld returned 1 exit status

代码如下:

#include <QApplication>
#include <QDebug>
#include <X11/Xlib.h>
#include <QPaintDevice>
#include <QX11Info>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
#include <X11/extensions/Xdamage.h>

#include <QPixmap>
#include <QWidget>

int main( int argc, char *argv[] )
{
    QApplication app( argc, argv );
    app.setGraphicsSystem("native");

    Picture frontBuffer;
    XRenderPictFormat *format;
    Window rootWindow;
    int depth;

    Display *dpy = XOpenDisplay( getenv("DISPLAY") );
    rootWindow = XRootWindow( dpy, XDefaultScreen( dpy ) );

    depth = DefaultDepth( dpy, DefaultScreen(dpy) );

    // Redirect all the windows
    XCompositeRedirectSubwindows( dpy, rootWindow, CompositeRedirectManual );

    // Get the format
    format = XRenderFindVisualFormat( dpy, DefaultVisual( dpy, DefaultScreen(dpy) ) );

    XRenderPictureAttributes pa;
    pa.subwindow_mode = IncludeInferiors;

    // Creating front buffer
    frontBuffer = XRenderCreatePicture( dpy, rootWindow, format, CPSubwindowMode, &pa );

    uint nwindows;
    Window root_return, parent_return, *windows;

    XQueryTree( dpy, rootWindow, &root_return,
                    &parent_return, &windows, &nwindows );

    for ( uint i = 0; i < nwindows; i++ ) {
            XWindowAttributes attr;
            if ( !XGetWindowAttributes( dpy, windows[i], &attr ) )
                    continue;

            Pixmap pix = XCompositeNameWindowPixmap( dpy, windows[i] );

            Picture pic = XRenderCreatePicture( dpy, pix, format, 0, 0 );

            QPixmap pixmap(540, 900);
            XRenderComposite( dpy, PictOpSrc, pic, None, pixmap.x11PictureHandle(),
                                          0, 0, 0, 0, 0 , 0, 540, 900 );
            pixmap.save( QString::number( i )+".png", "PNG" );
        }
    }
    XFree( windows );
    return app.exec();
}

推荐答案

您是否将您的程序与 libXcomposite 链接?那就是定义这些函数的库.

Did you link your program with libXcomposite? That's the library which defines those functions.

这篇关于Qt 与 XComposite 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆