我试图打开一个X11窗口,打印一个像素,然后添加代码以使Terminate()返回true。但这不会成为一个窗口。这是我的代码:
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <iostream>
int x = 0;
int y = 0;
bool Termination() {
return true;
}
int main() {
Display *dspl = XOpenDisplay(NULL);
if (!dspl) return 1;
int screenNumber = DefaultScreen(dspl);
unsigned long white = WhitePixel(dspl, screenNumber);
unsigned long black = BlackPixel(dspl, screenNumber);
Window win = XCreateSimpleWindow(dspl, DefaultRootWindow(dspl), 50, 50, 1280, 720, 0, black, white);
XSetStandardProperties(dspl, win, "Lel", "Gaem", None, NULL, 0, NULL);
GC gc = XCreateGC(dspl, win, 0,0);
XSetBackground(dspl, gc, black);
XSetForeground(dspl, gc, white);
XClearWindow(dspl, win);
XMapRaised(dspl, win);
XDrawPoint(dspl, win, gc, x, y);
while (Termination())
{
}
XFreeGC(dspl, gc);
XDestroyWindow(dspl, win);
XCloseDisplay(dspl);
printf("Job's done!\n");
return 0;
}
是什么使X11无法显示我的窗口? 最佳答案
在此之前添加
XMapWindow(dspl, win);
XInternAtom(dspl, "WM_DELETE_WINDOW", False);
关于c++ - X11无法打开窗口,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/64453842/