4

I use fedora 14 system. When I use starx startup desktop systems, I created a Xlib program, the code is as follows:

    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);

The window can be created placed at the top But if I use xinit startup desktop systems, xinitrc script as follows,:

enter image description here

the program can't work normally, prompt _NET_WM_STATE and _NET_WM_STATE_ABOVE cannot find,the window can not be placed at the top, what's the reason?

cgmst
  • 41
  • 4

1 Answers1

0

Doing this at startup might be tricky, if this code executes before the window manager is up and ready to react to the message.

There's also an error in the event; xclient.data.l[2] should be 0, not 1. https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm46035372536800

Joe Sewell
  • 306
  • 1
  • 11