设置根窗口的背景颜色
我正在尝试学习 XLib。我搜索了 Feh 程序的源代码以了解如何修改根窗口,但没有结果。
有代码可以测试根窗口访问,但我不明白为什么它不起作用。
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Display *disp2;
Window root2;
int main(int argc, char *argv[])
{
disp2 = XOpenDisplay(NULL);
root2 = RootWindow(disp2, DefaultScreen(disp2));
// Generation of random number to set window color
srand(time(NULL));
int i = rand();
// Setting background
// I forgot to change 256 to i
// XSetWindowBackground(disp2, root2, 256 );
XSetWindowBackground(disp2, root2, i
XClearWindow(disp2, root2);
// Showing the random number
printf ("%i \n", i );
return 0;
}
那么,这段代码有什么问题呢?
I am trying to learn XLib. And I searched throught source of Feh program to understand how to modify root window, but I had no results.
There is code to test root window access, but I don't understand why it is not working.
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Display *disp2;
Window root2;
int main(int argc, char *argv[])
{
disp2 = XOpenDisplay(NULL);
root2 = RootWindow(disp2, DefaultScreen(disp2));
// Generation of random number to set window color
srand(time(NULL));
int i = rand();
// Setting background
// I forgot to change 256 to i
// XSetWindowBackground(disp2, root2, 256 );
XSetWindowBackground(disp2, root2, i
XClearWindow(disp2, root2);
// Showing the random number
printf ("%i \n", i );
return 0;
}
So, what's wrong in this code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
代码中没有任何问题。您只是想打印随机数。如果您需要打印 0-256 之间的随机数,请尝试
you can change color of root window in command line
Check this out!
你的具体问题是什么。
你的问题缺乏背景。
There is nothing wrong in the code. You're just trying to print random number. If you need to print random number fro.m 0-256 then try
you can change color of root window in command line
Check this out!
What is your exact problem.
Your question lacks context.