Linux Qt与XComposite问题
我正在尝试编写一个简单的程序,它将所有窗口重定向到backbuffer(就像composite管理器那样),然后将它们写入pixmap并保存到磁盘。但我有一个错误:Linux Qt与XComposite问题,linux,qt,qt4,x11,xlib,Linux,Qt,Qt4,X11,Xlib,我正在尝试编写一个简单的程序,它将所有窗口重定向到backbuffer(就像composite管理器那样),然后将它们写入pixmap并保存到磁盘。但我有一个错误: (.text.startup+0x5e):-1: error: undefined reference to `XCompositeRedirectSubwindows' (.text.startup+0x171):-1: error: undefined reference to `XCompositeNameWindowPixm
(.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();
}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
int main(int argc,char*argv[])
{
QApplication应用程序(argc、argv);
应用程序setGraphicsSystem(“本机”);
图片前缓冲区;
XRenderPictFormat*格式;
窗口根窗口;
智力深度;
Display*dpy=XOpenDisplay(getenv(“Display”);
rootWindow=XRootWindow(dpy,XDefaultScreen(dpy));
深度=默认深度(dpy,默认屏幕(dpy));
//重定向所有窗口
XCompositeDirectSubWindows(dpy、rootWindow、CompositeDirectManual);
//获取格式
格式=XRenderFindVisualFormat(dpy,DefaultVisual(dpy,DefaultScreen(dpy));
XrenderPictureA;
pa.subwindow_mode=包含中间层;
//创建前端缓冲区
frontBuffer=XRenderCreatePicture(dpy、根窗口、格式、CPSubwindowMode和pa);
uint nwindows;
窗口根返回、父返回、*windows;
XQueryTree(dpy、rootWindow和root\u返回、,
&父对象(返回、windows和nwindows);
对于(uint i=0;i
您是否将程序链接到libXcomposite?这就是定义这些函数的库。您是否将程序与libXcomposite链接?这是定义这些函数的库。使用-lXcomposite
或pkg配置--libs xcomposite
使用-lXcomposite
或pkg配置--libs xcomposite编译