所以我有以下代码,不知道我是否添加了太多/很少但是它仍然用于conext。
Window root = XCreateWindow(proc->display,
RootWindow(proc->display, screen),
0, 0, width + 500, height + 500, 0,
CopyFromParent, InputOutput,
CopyFromParent, CWEventMask, &attr);
XSetWindowBackground(proc->display, root, WhitePixel(proc->display, screen));
XFlush(proc->display);
XMapWindow(proc->display, root);
Window avaliableDevices = XCreateSimpleWindow(proc->display, root, 10, 50,
220, 650, 5, BlackPixel(proc->display, screen),
WhitePixel(proc->display, screen));
XFlush(proc->display);
XMapWindow(proc->display, avaliableDevices);
sleep(1);
XDrawString(proc->display, root, DefaultGC(proc->display, DefaultScreen(proc->display))
, 20, 20, "hello", strlen("hello"));
Window networkedDevices = XCreateSimpleWindow(proc->display, root, /* display, parent */
900, 50, /* x, y: the window manager will place the window elsewhere */
220, 650, /* width, height */
5, BlackPixel(proc->display, screen), /* border width & colour, unless you have a window manager */
WhitePixel(proc->display, screen)); /* background colour */
XDrawString(proc->display, root, DefaultGC(proc->display, DefaultScreen(proc->display))
, 920, 40, "NETWORKED DEVICES", strlen("NETWORKED DEVICES"));
我遇到的问题是没有睡眠(1),字符串不会在屏幕上绘制,为什么有任何想法有点混淆?
我第一次打电话给它,它需要一个睡眠,但第二次没问题:/