C++ x11不匹配错误X_CreateWindow序列号7
我正在编写一个带有事件输出的基本X应用程序。我在运行程序时遇到错误匹配。据我所知,代码是正确的,但我不知道为什么我会收到错误,也没有太多关于这方面的文档。这是我的createWindow函数:C++ x11不匹配错误X_CreateWindow序列号7,c++,linux,x11,xlib,C++,Linux,X11,Xlib,我正在编写一个带有事件输出的基本X应用程序。我在运行程序时遇到错误匹配。据我所知,代码是正确的,但我不知道为什么我会收到错误,也没有太多关于这方面的文档。这是我的createWindow函数: void appevent::createWindow() { XPixmapFormatValues *pixmapFormats; int count; const int bitsPerByte {8}; dpy = XOpenDisplay(NULL);
void appevent::createWindow() {
XPixmapFormatValues *pixmapFormats;
int count;
const int bitsPerByte {8};
dpy = XOpenDisplay(NULL);
pixmapFormats = XListPixmapFormats(dpy, &count);
for (int i {} ; i < count ; i++) {
if(pixmapFormats[i].depth > depth) {
depth = pixmapFormats[i].depth;
bytespp = pixmapFormats[i].bits_per_pixel / bitsPerByte;
scanlinePad = pixmapFormats[i].scanline_pad;
}
}
XFree(pixmapFormats);
std::cout << "Max depth of display: " << depth << std::endl;
std::cout << "Bytes per pixel: " << bytespp << std::endl;
vis = DefaultVisual(dpy, 0);
switch(vis->c_class) {
case PseudoColor: std::cout << "Vis is pseudocolor" << std::endl; break;
case StaticColor: std::cout << "Vis is StaticColor" << std::endl; break;
case GrayScale : std::cout << "Vis is GrayScale" << std::endl; break;
case StaticGray : std::cout << "Vis is StaticGray" << std::endl; break;
case DirectColor: std::cout << "Vis is DirectColor" << std::endl; break;
case TrueColor : std::cout << "Vis is TrueColor" << std::endl; break;
}
w = XCreateWindow(dpy, DefaultRootWindow(dpy), 100, 100,
screenWidth, screenHeight,
0,
depth, CopyFromParent, vis,
0, NULL);
XStoreName(dpy, w, "Hello");
XMapWindow(dpy, w);
screen = new char[screenWidth * screenHeight * bytespp];
if(ImageByteOrder(dpy) == LSBFirst) std::cout << "LSB first" << std::endl;
else std::cout << "MSB first" << std::endl;
ximg = XCreateImage(dpy, vis, depth,
ZPixmap,
0,
screen,
screenWidth, screenHeight,
scanlinePad,
0);
XSetForeground(dpy, DefaultGC(dpy, 0), -0);
XSetBackground(dpy, DefaultGC(dpy, 0), 0);
}
我在X方面没有太多经验。这里的错误是什么
Max depth of display: 32
Bytes per pixel: 4
Vis is TrueColor
LSB first
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 1 (X_CreateWindow)
Serial number of failed request: 7
Current serial number in output stream: 10