我使用fedora 14系统。 当我使用starx启动桌面系统时,我创建了一个Xlib程序,代码如下:
Atom wmStateAbove = XInternAtom(display, "_NET_WM_STATE_ABOVE",1);
if(wmStateAbove != None)
printf("_NET_WM_STATE_ABOVE has atom of %ld \n", (long)wmStateAbove);
else
printf("ERROR: can't find atom for _NET_WM_STATE_Above! \n");
Atom wmNetWmState = XInternAtom(display, "_NET_WM_STATE", 1);
if(wmNetWmState != None)
printf("_NET_WM_STATE has atom of %ld \n", (long)wmNetWmState);
else
printf("ERROR: can't find atom for _NET_WM_STATE! \n");
if(wmStateAbove != None)
{
printf("======\n");
XClientMessageEvent xclient;
memset(&xclient, 0, sizeof(xclient));
xclient.type = ClientMessage;
xclient.window = win;
xclient.message_type = wmNetWmState;
xclient.format = 32;
xclient.data.l[0] = 1;
xclient.data.l[1] = wmStateAbove;
xclient.data.l[2] = 1;
xclient.data.l[3] = 1;
xclient.data.l[4] = 0;
printf(" default Window %d \n", DefaultRootWindow(display));
XSendEvent(display,
DefaultRootWindow(display), False,
SubstructureRedirectMask | SubstructureNotifyMask,
(XEvent*)&xclient);
可以在顶部创建窗口 但如果我使用xinit启动桌面系统,xinitrc脚本如下:
程序无法正常工作,提示_NET_WM_STATE和_NET_WM_STATE_ABOVE找不到,窗口不能放在顶部,是什么原因?
答案 0 :(得分:0)
如果此代码在窗口管理器启动并准备对消息作出响应之前执行,则在启动时执行此操作可能会很棘手。
该事件中也有一个错误; xclient.data.l [2]应该为0,而不是1。https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm46035372536800